sidoh / esp8266_milight_hub

Replacement for a Milight/LimitlessLED hub hosted on an ESP8266
MIT License
931 stars 219 forks source link

Split On/Off to individual buttons? #759

Open smartroad opened 2 years ago

smartroad commented 2 years ago

Hi, Just found this awesome bit of coding. I was wondering, the on/off slider, could it be broken out into individual buttons for on and off?

I ask as I have remotes for my lights and the ESP doesn't know the state of the lights, so if the lights are on, but the ESP thinks they are off then I have to press the button twice. Once to "turn on" the lights and then again to turn them off. Having as individual buttons means just hitting the one needed.

Just a thought I've had using the system 😀

Best, Smartroad

poudenes commented 2 years ago

I had same issue with HA in combination with ESP wall switches. I solved it by let ESP listen to MQTT and change state of the ESP switch.

Yo can add the MQTT line of milight into this also

Schermafbeelding 2022-01-26 om 10 17 00

rule:

// SWITCH TURN ON BY HA
On ha_sys#sw1=1 do
  If [ha_dn#gn]=0 
    Neopixel,1,0,255,0
  Else 
    Neopixel,1,0,10,0
  Endif
Endon

On ha_sys#sw1=0 do
  If [ha_dn#gn]=0
    If [ha_dn#dt]=1 
      Neopixel,1,255,0,0
    Elseif [ha_sc#kodi]=1 
      Neopixel,1,255,0,255
    Elseif [ha_sc#tv]=1 
      Neopixel,1,0,70,100
    Elseif [ha_sc#atv]=1 
      Neopixel,1,100,100,0
    Elseif [ha_dn#ev]=1 
      Neopixel,1,255,0,0
    Endif
  Else 
    Neopixel,1,10,0,0
  Endif
Endon
// END

For me I only change Neopixel color, but you can add a line to change states of ESP :)

Maybe this is a solution for you also?