Hola,
I geeked out on smarthome monitoring, using Prometheus to gather metrics, and Grafana to make pretty charts. I came across a Python Promethus exporter here - this worked well for a while, but I wanted to do more, and I don't particularly enjoy using Python, so, doing what any self-respecting developer does, I ported it to my favorite platform, .NET!
My port of hubitat2prom, written in C#, can be found here; Docker images are here. Setup documentation can be found in the repository readme. I run this on a Raspberry Pi 4 alongside PiAware and a few other Prometheus exporters.
Like the original Python solution, this uses the Hubitat Maker API to gather device metrics. Those metrics are then translated into Prometheus exporter metrics so Prometheus can ingest them, and Grafana can chart them.
Unlike the Python version, I've added or changed the following:
- Support for all device attributes, with some attributes being explicitly handled. See here.
- Reduced HTTP requests by an order of magnitude - one request for all information instead of one per device. This is done with the Maker API /all endpoint.
- Added endpoint to get Prometheus metrics for a specific device.
- Type safety, even among types that differ within the Hubitat API.
- Async support for all I/O, freeing up CPU resources on the host system.
Here's an example of the metrics I'm collecting for one of my switches.
From Maker API:
{
"name":"Plug - PiAware",
"label":"Plug - PiAware",
"type":"Zooz Power Switch",
"id":"1063",
"date":"2022-03-08T07:33:28+0000",
"model":null,
"manufacturer":null,
"capabilities":[
"Configuration",
"Actuator",
"VoltageMeasurement",
"Refresh",
"PowerMeter",
"EnergyMeter",
"Outlet",
"Switch",
"Sensor"
],
"attributes":{
"voltage":"123.025",
"dataType":"NUMBER",
"values":null,
"voltageL":"0.000",
"voltageH":"8073117.696", // god knows what happened here
"frequency":null,
"powerL":"-2147476.366",
"switch":"on",
"powerH":"3665038759.25", // D:
"power":"7.731",
"energyDuration":"30.37 Days",
"current":"0.103",
"currentH":"134217.832",
"currentL":"0.000",
"energy":"5.58"
},
"commands":[
{
"command":"configure"
},
{
"command":"off"
},
{
"command":"on"
},
{
"command":"refresh"
},
{
"command":"resetCurrent"
},
{
"command":"resetEnergy"
},
{
"command":"resetPower"
},
{
"command":"resetVoltage"
}
]
}
From this application:
switch{device_name="plug___piaware"} 1.0
current{device_name="plug___piaware"} 0.103
energy{device_name="plug___piaware"} 5.58
power{device_name="plug___piaware"} 7.731
voltage{device_name="plug___piaware"} 123.025
Here's what my Grafana dashboard looks like, using data from this app.
Hope others find this useful!
Latest Release