mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 22:55:10 +02:00
prometheus: Convert fahrenheit to celsius (#8511)
This commit is contained in:
committed by
Pascal Vizeli
parent
8c9557401f
commit
40aafcdf5d
@@ -17,6 +17,7 @@ from homeassistant.const import (CONF_DOMAINS, CONF_ENTITIES, CONF_EXCLUDE,
|
||||
TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||
from homeassistant import core as hacore
|
||||
from homeassistant.helpers import state as state_helper
|
||||
from homeassistant.util.temperature import fahrenheit_to_celsius
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -198,6 +199,8 @@ class Metrics:
|
||||
metric = self._metric(*metric)
|
||||
try:
|
||||
value = state_helper.state_as_number(state)
|
||||
if unit == TEMP_FAHRENHEIT:
|
||||
value = fahrenheit_to_celsius(value)
|
||||
metric.labels(**self._labels(state)).set(value)
|
||||
except ValueError:
|
||||
pass
|
||||
|
Reference in New Issue
Block a user