{"id":22051596,"url":"https://github.com/parlaynu/hue-utilities","last_synced_at":"2025-10-07T11:53:14.318Z","repository":{"id":155555106,"uuid":"615134608","full_name":"parlaynu/hue-utilities","owner":"parlaynu","description":"Tools to monitor and log events from a Hue lighting system.","archived":false,"fork":false,"pushed_at":"2024-06-18T02:06:53.000Z","size":80,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-28T21:34:33.243Z","etag":null,"topics":["event-streaming","influxdb","philips-hue","pushover-notifications","zeroconf"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parlaynu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-17T02:47:27.000Z","updated_at":"2024-06-18T02:06:57.000Z","dependencies_parsed_at":"2024-06-08T07:40:27.123Z","dependency_job_id":"b9008474-10eb-483d-9a37-861c2e6eec51","html_url":"https://github.com/parlaynu/hue-utilities","commit_stats":null,"previous_names":["parlaynu/hue-utilities"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parlaynu%2Fhue-utilities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parlaynu%2Fhue-utilities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parlaynu%2Fhue-utilities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parlaynu%2Fhue-utilities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parlaynu","download_url":"https://codeload.github.com/parlaynu/hue-utilities/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245121640,"owners_count":20564154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-streaming","influxdb","philips-hue","pushover-notifications","zeroconf"],"created_at":"2024-11-30T15:09:54.040Z","updated_at":"2025-10-07T11:53:14.210Z","avatar_url":"https://github.com/parlaynu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Philips Hue Lighting System - Utilities\n\nThis repository has some utilities to query and monitor a hue lighting system.\n\nIt uses zeroconf to locate the bridge - if your app can find the bridge on your network, then these\nutilties will as well.\n\nYou can read about Hue [here](https://www.philips-hue.com/).\n\n\n## Getting Started\n\nThis section describes how to get started with listening for events.\n\nSetup python environment:\n\n    python3 -m venv pyenv\n    source pyenv/bin/activate\n    pip3 install -r requirements.txt\n\nRegister an application and create configuration:\n\n    ./bin/init-application.py [-n \u003capp-name\u003e] [-i \u003capp-instance\u003e]\n\nThis creates a configuration file in the `hlib.resources` directory that the other tools automatically find and use.\nIt uses a default application name with unique instance name if not provided.\n\n\n## Utilities\n\n| Utility           | Description                                                       |\n| ----------------- | ----------------------------------------------------------------- |\n| bridge-info.py    | find your bridge and pring some info about it                     |\n| ls-devices.py     | list all devices attached to your bridge                          |\n| ls-light.py       | print full configuration of the light                             |\n| ls-resource.py    | print information about any type of resource                      |\n| event-syslog.py   | log events to the system syslog facility                          |\n| event-influxdb.py | log to an influxdb database                                       |\n| read-temp.py      | reads the temperature from a devices that records temperature     |\n| silent-light.py   | attempts to configure your light to stay off after a power outage |\n| check-silent.py   | verify lights are configured to be silent; pushover notification  |\n\n### Bridge Info\n\nThis one is very simple. You don't need this info to run any of the other utilities, but if you're curious:\n\n    $ ./bin/bridge-info.py \n    Bridge:\n     Hostname: XXXXXXXXXXXXXXXX.local.\n           ID: XXXXXXXXXXXXXXXX\n        Model: BSB002\n    Addresses: 192.168.1.111\n         Port: 443\n\nIf you don't get a response but the app on your mobile device works, it's probably your firewall blocking\nthe response. \n\n### List Devices\n\nThis prints out all the devices on your bridge and the services they offer:\n\n    $ ./bin/ls-devices.py\n    \n    Product: Hue ambiance candle\n      Model: LTW012\n       Name: Lamp 1\n         ID: cacca7ff-5660-4379-929d-f435f94ee99c\n    Services:\n      - zigbee_connectivity\n        abf90a95-f0f9-429b-a282-3c89dfd4ba7b\n      - light\n        f702d8e5-9233-4160-95d7-28c4b924331e\n      - taurus_7455\n        bbdd254f-f4b2-4729-a3d5-f4a3da0cbaf9\n        \n    Product: Hue white lamp\n      Model: LWB010\n       Name: Backdoor\n         ID: f333430c-1775-496b-9d41-f6246f92e079\n    Services:\n      - zigbee_connectivity\n        f65f92e4-0473-4d60-89fc-bf72970c6cc6\n      - light\n        7d12ae2a-dad7-4564-833c-386f4b3f0e57\n      - taurus_7455\n        2c4b1320-22d9-4bad-9fa7-298bd17927ac\n        \n\n### List Light\n\nThis lists details of a light. Used the UUID from the light service listed in ls-devices.\n\n    $ ./bin/ls-light.py 7d12ae2a-dad7-4564-833c-386f4b3f0e57\n    {'alert': {'action_values': ['breathe']},\n     'color_temperature': {'mirek': 443,\n                           'mirek_schema': {'mirek_maximum': 454,\n                                            'mirek_minimum': 153},\n                           'mirek_valid': True},\n     'color_temperature_delta': {},\n     'dimming': {'brightness': 0.0, 'min_dim_level': 2.0},\n     'dimming_delta': {},\n     'dynamics': {'speed': 0.0,\n                  'speed_valid': False,\n                  'status': 'none',\n                  'status_values': ['none']},\n     'effects': {'effect_values': ['no_effect', 'candle'],\n                 'status': 'no_effect',\n                 'status_values': ['no_effect', 'candle']},\n     'id': '5fa16ad4-843e-41b4-bae6-4329a45f1f76',\n     'id_v1': '/lights/7',\n     'identify': {},\n     'metadata': {'archetype': 'table_shade', 'name': 'Kitchen'},\n     'mode': 'normal',\n     'on': {'on': False},\n     'owner': {'rid': 'a08b0c33-9718-4cec-ad0e-2d7a25464064', 'rtype': 'device'},\n     'powerup': {'color': {'color_temperature': {'mirek': 439},\n                           'mode': 'color_temperature'},\n                 'configured': True,\n                 'dimming': {'dimming': {'brightness': 49.01}, 'mode': 'dimming'},\n                 'on': {'mode': 'on', 'on': {'on': True}},\n                 'preset': 'custom'},\n     'signaling': {'signal_values': ['no_signal', 'on_off']},\n     'type': 'light'}\n\n\n## Syslog Logger\n\nTo run the syslogger, use this command:\n\n    $ ./event-syslog.py motion temperature light_level\n\nDepending on the setup of your rsyslog, this will write events to `/var/log/syslog` or whatever\nis the default on your system. See the next sections for different logging options.\n\n### Forwarding Logs to Remote System\n\nTo configure the local system to forward `local0` events to a remote system, edit the configuration file\n`/etc/rsyslog.conf` and add the line below, changing the `X.X.X.X` to the IP address of the remote system:\n\n    local0.*  action(type=\"omfwd\" target=\"X.X.X.X\" port=\"514\" protocol=\"udp\"\n                action.resumeRetryCount=\"100\"\n                queue.type=\"linkedList\" queue.size=\"10000\")\n\nThen update the default entry to not log any `local0` events to the default syslog file:\n\n    *.*;auth,authpriv,local0.none   -/var/log/syslog\n\nRestart and the events will be forwarded:\n\n    systemctl restart rsyslog\n\nYou can then setup logging on the remote system as in the section below.\n\n###  Logging to Separate File\n\nThere are two configuration changes that need to be made:\n\n1. direct `local0` facility events to their own log file\n2. stop `local0` events being sent to the default log file\n\nEdit the file `/etc/rsyslog.conf` and add the first line below and make the\nchanges to the second line:\n\n    local0.*                        /var/log/hue-events.log\n    *.*;auth,authpriv,local0.none   -/var/log/syslog\n\nRestart `rsyslog` and all should work:\n\n    systemctl restart rsyslog\n\n\n### Log Rotation\n\nTo setup log rotation, edit the file `/etc/logrotate.d/rsyslog` and add the file\n`/var/log/hue-events.log` to the list of log files to rotate - just make it match all\nthe others.\n\nI don't think the service needs to be restarted as it is run periodically on a timer,\nbut if you want to:\n\n    systemctl restart logrotate\n\n\n## InfluxDB Logger\n\nTo log to an InfluxDB, you need to setup the account and permissions as environment variables and \n\n    export IDB_TOKEN=\"influxdb-access-token\"\n    export IDB_ORG=\"influxdb-org-name\"\n    export IDB_BUCKET=\"influxdb-bucket-to-log-to\"\n    export IDB_URL=\"http://\u003cyour-influxdb-host\u003e:8086\"\n\n    ./bin/event-influxdb.py motion temperature light_level\n\nThe logger currently only logs 'temperature', 'light_level' and 'motion' events. There's no reason why\nother events can't be logged, I was just interested in these ones so didn't bother adding support for \nother event types or even better, generalizing the code to handle any event type. On the todo list.\n\nInformation about InfluxDB can be found [here](https://docs.influxdata.com/influxdb/v2.6/get-started/).\nTo install OpenSource InfluxDB 2.x, follow the instructions on their download portal\n[here](https://portal.influxdata.com/downloads/).\n\n\n## Silent Light\n\nI've had a few issues after power outages where the lights come on. This is normally OK except for when \nit happens in the middle of the night in the bedroom. From memory, there used to be a setting accessible \nfrom the app to control this, but I can't find it anymore. There is an option still available in the API \nthough which this utility uses to configure the option.\n\nIt works in a lot of situations I've tested, however, if the power if off for an extended period of time, \nthen they still come on with the power.\n\nOnce you have the light's id from the 'ls-devices.py' tool, you can run it like this:\n\n    $ ./bin/silent-light.py 7d12ae2a-dad7-4564-833c-386f4b3f0e57\n\nListing the light's settings once this has been run will show the powerup configuration to be off:\n\n    $ ./bin/ls-light.py 7d12ae2a-dad7-4564-833c-386f4b3f0e57\n    {...\n     'powerup': {'color': {'mode': 'previous'},\n                 'configured': True,\n                 'dimming': {'mode': 'previous'},\n                 'on': {'mode': 'on', 'on': {'on': False}},\n                 'preset': 'custom'},\n      ... }\n\nTest it by unplugging, waiting a few minutes and then plugging back in.\n\nTo do the opposite, that is have the light always turn on, run with the '--negate' flag.\n\n### Checking Silent Status\n\nTo verify that your lights are still in silent mode, you can use the check-silent.py application:\n\n    $ ./check-silent.py -h\n    usage: check-silent.py [-h] light_id [light_id ...]\n    \n    positional arguments:\n      light_id    id of light to check\n\nFor example:\n\n    $ ./check-silent.py fc513d4a-2b9b-4cc5-b0a7-38e4812949a1 c8dba9da-9b15-44f0-8888-0a4a72c3620a\n    fc513d4a-2b9b-4cc5-b0a7-38e4812949a1: name: Light1, silent: True\n    c8dba9da-9b15-44f0-8888-0a4a72c3620a: name: Light2, silent: True\n\nThis can also optionally send notifications to you using the pushover APP. To configure this, edit the configuration file\nin 'hlib/resources/config.yaml' and add these entries:\n\n    pushover_token: application-token\n    pushover_clients:\n    - client-key\n\nTo create your application and find your client key, refer to the [pushover API documentation](https://pushover.net/api).\n\nI run this as a cron job on a raspberry pi.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparlaynu%2Fhue-utilities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparlaynu%2Fhue-utilities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparlaynu%2Fhue-utilities/lists"}