Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Custom stats not displayed if numeric value is zero #444

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions library/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,22 +512,22 @@ def stats():
logger.error("Custom sensor class " + str(custom_stat) + " not found in sensors_custom.py")
return

if not string_value:
if string_value is None:
string_value = str(numeric_value)

# Display text
theme_data = config.THEME_DATA['STATS']['CUSTOM'][custom_stat].get("TEXT", None)
if theme_data and string_value:
if theme_data and string_value is not None:
display_themed_value(theme_data=theme_data, value=string_value)

# Display graph from numeric value
theme_data = config.THEME_DATA['STATS']['CUSTOM'][custom_stat].get("GRAPH", None)
if theme_data and numeric_value:
if theme_data and numeric_value is not None:
display_themed_progress_bar(theme_data=theme_data, value=numeric_value)

# Display radial from numeric and text value
theme_data = config.THEME_DATA['STATS']['CUSTOM'][custom_stat].get("RADIAL", None)
if theme_data and numeric_value and string_value:
if theme_data and numeric_value is not None and string_value is not None:
display_themed_radial_bar(
theme_data=theme_data,
value=numeric_value,
Expand Down