Very basic question I’m sure, but I’m struggling to get my head around this. I have a Sonoff Basic switch as well as a Sonoff RF bridge with a four button remote.
I have both flashed with Tasmota and talking to Home Assistant - I can control the switch from the GUI turning on and off, and I can see the button state change - I’m using the off_delay parameter to reset the state to off after one second. I’m trying to have home assistant change the state of the switch when the button is pressed (eg if it’s on turn it off, if it’s off turn it on), I have this in configuration.yaml at the moment:
Thanks for that - I’ve corrected that now, got a bit further, now have an automation which turns the sonoff switch on:
- alias: "Turn switch on"
trigger:
platform: state
entity_id: binary_sensor.Button_A
to: 'on'
condition:
condition: state
entity_id: switch.Sonoff_Switch_01
state: 'off'
action:
service: switch.turn_on
data:
entity_id: switch.Sonoff_Switch_01
So I think I’m nearly there, the final piece I’d like to figure out is how to tweak the condition - eg if the sonoff switch state is currently off then turn it on, however if it’s currently on then turn it off, in powershell I’d do an If statement on to check the state of switch.Sonoff_Switch_01 and fire actions based on that.
thanks for the info. i have been trying for 6 hours to get a simple sonoff basic switch to turn on with an RF remote through the sonoff bridge.
if i go into dev tools and try to call service of the switch entity nothing happens also. where is this broken !!!
the Mosquitto broker addon is indicating things are connected.
1564821541: New connection from 192.168.1.53 on port 1883.
1564821541: New connection from 192.168.1.51 on port 1883.
1564821541: New client connected from 192.168.1.53 as RF_Bridge (p2, c1, k30, u’sonoff’).
1564821541: New client connected from 192.168.1.51 as sonoff_51 (p2, c1, k30, u’sonoff’).
After many more hours and many more videos ive managed to get switches controlled through the RF remote. . . i ended up abandoning the yaml file editing and using all node red.
during this time i worked out that in the switch config the prefix was different.
however when i tried to change it around to %prefix%/%topic%/ it never saved it that way.
so i just changed the topic to “sonoff_51/cmnd/power” and it worked. . .