Skip to content

smashed-potatoes/phaos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phaos

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.

Requirements

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

Setup

  1. Make sure the script is executable with chmod +x app.py
  2. Set your mobile devices to have reserved/static IP assignments
  3. Set the following configuration items in phaos.cfg:
    • poll_interval: The number of seconds to wait between checking if the device(s) are connected
    • bridge_hostname: The hostname/IP of your Hue Bridge
    • city: 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 format Light Name = Time Config where Time Config is:
      • Always - No time constraints
      • Day - After dawn but before dusk
      • Night - After dusk or before dawn
      • H:M:S to H:M:S - A time frame, for example 10 AM to 4 PM would be 10: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
    • [Groups]: A list of groups to be controlled and their time configurations in the format Light Name = Time Config
      • Time Config is the same as the options for [Lights] above
    • [Devices]: In this section list your mobile devices in the format IP 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
  4. Configure log rotation in /etc/logrotate.conf
/var/log/phaos.log {
    missingok
    daily
    compress
    rotate 15
}

Usage

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