Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions homeassistant/components/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import voluptuous as vol
from aiohttp import web

from homeassistant.components.climate import ATTR_CURRENT_TEMPERATURE
from homeassistant.components.http import HomeAssistantView
from homeassistant.const import (
EVENT_STATE_CHANGED, TEMP_FAHRENHEIT, CONTENT_TYPE_TEXT_PLAIN,
Expand Down Expand Up @@ -180,6 +181,15 @@ def _handle_climate(self, state):
'Temperature in degrees Celsius')
metric.labels(**self._labels(state)).set(temp)

current_temp = state.attributes.get(ATTR_CURRENT_TEMPERATURE)
if current_temp:
if unit == TEMP_FAHRENHEIT:
current_temp = fahrenheit_to_celsius(current_temp)
metric = self._metric(
'current_temperature_c', self.prometheus_client.Gauge,
'Current Temperature in degrees Celsius')
metric.labels(**self._labels(state)).set(current_temp)

metric = self._metric(
'climate_state', self.prometheus_client.Gauge,
'State of the thermostat (0/1)')
Expand Down