Page 1 of 1

Domoticz & Prometheus Integration

Posted: Monday 29 January 2018 23:39
by wywywywy
Hi all,

I guess there's probably a number of people here using Prometheus + Grafana to display various metrics for their homes.

Now Prometheus can easily go and grab JSON for metrics, and Domoticz does expose its metrics through the API.

So in theory this should be possible, but has anyone tried it yet? What is the easiest way to do this?

Personally I am particularly interested in energy usage and temperature metrics. And when I try to get the current usage this is what I get.

/json.htm?type=devices&rid=34

Code: Select all

{
   "ActTime" : 1517263547,
   "ServerTime" : "2018-01-29 22:05:47",
   "Sunrise" : "08:01",
   "Sunset" : "16:45",
   "result" : [
      {
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "894.0 Watt",
         "Description" : "",
         "Favorite" : 1,
         "HardwareID" : 7,
         "HardwareName" : "CurrentCost",
         "HardwareType" : "CurrentCost Meter USB",
         "HardwareTypeVal" : 65,
         "HaveTimeout" : false,
         "ID" : "0000002",
         "LastUpdate" : "2018-01-29 22:05:37",
         "Name" : "House Power",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "SubType" : "Electric",
         "Timers" : "false",
         "Type" : "Usage",
         "TypeImg" : "current",
         "Unit" : 1,
         "Used" : 1,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "34"
      }
   ],
   "status" : "OK",
   "title" : "Devices"
}
The main thing that worries me is the "Data" is a string not a number. Anyone knows how to get around this in Prometheus?

Thanks.

Re: Domoticz & Prometheus Integration

Posted: Saturday 29 September 2018 3:22
by wywywywy
In the end I created one myself.

I'm going to share it here in case it turns out to be useful to someone else as well.

https://github.com/wywywywy/domoticz_exporter

Re: Domoticz & Prometheus Integration

Posted: Monday 22 March 2021 22:39
by ggiblin
Well done that man.
It's a great exporter.
I installed it tonight.
It does exactly what I want.
Now to set-up a few alerts.

Thanks
Gerard