hue-exporter

command module
v0.0.0-...-1c0a2ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

README

Hue Exporter

Prometheus exporter for Hue Lights, written in Go with metric collectors.

Installation and Usage

If you are new to Prometheus there is a getting started guide. The hue_exporter listens on HTTP port 8080 by default and exposes the metrics under /metrics.

Hue Configuration

To run this exporter you will need an applicationKey generated by your Hue system. Find out the IP Address of your system and push the pairing button. Generate an Application Key by using the following POST web request: https://{{ip}}:16021/api/v1/new.

ip="" # fill in your ip
wget --no-check-certificate \
  --method POST \
  --body-data '{"devicetype":"exporter"}' \
   "https://$ip/api"
$ip = "" # fill in your ip
$body = "{`"devicetype`":`"exporter`"}"
$response = Invoke-RestMethod 'https://${ip}/api' -Method 'POST' -Body $body
$response | ConvertTo-Json

The hue_exporter is configured via a config.yaml file. You can find an example here.

Docker

The hue_exporter is designed to monitor everything from the Hue System.

There are three different architectures available: amd64, arm64, arm for linux. If you are running this on a normal PC or NAS System you should be fine with amd64 while Raspberry and other systems might need an arm based image.

docker run -d \
  -v "/path/to/config.yaml:/config.yaml" \
  -p 8080:8080 \
  patrickdomnick/hue-exporter:latest-amd64

For Docker compose, similar flag changes are needed.

---
version: '3.9'

services:
  hue_exporter:
    image: patrickdomnick/hue-exporter:latest-amd64
    container_name: hue_exporter
    restart: unless-stopped
    ports:
      - "8080:8080"
    volumes:
      - 'config.yaml:/config.yaml'

Metrics

The following default Labels will be applied to all Metrics even if some collectors do not support these types:

  • deviceID
  • deviceName
  • modelID
  • productName
  • productArchetype
  • manufacturerName
  • roomID
  • roomName
  • roomArchetype
Light
Name Description Unit
hue_light_on On/Off state of the light Boolean (0-1)
hue_light_brightness Brightness percentage Percentage (0-100)
hue_light_color_x X position in CIE gamut position Percentage (0-1)
hue_light_color_y Y position in CIE gamut position Percentage (0-1)
Level
Name Description Unit
hue_level Light level in 10000*log10(lux) + 1 Lux
Motion
Name Description Unit
hue_motion 1 if motion is detected Boolean (0-1)
Power
Name Description Unit
hue_power_level The current battery state in percent Percentage (0-100)
Temperature
Name Description Unit
hue_temperature Temperature in 1.00 degrees Celsius Celsius

Development building and running

Prerequisites:

Building:

git clone https://gitlab.com/PatrickDomnick/hue-exporter.git
cd hue-exporter
goreleaser build --snapshot --rm-dist

Running:

go run main.go

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
hue

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL