Author Topic: "Group lights" with SOnOffs  (Read 224 times)

0 Members and 1 Guest are viewing this topic.

Offline paulca

  • Super Contributor
  • ***
  • Posts: 2063
  • Country: gb
"Group lights" with SOnOffs
« on: August 17, 2019, 04:45:18 pm »
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
"What could possibly go wrong?"
Current Open Projects:  3 Channel Audio mixer with DAC, BT, pre-amps and h/phone amp, WS281x LED controller Version 2 5V/5A w/Atmega328, FY6600 Power supply, 5A DC Load (Still!)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf