mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix Fahrenheit to Celsius conversion in Prometheus exporter (#52212)
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.
This commit is contained in:
parent
5c5e43afc1
commit
5d3f3c756f
@ -397,7 +397,7 @@ class PrometheusMetrics:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
value = self.state_as_number(state)
|
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)
|
value = fahrenheit_to_celsius(value)
|
||||||
_metric.labels(**self._labels(state)).set(value)
|
_metric.labels(**self._labels(state)).set(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user