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

0 Members and 1 Guest are viewing this topic.

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4383
  • 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:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf