Phaos is a script that turns on and off a group of Philips Hue lights based on certain devices being connected to the same network (i.e. mobile phones).
The reason it has been created is so that the lights only turn off when all people have left the home and turn on when at least one has returned.
The following can be installed using pip: pip install [package]
- scapy - Used for polling devices with ARP ping
- phue - Used to control the Philips Hue devices
- python-daemon - Used to daemonize the script
- astral - Used to get the sun set / sun rise times
- Make sure the script is executable with
chmod +x app.py
- Set your mobile devices to have reserved/static IP assignments
- Set the following configuration items in
phaos.cfg
:poll_interval
: The number of seconds to wait between checking if the device(s) are connectedbridge_hostname
: The hostname/IP of your Hue Bridgecity
: Your current city (used to determine sun rise / sun set time)[Lights]
: A list of lights to be controlled and their time configurations in the formatLight Name = Time Config
whereTime Config
is:Always
- No time constraintsDay
- After dawn but before duskNight
- After dusk or before dawnH:M:S to H:M:S
- A time frame, for example 10 AM to 4 PM would be10:00:00 to 16:00:00
- Time frames that span into the next day can also be used, for example 10 PM to 4 AM would be
22:00:00 to 4:00:00
- Time frames that span into the next day can also be used, for example 10 PM to 4 AM would be
[Groups]
: A list of groups to be controlled and their time configurations in the formatLight Name = Time Config
Time Config
is the same as the options for[Lights]
above
[Devices]
: In this section list your mobile devices in the formatIP Range to scan = MAC Address
- E.g.
192.168.0.10/32 = 12:34:56:78:90:AB
- Or IP range:
192.168.0.0/24 = 12:34:56:78:90:AB
- E.g.
- Configure log rotation in
/etc/logrotate.conf
/var/log/phaos.log {
missingok
daily
compress
rotate 15
}
Before running the daemon for the first time, press the button on top if your hue hub, this allows it to get an auth token. This only needs to be done the first time, it stores the hue token in ~/.python_hue
The daemon can be started, stopped or restarted by calling the script with the appropriate command:
sudo ./app.py start|stop|restart
Note: The daemon must be run with sudo to allow for access to the socket for the ARP ping