From 5d3f3c756fc4ea4085252a1e23d0dd438c496699 Mon Sep 17 00:00:00 2001 From: Christopher Masto Date: Mon, 28 Jun 2021 03:19:49 -0400 Subject: [PATCH] Fix Fahrenheit to Celsius conversion in Prometheus exporter (#52212) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit const.TEMP_FAHRENHEIT is "°F", but _unit_string converts this to "c", so the comparison never succeeds and we end up with temperatures in F but labeled C. --- homeassistant/components/prometheus/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/prometheus/__init__.py b/homeassistant/components/prometheus/__init__.py index b253daf559e..c74caa745f3 100644 --- a/homeassistant/components/prometheus/__init__.py +++ b/homeassistant/components/prometheus/__init__.py @@ -397,7 +397,7 @@ class PrometheusMetrics: try: value = self.state_as_number(state) - if unit == TEMP_FAHRENHEIT: + if state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_FAHRENHEIT: value = fahrenheit_to_celsius(value) _metric.labels(**self._labels(state)).set(value) except ValueError: