Giter Site home page Giter Site logo

homey-prometheus-exporter's Introduction

Prometheus exporter for Athom Homey

Prometheus exporter for Homey.

The following metrics are exported:

  • General system information (load averages, memory, storage).
  • Device state information (sensor values, state of switches, etc.). Device state gauges are named homey_device_<state> and have labels for device ID, name and zones.
  • User presence (present/away, awake/asleep)
  • Logic Variables
  • Weather data

How to support the project

  • If you can code, PRs with improvements and bug fixes are always appreciated. Be sure to check the issue list if there is anything up for grabs
  • There is a lot of different variations of the Homey nowadays. The maintainer currently runs a Homey early 2016 (the first production Homey), which is the device that gets the most testing. If you own a differnt Homey, testing and reporting issues is much appreciated.
  • If you prefer to, and have some money to spare, I have also set up a donate link that goes directly to purchasing more modern Homey devices so that I have a more modern device for testing.

How to use it

First, you need a Prometheus.io instance. The easiest way to install such an instance is to use Docker. This app has been developed and tested with the prom/prometheus:v2.1.0 image.

To add the Homey to Prometheus, you need to add the IP of Homey and port 9414 to the list of scrape targets. For example (prometheus.yml):

<...>
scrape_configs:
  <....>
  - job_name: 'homey'
    scrape_interval: 15s

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
     - targets: [
         '<ip address of Homey>:9414'
    ]

Here is an example docker-compose file:

grafana:
  image: grafana/grafana:5.0.1
  ports:
  - 3000:3000
  volumes:
    - ./data/grafana:/var/lib/grafana
  restart: unless-stopped
  environment:
    - GF_SECURITY_ADMIN_PASSWORD=mysecretpassword
    - GF_USERS_ALLOW_SIGN_UP=false
    - GF_AUTH_ANONYMOUS_ENABLED=true
prometheus:
  image: prom/prometheus:v2.1.0
  ports:
    - 9090:9090
  volumes:
    - ./config/prometheus:/etc/prometheus:ro
    - ./data/prometheus:/prometheus
    - ./logs/prometheus:/logs
  command:
    - '--config.file=/etc/prometheus/prometheus.yml'
    - '--storage.tsdb.path=/prometheus'
    - '--storage.tsdb.retention=365d'
    - '--web.enable-admin-api'

Troubleshooting

Browse to http://<homey_ip>:9414/metrics and make sure there is a response.

How to configure it

There is currently no configuration needed for this app.

homey-prometheus-exporter's People

Contributors

arpiecodes avatar azure-pipelines[bot] avatar dependabot[bot] avatar klippo avatar mikrofyr avatar rickardp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

homey-prometheus-exporter's Issues

Can't see self timer en counters of exporter

In debug mode I see these messages:

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connect listeners added. Use emitter.setMaxListeners() to increase limit
at d (/node_modules/athom-api/dist/index.js:1:1122279)
at t.value (/node_modules/athom-api/dist/index.js:1:1125071)
at t.value (/node_modules/athom-api/dist/index.js:1:1070714)
at t.value (/node_modules/athom-api/dist/index.js:1:1125140)
at t.value (/node_modules/athom-api/dist/index.js:1:1125371)
at /node_modules/athom-api/dist/index.js:1:1076978
at new Promise ()
at new t (/node_modules/athom-api/dist/index.js:1:27558)
at t. (/node_modules/athom-api/dist/index.js:1:1076948)
at a (/node_modules/athom-api/dist/index.js:1:324184) {
name: 'MaxListenersExceededWarning',
emitter: t {
_security: { oauth2: [Object] },
token: {
name: 'homey_auth',
isQuery: false,
value: 'f8bcf243-7814-4cfc-9bbd-fb11319c0f0c:1e1aba4d-0331-4ae4-ad96-30ecce1cdb79:ee6bbcb87d8b7515e3426884902b6b622bd156ec'
},
_caches: {
'HomeyAPI.ManagerDevices.Device': [e],
'HomeyAPI.ManagerDevices.Capability': [e]
},
_pendingCalls: {},
_baseUrl: 'http://localhost:80',
_basePath: '/api/manager/devices',
_eventNS: '/realtime/manager/devices/',
_eventURI: 'homey:manager:devices',
authorizationUrl: '',
managerName: 'ManagerDevices'
},
type: 'connect',
count: 11
}
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connect_error listeners added. Use emitter.setMaxListeners() to increase limit
at d (/node_modules/athom-api/dist/index.js:1:1122279)
at t.value (/node_modules/athom-api/dist/index.js:1:1125071)
at t.value (/node_modules/athom-api/dist/index.js:1:1070714)
at t.value (/node_modules/athom-api/dist/index.js:1:1125140)
at t.value (/node_modules/athom-api/dist/index.js:1:1125371)
at /node_modules/athom-api/dist/index.js:1:1076998
at new Promise ()
at new t (/node_modules/athom-api/dist/index.js:1:27558)
at t. (/node_modules/athom-api/dist/index.js:1:1076948)
at a (/node_modules/athom-api/dist/index.js:1:324184) {
name: 'MaxListenersExceededWarning',
emitter: t {
_security: { oauth2: [Object] },
token: {
name: 'homey_auth',
isQuery: false,
value: 'f8bcf243-7814-4cfc-9bbd-fb11319c0f0c:1e1aba4d-0331-4ae4-ad96-30ecce1cdb79:ee6bbcb87d8b7515e3426884902b6b622bd156ec'
},
_caches: {
'HomeyAPI.ManagerDevices.Device': [e],
'HomeyAPI.ManagerDevices.Capability': [e]
},
_pendingCalls: {},
_baseUrl: 'http://localhost:80',
_basePath: '/api/manager/devices',
_eventNS: '/realtime/manager/devices/',
_eventURI: 'homey:manager:devices',
authorizationUrl: '',
managerName: 'ManagerDevices'
},
type: 'connect_error',
count: 11
}
× Connection has been lost, exiting...

Not show all readings in grafana

I have setup Prometheus and Grafana.
When I make a graph in Grafana of the power metrics I get the complete list. About 20 devices.

Is it possible in Grafana to select which devices I want to see?
In the Prometheus graph I can switch them of.

Sorry for my bad English. I hope you understand what I mean.

Problem with /metrics page

Had it working but after a power failure at my home and the homey changed IP adress it no longer works, Have re-installed the app but can't get it working again. There is no page at http://<homey_ip>:9414/metrics.

nmap gives nothing:
nmap -sT -p- 192.x.x.186
Starting Nmap 7.93 ( https://nmap.org ) at 2022-10-04 21:58 CEST
Nmap scan report for homey-5c87___________6e27 (192.x.x.186)
Host is up (0.0086s latency).
Not shown: 65527 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
53/tcp open domain
80/tcp open http
443/tcp open https
5355/tcp open llmnr
41091/tcp open unknown
42339/tcp open unknown
51826/tcp open unknown

Prometheus app: 0.33

Any ideas from here?

3 times higher deviceupdate Call Rate since 0.3.3

It's me again, sorry. I've used the 0.3.3 test version and switched over to the normal 0.3.3 version. As you can see it has had a huge impact on the call rate. I've about factor 3 more for deviceupdate and registerdevice.
Screenshot 2022-09-14 at 08 22 03

Is that expected behavior? Interestingly It hasn't had much of an impact on the CPU...?

Crashing randomly since firmware version 8.0.6

Hi,
I’m experiencing crashes from Prometheus Exporter at random now. It used to be once a day around 4am but now it stops randomly and multiple times a day. Happy to help sort it out.

Very high CPU load with v0.2.10

As soon as I'm enabling the prometheus homey app, I see a drastically increased CPU load on my homey. Without prometheus I've between 50-100% load (with a few higher peaks), but as soon as I'm enabling prometheus app between 250-300% load! That's way too much and has impact to all my other apps...
Screenshot 2022-09-07 at 21 16 36

App does not start correctly after Homey reboot

After a Homey reboot (I experience zwave instability and have it reboot once a week) the Prometheus app does not start correctly so no data is sent to Prometheus until I restart the app on the Homey. I suspect the app starts before everything is ready on the Homey or something like that.

Exporting variables from homes "logic" feature.

I think it would be a great addition to also export the user-created logical variables, since they are useful to use as counters for things like flow runs, or even just to expose additional app information (like smart presence device connections, etc.) that wouldn't otherwise be collectable.

Just numerical and boolean values would already be great, but I think string values could also be pretty useful. Especially if it would be possible to also export some of the system/app default variables, like Spotify song information or hue light modes.

Maybe this should be something configurable to the user though, since (at least to me) it sounds like it could strain homeys CPU quite a bit.

status homey_device_alarm_contact not changing

So, I have to open a ticket to respond on a remark I made in another ticket:

homey_device_alarm_contact keeps hanging on value 1 and is not changing. I use Zigbee windows/door sensors and now they are not registering status 0 (closed). It worked before v2.0.

The strange thing is, the devices in Homey do show normal behavior, open or closed. Only in /metrics they seem to be stuck.

@rickardp you thought this was by design, but afterwards you saw there was apparently an issue with Fibaro (Zwave) devices.

So is this issue caused by the Prometheus app?

Add device-type and/or the source app as key

I’ve the issue that the “homey_device_measure_temperature” key has a lot of different temperatures, some of them (of a specific device type from one vendor) are reporting not a room but the device temperature - which is not important for end users. So I need to filter the device temperatures out. However I have no option to filter, exception for the “name”. As I know the device/type and app, is there any option to add a key/value-pair for the device-type and/or the app? Today I see the following keys:

  • device
  • instance
  • job
  • name
  • zone
  • zones

youless connection (LS120S0) homey->prometheus->Grafana

Hello Rickardp,
I’m trying to connect the measurements of a LS120 (youless) not the P1 connect but the S0 connection as a command string in prometheus.

It works with the code LS120P1:
homey_device_meter_power{device=“1202f494-c55d-4b64-8ce8-e4031d832d7d”,instance=“192.168.0.159:9414”,job=“homey”,name=“LS120P1@72:b7:ad:14:31:54”,zone=“Thuis”,zones=“Thuis”}

So i’ve tried to change the code P1 into S0:
homey_device_meter_power{device=“1202f494-c55d-4b64-8ce8-e4031d832d7d”,instance=“192.168.0.159:9414”,job=“homey”,name=“LS120S0@72:b7:ad:14:31:54”,zone=“Thuis”,zones=“Thuis”}

unfortunately it does not work, can anyone help me with the code, how can i get the measurements for the S0 contact. (In homey I can See the values)

Please let me know

ZigBee state export

Currently, Z-wave state is being exported but not ZigBee. Investigate if the state contains useful information (z-wave is very useful when debugging congestion/latency issues). Can the same thing be done here?

Also, both states have an event API, which should probably be used instead of polling as it works now.

0.2.7 App doesn't start up correctly if a variable value is 'null'

If a variable has null as value, the app doesn't start up correctly ( no open port on 9414 ) .

It also seems to stop responding when after a succesfull startup , a variable becomes 'null' .

See output on startup ( I added a console.log (var[varNames]) in app.js:115
{
__athom_api_type: 'HomeyAPI.ManagerLogic.Variable',
id: '022d21e7-d115-4017-86a5-9111bc541999',
name: 'Volume test',
type: 'number',
value: null
}
Unhandled Rejection at: Promise {
TypeError: Value is not a valid number: null
at Object.set (/node_modules/prom-client/lib/gauge.js:222:10)
at timeCode.name (/app.js:149:50)
at timeCode (/app.js:441:16)
at PrometheusApp.updateVariable (/app.js:139:9)
at /app.js:116:22
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async timeAsyncCode (/app.js:416:16)
at async PrometheusApp.onInit (/app.js:66:9)
} reason: TypeError: Value is not a valid number: null
at Object.set (/node_modules/prom-client/lib/gauge.js:222:10)
at timeCode.name (/app.js:149:50)
at timeCode (/app.js:441:16)
at PrometheusApp.updateVariable (/app.js:139:9)
at /app.js:116:22
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async timeAsyncCode (/app.js:416:16)
at async PrometheusApp.onInit (/app.js:66:9)

Homey 2.0 | Since beta update retrieve no data

I have updated Homey to version 2.0. Now Prometheus no longer receives data. All values are 0. Restarting the tool makes no difference. Or is prometheu.io no longer supported with version 2.0?

App in Homey gets set to Paused status

Describe the bug
The Prometheus.IO app is randomly being set to paused status which is only cleared by restarting the app

Diagnostics report ID
This was made yesterday but I'm not sure if it is of any use: c423a8f9-8a7a-4f0d-84b2-c665ee3a9b27
And another instance of it happening while I was creating this bug report: bebdbc25-2950-4d7e-a98c-da4aee3438a4
Another instance at just after 17:00 today: a99f6a78-2de3-4e0b-8e89-9b38f125ff8d
Again just after 20:00 even with scraping set to every 60 seconds (instead of 15 seconds): 6941bcf4-fc1e-49f0-a469-8c7182d7d944
And again just after 21:00 6ff6f11f-d0a3-4c53-8c28-65a172d1546b

Configuration
Hardware revision: "Homey Pro (Early 2019)".
Firmware version : 8.1.4

Additional context
I recently added 17 virtual devices to Homey (13 with just "measure power" capability and 4 others with "measure power" and "meter power" capability). Before that there were no apparent issues. Also I researched a bit an found somewhere that Homey does automatically sets apps in a paused state when said app used more than 80MB of memory.
The Prometheus.IO app is regularly using between 28 and 34MB of memory (while Athom/Homey mentions apps should not use more than 30MB) with occasional spikes to around 70MB but i could not find any occurrence in prometheus of the app using 80MB or more (possibly because the app is then on paused status and not sending it to the Prometheus server).
I already tried removing some unused apps and also removed some devices from Homey to see if that reduces the Prometheus.IO memory footprint but it does not appear to make any perceivable difference. I also have set now a Homey Flow to restart the Prometheus.IO app at 3:33 am but that does also not prevent the issue from happening it seems to be happening at random and the memory footprint does not seem to increase or decrease towards the time that it is stopped by Homey. The Prometheus server is querying Homey/Prometheus.io every 15 seconds.
I did find that the Grafana query "sum(rate(homey_exporter_self_time_seconds[$__rate_interval]))" shows a high spike a few seconds before the stop of Prometheus.IO of around 30 seconds while typically this would be no more than 3 seconds.
the following items seems to contribute the bulk of the spike "{action="updatedevicelist", device="_updatedevicelist", instance="192.168.34.161:9414", job="prometheus", name="_updatedevicelist", type="real", zone="_updatedevicelist", zones="_updatedevicelist"}", "{action="updatedevicelist", device="_updatedevicelist", instance="192.168.34.161:9414", job="prometheus", name="_updatedevicelist", type="system", zone="_updatedevicelist", zones="_updatedevicelist"}" and "{action="updatedevicelist", device="_updatedevicelist", instance="192.168.34.161:9414", job="prometheus", name="_updatedevicelist", type="user", zone="_updatedevicelist", zones="_updatedevicelist"}" apparently at about just after the whole hour mark (at least that is what Grafana shows [15-45 seconds after the whole hour]) these contribute a total of 26-28 seconds. Normally the spikes for this contribute about 5 seconds at just past the whole hour mark.

edit 19:14 CEST : I've now put the scraping interval of the Prometheus server to once every 60 seconds instead of once every 15 seconds. In the assumption that the multi second spikes take too long causing multiple scraping requests to queue up and increase memory usage until the cause of the spike has resolved.

edit 21:17 CEST: just after 20:00 CEST Prometheuse.IO was put to paused again even though the scraping interval was put to 60 seconds

edit 21:33 CEST: i have no created a flow that restarts Prometheus.IO every hour (with a delay of 4 minutes) so that at least if it gets paused just after the hour it gets restarted.

homey_memory_used doesn't add up to homey_memory_total - homey_memory_free

While creating a grafana dashboard I noticed that homey_memory_used doesn't add up to homey_memory_total - homey_memory_free

curl http://homey:9414/metrics -s |grep ^homey_memory|grep -E 'total|free' | awk '{print $NF}' | tr "\n" "-" | sed -e 's/-$//g' | bc -i|tail -n1 # TOTAL-FREE

447053824

curl http://homey:9414/metrics -s |grep ^homey_memory|grep used| awk '{ print $NF}' | tr "\n" "+" | sed -e 's/+$//g' | bc -i|tail -n1 # USED

386704384

Approx values while testing
homey_memory_total 511995904
homey_memory_free 59482112
homey_memory_swap 524288
homey_memory_used{component="homey:app:com.fibaro"} 13509632
homey_memory_used{component="homey:app:nl.timkouters.domitech"} 12764160
homey_memory_used{component="homey:app:com.google.chromecast"} 16764928
homey_memory_used{component="homey:app:com.panasonic.viera"} 14077952
homey_memory_used{component="homey:app:com.osram.lightify.zigbee"} 12962816
homey_memory_used{component="homey:app:com.ubnt.unifi"} 25013248
homey_memory_used{component="homey:app:nl.klikaanklikuit"} 12514304
homey_memory_used{component="homey:app:com.weather-sensors"} 13585408
homey_memory_used{component="homey:app:com.telldus"} 13387776
homey_memory_used{component="homey:app:com.everspring"} 13725696
homey_memory_used{component="homey:app:nl.tonversteeg.pushbullet"} 14837760
homey_memory_used{component="homey:app:net.i-dev.betterlogic"} 13369344
homey_memory_used{component="homey:app:openmindnl.ledcollection"} 22273024
homey_memory_used{component="homey"} 109253632
homey_memory_used{component="system"} 56203264
homey_memory_used{component="homey:app:io.prometheus"} 25985024

Am I doing something wrong, or is some stats missing?

Edit: Looked at systemInfo output, and the inconsistency is there. Nothing to do with the exporter

Zone activity

Hi

Is it possible to get zones activity into the exporter?
image

allow for prefix in /metrics when using multiple homey's

When you have multiple Homey's there is no option to give the metrics a prefix name it's always homey_
regardless the physical Homey you run it on.

So Homey Pro 2023 /metrics starts with homey_*

# HELP homey_boot_time Time of last Homey reboot
# TYPE homey_boot_time gauge
homey_boot_time{version="10.0.0-rc.73"} 1680941168932

and my first Homey Pro 2016 starts with homey_*

# HELP homey_boot_time Time of last Homey reboot
# TYPE homey_boot_time gauge
homey_boot_time{version="8.1.3"} 1680096455541

Virtual class

HI!

It would be great to have the virtual class - if exists - as a separate label. An example could be a socket with a light plugged in. In this case the class in Homey Developer Tools is: "socket (Virtual: light)"

conn refused /metrics page

Hi, I am currently unable to reach the metrics page using 9414.

App version 0.33
Tried restarting homey as well as restarting and reinstalling the prometheus app on homey.

When looking at app performance in homey I can see it is using memory.

nmap:
nmap -sT -p- 192.168..
Starting Nmap 7.92 ( https://nmap.org ) at 2022-12-14 16:59 UTC
Nmap scan report for homey-*****c431e (192.168..)
Host is up (0.024s latency).
Not shown: 65528 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
53/tcp open domain
80/tcp open http
443/tcp open https
5080/tcp open onscreen
5081/tcp open sdl-ets
5355/tcp open llmnr

I have sent a diagnostics report with 7ed02f78-fef3-4de6-8a0a-4bd37edb099d

Anything I can do here?

Export Weather API

If possible, export the data used for the Homey Weather API. Useful for people without e.g outdoor sensors.

State measure_power

Hi

Devices that do not have a built-in power meter can now have a power consumption setting when the unit is turned off or on. Is it possible to get the consumption into export, State measure_power?
image

Stop sending data

With varying intervals the app stop sending some data. In my case "Load Average 1,5 and 15" displayed in the same panel in Grafana. Restarting the app will resolve the issue and reporting is restored - for some time.

Running Prometheus 2.4.2 on an rpi 3. Homey is running firmware 1.5.13-rc.11

/PO

Some zero-values not exported

Hi,

I'm testing the exporter and it seems some for some metrics 0-value is not exported. Looks like it is stuck on the last non-zero value. Not sure if it's related to #9 or not.

Example from <ip>/metrics

# TYPE homey_device_onoff gauge
homey_device_onoff{device="be...",name="Desk lamp",zone="Living Room",zones="Home/Living Room"} 1

# TYPE homey_device_measure_power gauge
homey_device_measure_power{device="17...",name="Heater",zone="Living Room",zones="Home/Living Room"} 1283.5

The first is a Philips Hue lamp, the second a Fibaro Wall Plug.

The information is correct, 0/off for both, in the Homey App. For the wall plug, it is also correct in https://insights.athom.com/. The lamp is not in insights.

My setup:
Homey (Early 2019)
Homey 2.0.0, 1/3 free memory, lots of free storage
Fibaro App 2.1.19
Hue App 3.0.10
Prometheus.io 0.2.3

No response

Hi,

I've installed the app recently on my Homey running 1.5.8 and I cannot connect to it. In the app description it is stated that for troubleshooting, browse to http://<homey_ip>:9414/metrics. I cant get a response from there through Chrome.

Any tips on what to do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.