Skip to content

Commit

Permalink
Merge pull request auhlig#1 from gleichda/add_heating_metrics
Browse files Browse the repository at this point in the history
Add heating metrics
  • Loading branch information
auhlig authored Nov 25, 2019
2 parents 6531ecc + 164e4df commit 2d17891
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@ venv.bak/

# mypy
.mypy_cache/

# IntelliJ/PyCharm
/.idea
*.iml
37 changes: 37 additions & 0 deletions exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ def __init_metrics(self):
labelnames=labelnames,
namespace=namespace
)
self.metric_valve_adaption_needed = prometheus_client.Gauge(
name='valve_adaption_needed',
documentation='must the adaption re-run?',
labelnames=labelnames,
namespace=namespace
)
self.metric_temperature_offset = prometheus_client.Gauge(
name='temperature_offset',
documentation='the offset temperature for the thermostat',
labelnames=labelnames,
namespace=namespace
)
self.metric_valve_position = prometheus_client.Gauge(
name='valve_position',
documentation='the current position of the valve 0.0 = closed, 1.0 max opened',
labelnames=labelnames,
namespace=namespace
)
self.metric_humidity_actual = prometheus_client.Gauge(
name='humidity_actual',
documentation='Actual Humidity',
Expand Down Expand Up @@ -152,6 +170,22 @@ def __collect_thermostat_metrics(self, room, device):
.format(room, device.label, device.actualTemperature, device.setPointTemperature, device.humidity)
)

def __collect_heating_metrics(self, room, device):

# Do not check with if as 0 equals false
self.metric_temperature_actual.labels(room=room, device_label=device.label).set(device.valveActualTemperature)
self.metric_temperature_setpoint.labels(room=room, device_label=device.label).set(device.setPointTemperature)
self.metric_valve_adaption_needed.labels(room=room, device_label=device.label).set(device.automaticValveAdaptionNeeded)
self.metric_temperature_offset.labels(room=room, device_label=device.label).set(device.temperatureOffset)
self.metric_valve_position.labels(room=room, device_label=device.label).set(device.valvePosition)

logging.info(
"room: {}, label: {}, temperature_actual: {}, temperature_setpoint: {}, valve_adaption_needed: {}, "
"temperature_offset {}, valve_position: {}"
.format(room, device.label, device.valveActualTemperature, device.setPointTemperature,
device.automaticValveAdaptionNeeded, device.temperatureOffset, device.valvePosition)
)

def __collect_device_info_metrics(self,room, device):
logging.info(
"found device: room: {}, label: {}, device_type: {}, firmware_version: {}, last_status_update: {}, permanently_reachable: {}"
Expand Down Expand Up @@ -210,6 +244,9 @@ def collect(self):
if isinstance(d, (WallMountedThermostatPro, TemperatureHumiditySensorDisplay,
TemperatureHumiditySensorWithoutDisplay, TemperatureHumiditySensorOutdoor)):
self.__collect_thermostat_metrics(g.label, d)
elif isinstance(d, HeatingThermostat):
logging.info("Device of type heating")
self.__collect_heating_metrics(g.label, d)

except Exception as e:
logging.warning(
Expand Down

0 comments on commit 2d17891

Please sign in to comment.