Products > Embedded Computing
"Group lights" with SOnOffs
(1/1)
paulca:
So my living room has a soft lights in each corner. Normally I have to go and turn them all on, one at a time.
A small light bulb moment (bad pun) and I figured if I made them all SOnOff switched I could implement firmware that would allow one switch to turn them all on/off.
As this is an extension to an existing home automation system, I just added something that was needed for other things anyway, "Demands".
In short, a Python UDP socket listens for JSON blobs with demands. Call it the Demand Server.
So when you "long press" the button on one of the SOnOffs it publishes a demand such as:
{"groupLights1": {"key":"groupLights1", "demandState":"ON"}}
These are merged into a full tree of demands in an in-memory dictionary.
On a TCP socket the same Python script will respond with the full JSON tree to any device that connects.
An additional Python script (keeping everything modular), called "Group Light Controller" polls this data every second and if it finds the demand for groupLights1 and it has changed from it's previous value, it will send the http command to all the group.
Here is a cartoon diagram of the system:
The code repo:
https://gitlab.com/paulcam/home_heating
Navigation
[0] Message Index
Go to full version