r/tasmota•
corus87

Need a bit help with a rule to get the current power state by MQTT

Hi,

I've got a wall switch and a E27 LEDW bulb both flashed with tasmota. Now if the bulb is off, I want to turn the white light on (255,255,255,255) and if the bulb is already on (doesn't matter what color) the switch should turn it off.

I know how setup a rule to power toggle the bulb, but how can I make a rule, to get the current power state of the bulb by MQTT?
So that the switch knows the bulb is on (because I also can turn the bulb on with HASS or by voice assistant), so in this case pressing the button on the switch would turn the light off.

Thanks in advanced.

Posted Sep 17, 2020, 12:21 PM UTC

13
digiblur•

Could you just do device groups? https://youtu.be/Bp1BsTe2zyY

1
corus87OP•

Device groups looks like a nice feature, but still it would only toggle the state and the switch wouldn't turn on the white light.
I ask in the tasmota discord channel, and it seems like there is no easy way to accomplish my plan. I may have to setup the logic in HA.
Anyway thanks for your reply.

1
catalintabirca•

You need subscribe and ifelse compiled. Store the state of the bulb in a variable (subscribe to stat/power and stat/result) create a rule for the button (if var1 is on do off, else color white) read the rule cookbook for inspiration

1