Skip to main content

A Hue bridge and Unifi controller client. Enables/disables specified Hue schedules in the presence/absence of specified wifi devices on the Unifi controller.

Project description

huunifie

A Hue bridge and Unifi controller client. Enables/disables specified Hue schedules in the presence/absence of specified wifi devices on the Unifi controller.

Installation

huunifie can be installed with the following command:

python3 -m pip install huunifie

Compatibility information

This code was only tested with python 3.5 and above under GNU/Linux with a Unify controller 5.9.29 and a hue bridge API version 1.28.0.

Usage

you@computer:~$ python3 -m huunifie --help
usage: huunifie.py [-h] [-uh UNIFI_HOST] [-up UNIFI_PORT] [-uu UNIFI_USERNAME]
                   [-uw UNIFI_PASSWORD] [-hh HUE_HOST] [-hp HUE_PORT]
                   [-hk HUE_KEY] [-wc WIFI_CLIENTS [WIFI_CLIENTS ...]]
                   [-sn SCHEDULES_NAMES [SCHEDULES_NAMES ...]] [-i INTERVAL]
                   [-c CONFIG_FILE] [-s] [-v] [-d] [-l LOG_FILE]
                   [-sh SYSLOG_HOST] [-sp SYSLOG_PORT]

A Hue bridge and Unifi controller client. Enables/disables specified Hue
schedules in the presence/absence of specified wifi devices on the Unifi
controller.

optional arguments:
  -h, --help            show this help message and exit
  -uh UNIFI_HOST, --unifi_host UNIFI_HOST
                        Unifi controller hostname (default: None)
  -up UNIFI_PORT, --unifi_port UNIFI_PORT
                        Unifi controller port (default: None)
  -uu UNIFI_USERNAME, --unifi_username UNIFI_USERNAME
                        Unifi controller username (default: None)
  -uw UNIFI_PASSWORD, --unifi_password UNIFI_PASSWORD
                        Unifi controller password (default: None)
  -hh HUE_HOST, --hue_host HUE_HOST
                        Hue hub hostname (default: None)
  -hp HUE_PORT, --hue_port HUE_PORT
                        Hue hub port (default: None)
  -hk HUE_KEY, --hue_key HUE_KEY
                        Hue hub API key (default: None)
  --no_pub              Disables zmq publication
  --pub                 Enables zmq publication
  --pub_host PUB_HOST   Host for zmq publication (default: *)
  --pub_port PUB_PORT   Port for zmq publication (default: 12168)
  -wc WIFI_CLIENTS [WIFI_CLIENTS ...], --wifi_clients WIFI_CLIENTS [WIFI_CLIENTS ...]
                        Wifi clients (hostname or mac) to monitor. Clients
                        names are separated by spaces. (default: None)
  -sn SCHEDULES_NAMES [SCHEDULES_NAMES ...], --schedules_names SCHEDULES_NAMES [SCHEDULES_NAMES ...]
                        Schedules to respectively enable/disable based on the
                        wifi clients presence/absence. Schedule names with
                        space(s) to be double-quoted. Schedule names are
                        separated by spaces. (default: None)
  -i INTERVAL, --interval INTERVAL
                        Polling interval (default: None)
  -c CONFIG_FILE, --config_file CONFIG_FILE
                        Path to configuration file. A template can be created
                        by using the -s option below. (default:
                        ~/.config/huunifie.conf)
  -s, --save_config     Safe configuration given on the command line to the
                        configuration file. (default: False)
  -v, --verbose         Prints events information on the console. (default:
                        False)
  -d, --debug           Verbose mode. (default: False)
  -l LOG_FILE, --log_file LOG_FILE
                        Path to log file. (default: None)
  -sh SYSLOG_HOST, --syslog_host SYSLOG_HOST
                        Syslog hostname. If present, the logfile is not
                        written locally (default: None)
  -sp SYSLOG_PORT, --syslog_port SYSLOG_PORT
                        Syslog port. (default: 514)

A Hue bridge and Unifi controller client. Enables/disables specified Hue
schedules in the presence/absence of specified wifi devices on the Unifi
controller.

Configuration

You can create a template configuration file by running huunifie with only the -s flag.

You can also test values on one or more different arguments then, adding -s to update your configuration. Only values specified on the command line will be update in the config file.

Examples:

  • Create a config file:
you@computer:~$ python3 -m huunifie -s -v -c /tmp/test_huunifie.conf
2018-12-10 21:55:38 [WARNING] : Configuration file /tmp/test_huunifie.conf not found.
2018-12-10 21:55:38 [   INFO] : Configuration saved to /tmp/test_huunifie.conf
2018-12-10 21:55:38 [  ERROR] : Unable to connect to the Unifi controller using https://localhost:8443
^C
you@computer:~$  cat /tmp/test_huunifie.conf
[general]
interval = 3
wifi_clients = 01:23:45:67:89:ab,your_device_hostname
schedules_name = A schedule name with spaces,another_without

[unifi]
host = localhost
port = 8443
username = hue
password = hue_password!!

[hue]
host = hue
port = 80
key = Your_40_alphanumeric_hue_api_key_please.
  • Update an existing config file
you@computer:~$ python3 -m huunifie -hh hue -uh unifi -v -s -c /tmp/test_huunifie.conf
2018-12-10 21:59:06 [   INFO] : Configuration loaded from /tmp/test_huunifie.conf
2018-12-10 21:59:06 [   INFO] : Configuration saved to /tmp/test_huunifie.conf
2018-12-10 21:59:06 [  ERROR] : Unable to connect to the Unifi controller using https://unifi:8443
^C
you@computer:~$ cat /tmp/test_huunifie.conf
[general]
interval = 3
wifi_clients = 01:23:45:67:89:ab,your_device_hostname
schedules_name = A schedule name with spaces,another_without

[unifi]
host = unifi
port = 8443
username = hue
password = hue_password!!

[hue]
host = hue
port = 80
key = Your_40_alphanumeric_hue_api_key_please.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

huunifie-0.4.3.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

huunifie-0.4.3-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file huunifie-0.4.3.tar.gz.

File metadata

  • Download URL: huunifie-0.4.3.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.9

File hashes

Hashes for huunifie-0.4.3.tar.gz
Algorithm Hash digest
SHA256 34f08c39a1ef3a5a5fcffc20043f562ed3a3fd4eefb053fb838779621483a284
MD5 30404ff20196c399c819b419bb151297
BLAKE2b-256 df019ef58a0dc74b9d482da4f5f38c33a8f2aaee3a2a4cff4f438edb39f41b62

See more details on using hashes here.

File details

Details for the file huunifie-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: huunifie-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.9

File hashes

Hashes for huunifie-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 adf2198df6d8fdd051f3da384e1e2b04a919111134d36730f43489311f2bb1c8
MD5 a5ca22737c21df06039ba1c9ac6b935b
BLAKE2b-256 6752d06d5c2461164e363d13e3ca5d4990c45337e345cc7f030ded0e1e667e8e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page