Domoticz & Prometheus Integration

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.
Post Reply
wywywywy
Posts: 13
Joined: Wednesday 27 September 2017 23:32
Target OS: Linux
Domoticz version:
Contact:

Domoticz & Prometheus Integration

Post by wywywywy » Tuesday 30 January 2018 0:39

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.

wywywywy
Posts: 13
Joined: Wednesday 27 September 2017 23:32
Target OS: Linux
Domoticz version:
Contact:

Re: Domoticz & Prometheus Integration

Post by wywywywy » Saturday 29 September 2018 3:22

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest