AppDaemon idea: Smart bulbs + wall switch: Is this the best way?

So I’ve been trying to figure out how I will replace my wall switches to handle our LIFX bulbs (like a Hue) such that the lifx bulbs are always powered, and the switch merely toggles the lifx state. I now have this working, but it seems like quite a complicated method to do so, especially to get two way communication.

  • ESP8266 which publishes to an mqtt topic when switch is pressed / toggled
  • HASS mqtt switch configured with that topic
  • HASS lifx bulb configured
  • HASS automation to turn bulb on when switch turned to on
  • HASS automation to turn bulb off when switch turned to off
  • HASS automation to turn switch on when bulb turned to on (and switch is off)
  • HASS auotmation to turn switch off when bulb turned to off (and switch is on).

The reason I seem to need four automations (I could possibly reduce to two with templates) is that I want to be able to control the bulbs via the LIFX app as well as the switches. This works relatively well at the moment (occasionally states get out of whack). If I didn’t sync the switches on/off when the bulbs change then it’s possible for me to turn the lights off with the app, and then pressing the switch tries to turn them off again.

Is there a simpler way to do this, correlate switches with bulbs and sync state? I’m thinking this might be the perfect case for a new AppDaemon app?

I would not want something as basic as turning on a light to be dependent on my wifi network and an MQTT server.

That’s probably why most of the commercial products are using radios and proprietary hubs.

1 Like

While I appreciate your comment, it doesn’t help me in any way shape or form.

1 Like

It might. Maybe you should change your category for the post and add AppDaemon to the subject to get Andrew’s attention.

Thanks Robert, good idea

you can make 1 app for this.

import appdaemon.appapi as appapi

class togglelights(appapi.AppDaemon):

  def initialize(self):
    listen_state(toggle_lights,entity_bulb)
    listen_state(toggle_lights,entity_switch)

  def toggle_lights(self, entity, attribute, old, new, kwargs):
    if entity == entity_bulb:
      self.toggle(entity_switch)
   else:
      self.toggle(entity_bulb)
2 Likes

yeah - use switch.toggle.

My plan is to use a RFM12B radio net.

Have a momentary push button in the wall switch, which publishes an MQTT topic, which then triggeres the automation. So similar to yours, but not ESP8266.

Mine has to run off of batteries in the wall and the ESP8266 are too power hungry. So basically - same, but low power.

Nice! Since I’m powering from the mains the consumption isn’t as much an issue and it speaks a protocol I know relatively well. Does your device form a mesh network or just broadcast? I could be convinced to go low power :stuck_out_tongue:

Late to the thread but it looks like Rene answered the AppDaemon part of your question!

my light switches are switched active only, hence i cannot power it from mains. so i need to go the low power route.

Gotcha. I still like the idea of devices I’m adding drawing as little power as possible / being as efficient as possible.

I’m trying to switch Milight RGBWW Bulbs with Qubino Flush 2 Relays, I was creating a new topic in Configuration, but then I was notified of this thread, and it seems as if I’m going a slightly different route. I want to keep conventional wiring (for reliability, redundancy etc) so I’m putting Qubino Zwave relays behind the wall switches, then in the ceiling I have either groups of 6W Milight RGBWW Downlights or normal sockets with E27 or MR16/GU10 Milight 8W/4W RGBWW bulbs(so individually or in zones/groups per qubino switch). I’m looking for a way to unify the z-wave (or in my case, template) switch with the (soon to be arriving) Milight/LimitlessLED v7 bridge (currently have the v6 bridge, which should be supported this week). In the frontend I will have/need/want the Milights 5-channel (so Hue, Saturation, Brightness, Color Temperature) control, while the initial turnon and final turnoff commands should be coupled with the z-wave relays.

I haven’t tried out AppDaemon yet, and was thinking more in the direction of a template light or an extension of the template switch. As soon as the v6 bridge works (incl the RGBWW stuff) I will see how the two entities function together, but I don’t think I can get it working as described above. In the meantime I’m gonna try to implement this with my Hyperion LED lights (without actually putting them behind the relays), it’s not the same exactly, but the Milights remember their last state and come on within a second. Also I think that this setup would prevent the lights from disappearing in the frontend when their power is cut-off, this along with the fact that the upcoming v7 bridge promises 2-way statefullnes should make for a really smooth operating and highly functional lighting system.