From 40aafcdf5df2abb10dd9ae08ecc6b9349f6d0244 Mon Sep 17 00:00:00 2001 From: Russell Cloran Date: Mon, 17 Jul 2017 02:25:20 -0700 Subject: [PATCH] prometheus: Convert fahrenheit to celsius (#8511) --- homeassistant/components/prometheus.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/prometheus.py b/homeassistant/components/prometheus.py index 4ed6028ac56..18a3a932d36 100644 --- a/homeassistant/components/prometheus.py +++ b/homeassistant/components/prometheus.py @@ -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