Giter VIP home page Giter VIP logo

hue_exporter's Introduction

Hue exporter

Travis CI build Go report

This is a Prometheus exporter for the Philips Hue system. It's written in Go.

It exposes metrics about lights, groups and sensors. I hope you like it.

There are other Hue exporter projects. They didn't quite do what I wanted and to make them do what I wanted would have meant some pretty major changes. They might work for you though:

Here's a screenshot of an example Grafana dashboard: Grafana

Light metrics

Each light metric is labelled with the friendly name, the model, the type, the product name, the manufacturer name, and the unique ID.

  • hue_light_brightness
  • hue_light_hue
  • hue_light_saturation
  • hue_light_on: 0 means off, 1 means on
  • hue_light_reachable: 0 or 1 representing false or true

Group metrics

Each group metric is labelled with the name, and the type.

  • hue_group_brightness
  • hue_group_hue
  • hue_group_saturation
  • hue_group_on: 0 means off, 1 means some lights within the group are on, 2 means all lights within the group are on

Sensor metrics

Each sensor metric is labelled with the friendly name, the model, the type, the product name, the manufacturer name, the unique ID and the device ID (for motion sensor components). The device ID is a truncated version of the unique ID, that may be used to group the individual sensors that make up a single physical device.

  • hue_sensor_value: value varies depending on the type of the sensor. For switches, it's the value of the last button pressed; for daylight and presence sensors it's a 0 or 1 representing false or true values; for the temperature sensor it's hundredths of a degree celsius; for the light level sensor it's Lux.
  • hue_sensor_battery: battery level percentage (0 for sensors that have no battery)
  • hue_sensor_last_updated: last updated timestamp (Unix epoch)
  • hue_sensor_on: 0 or 1 representing false or true
  • hue_sensor_reachable: 0 or 1 representing false or true

Some sensor type values you might find useful:

  • Daylight: the Hue Hub's built-in "daylight" sensor, based on sunset / sunrise in your configured location
  • ZGPSwitch: the Hue tap switch
  • ZLLSwitch: the Hue dimmer switch
  • ClipGenericStatus: a generic sensor, usually a pseudo-sensor created through the API for automation purposes
  • ZLLTemperature: the temperature sensor in the Hue motion sensor
  • ZLLPresence: the presence sensor in the Hue motion sensor
  • ZLLLightLevel: the light level sensor in the Hue motion sensor

General metrics

  • hue_group_scrapes_failed, hue_light_scrapes_failed, hue_sensor_scrapes_failed: count of failures when trying to scrape from the Hue API.
  • hue_bridge_restarts: count of times the bridge has restarted (estimated based on sensor data).

Metric structure

Hey, why didn't you combine the metrics for brightness and hue and saturation and on and reachable?

I tried that, but because of the different label combinations, it didn't really work and you ended up with a load of empty labels.

Configuration

There's an example configuration file hue_exporter.example.yml in this repository, but you can also generate one! Run hue_exporter generate to have the app discover to your Hue bridge and create an API user for itself, then write the necessary configuration.

Running

hue_exporter --config.file hue_exporter.yml --listen.address :9366

Those flag values are the defaults, so you could just run hue_exporter on its own if you're happy with those.

Docker

There are a few docker images built, including ones for ARM7 (Raspberry Pi). You can find these on Docker Hub. They expose /etc/hue_exporter as a volume for you to generate or pass in your own configuration.

docker run -p 9366:9366 -v my_config.yml:/etc/hue_exporter/config.yml mitchellrj/hue_exporter:latest

License

MIT / X11 Consortium license. I'd prefer to use Apache 2.0, but the excellent Hue library that this app uses is GPL 2.0 and that isn't compatible with Apache.

hue_exporter's People

Contributors

mitchellrj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hue_exporter's Issues

`generate` in latest arm docker does not work

Hi,

First of all; many thanks for creating this exporter!

The generate function of armv7 docker build crashes:

$ docker run -it --rm --entrypoint /bin/hue_exporter mitchellrj/hue_exporter:latest-arm7 generate
INFO[0000] Starting hue_exporter (version=0.2.2, branch=master, revision=cea677bb6afc96e50885cc6d347ca0faf165a939)  source="main.go:117"
INFO[0000] Build context (go=go1.12, user=root, date=20190319-22:02:00)  source="main.go:118"
panic: Error while searching for Hue bridges on the local network: unable to locate bridge


goroutine 1 [running]:
main.generateConfig(0x1c0e200)
	/go/src/github.com/mitchellrj/hue_exporter/generate.go:16 +0x500
main.main()
	/go/src/github.com/mitchellrj/hue_exporter/main.go:123 +0x428

Any ideas? I cant do Go, so cant fix it :(

Cannot start on Raspberry pi

The issue

Hi, I'm using this very useful project on my laptop for a few days now and I'm in the process of migrating it to a raspberry pi server. But that is not that easy:

Running the published docker image for arm:

docker run --rm -it mitchellrj/hue_exporter:0.2.1-arm7
Unable to find image 'mitchellrj/hue_exporter:0.2.1-arm7' locally
0.2.1-arm7: Pulling from mitchellrj/hue_exporter
8e3ba11ec2a2: Pull complete 
cdf532e0d558: Pull complete 
69484a10f36b: Pull complete 
Digest: sha256:f96659046468c06c22bf2292fb366285875d39f142b1c16e5fee0e4bdb42bab7
Status: Downloaded newer image for mitchellrj/hue_exporter:0.2.1-arm7

standard_init_linux.go:190: exec user process caused "exec format error"

So I tried with to run the binaries published on the github release page:

wget https://github.com/mitchellrj/hue_exporter/releases/download/v0.2.1/hue_exporter.arm7
--2018-12-02 16:38:12--  https://github.com/mitchellrj/hue_exporter/releases/download/v0.2.1/hue_exporter.arm7
Resolving github.com (github.com)... 192.30.253.113, 192.30.253.112
Connecting to github.com (github.com)|192.30.253.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/143560568/d381880c-9da7-11e8-85c2-ccac3ba00508?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20181202%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20181202T153813Z&X-Amz-Expires=300&X-Amz-Signature=fc81b982d6892f111ba03ebf22463750b342bf8c87a660364b7aaac9dc4fafb6&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dhue_exporter.arm7&response-content-type=application%2Foctet-stream [following]
--2018-12-02 16:38:13--  https://github-production-release-asset-2e65be.s3.amazonaws.com/143560568/d381880c-9da7-11e8-85c2-ccac3ba00508?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20181202%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20181202T153813Z&X-Amz-Expires=300&X-Amz-Signature=fc81b982d6892f111ba03ebf22463750b342bf8c87a660364b7aaac9dc4fafb6&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dhue_exporter.arm7&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.128.51
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.128.51|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11240674 (11M) [application/octet-stream]
Saving to: 'hue_exporter.arm7'

hue_exporter.arm7                                           100%[=========================================================================================================================================>]  10.72M  5.49MB/s    in 2.0s    

2018-12-02 16:38:15 (5.49 MB/s) - 'hue_exporter.arm7' saved [11240674/11240674]
chmod +x hue_exporter.arm7
./hue_exporter.arm7
hue_exporter.arm7: error: path 'hue_exporter.yml' does not exist, try --help

and there it works. So, when run in the docker image it fails, but straight on the rpi, it works.

My workaround

I can successfully run the following image:

FROM alpine

# https://adminswerk.de/caddy-golang-on-alpine-armv6/
RUN apk add --no-cache libc6-compat

ADD https://github.com/mitchellrj/hue_exporter/releases/download/v0.2.1/hue_exporter.arm7 /bin/hue_exporter
RUN chmod +x /bin/hue_exporter

EXPOSE 9366
ENTRYPOINT ["/bin/hue_exporter"]
CMD ["--config.file=/etc/hue_exporter/config.yml"]

Resolution

I'm sorry I unable to contribute a fix, my Go tooling knowledge being insufficient.

I did notice something fishy:

file hue_exporter.arm7 
hue_exporter.arm7: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, not stripped

which seems to indicate the binary is not statically linked.

and also, the following Docker image fails:

FROM alpine

# https://adminswerk.de/caddy-golang-on-alpine-armv6/
RUN apk add --no-cache libc6-compat


COPY --from=mitchellrj/hue_exporter:latest-arm7 /bin/hue_exporter /bin
RUN chmod +x /bin/hue_exporter

EXPOSE 9366
ENTRYPOINT ["/bin/hue_exporter"]
CMD ["--config.file=/etc/hue_exporter/config.yml"]

Context

$ uname -a
Linux raspberrypi 4.14.79-v7+ #1159 SMP Sun Nov 4 17:50:20 GMT 2018 armv7l GNU/Linux
docker version
Client:
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:57:21 2018
 OS/Arch:           linux/arm
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:17:57 2018
  OS/Arch:          linux/arm
  Experimental:     false

How to run?

Hello and thank you very much for sharing this. I am trying to do the same but I am using telegraf and grafana to "paint" those graphics. My problem is that "telegraf" is putting all the data together so I end with an erratic graph with all the sensors together in the same line.

image

I want to ask you how to run your work. I have been following the instructions but when I download the code, I don't have any "hue_exporter" file so I can't run it.

I have tried to install prometheus and other things but I am not able to run this...

Sorry if this is not really an issue, maybe is just I don't know how to use it... But I didn't know another way to ask you about this project... I am very interested in having those graphs running as showed in your project.

Thanks!

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.