From a55c6c5f47a5fe84ee4ec959d83881cb1660afd7 Mon Sep 17 00:00:00 2001 From: Nacho Barrientos Date: Wed, 27 May 2020 09:59:40 +0200 Subject: [PATCH] Make prometheus light state report robust (#36134) --- homeassistant/components/prometheus/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/prometheus/__init__.py b/homeassistant/components/prometheus/__init__.py index 314695458b0..c09c20ec3b0 100644 --- a/homeassistant/components/prometheus/__init__.py +++ b/homeassistant/components/prometheus/__init__.py @@ -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)