mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Make prometheus light state report robust (#36134)
This commit is contained in:
parent
ad6e21182e
commit
a55c6c5f47
@ -15,6 +15,7 @@ from homeassistant.const import (
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
CONTENT_TYPE_TEXT_PLAIN,
|
||||
EVENT_STATE_CHANGED,
|
||||
STATE_ON,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UNIT_PERCENTAGE,
|
||||
@ -249,7 +250,7 @@ class PrometheusMetrics:
|
||||
)
|
||||
|
||||
try:
|
||||
if "brightness" in state.attributes:
|
||||
if "brightness" in state.attributes and state.state == STATE_ON:
|
||||
value = state.attributes["brightness"] / 255.0
|
||||
else:
|
||||
value = self.state_as_number(state)
|
||||
|
Loading…
x
Reference in New Issue
Block a user