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.pull/52295/head
parent
5c5e43afc1
commit
5d3f3c756f
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue