Skip to content

Commit 7918f25

Browse files
committed
Add warning for ghosting in custom_sensors
1 parent c4ad638 commit 7918f25

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/sensors/sensors_custom.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def as_string(self) -> str:
5656
# If this function is empty, the numeric value will be used as string without formatting
5757
# Example here: format numeric value: add unit as a suffix, and keep 1 digit decimal precision
5858
return f'{self.as_numeric(): .1f}%'
59+
# Important note! If your numeric value can vary in size, be sure to display it with a default size.
60+
# E.g. if your value can range from 0 to 9999, you need to display it with at least 4 characters every time.
61+
# --> return f'{self.as_numeric():>4}%'
62+
# Otherwise, part of the previous value can stay displayed ("ghosting") after a refresh
5963

6064

6165
# Example for a custom data class that only has text values

0 commit comments

Comments
 (0)