I’m new to Home Assistant and using a Hassio installation on rPi3+ with Sonoff RF bridge. I’m using a binary sensor that sends a single code via MQTT. What I want is to change the state of this sensor from ‘on’ to ‘off’ each time Home Assistant receives this code. So far, I can see the sensor state change from ‘off’ to ‘on’ once only before having to reboot the system. I came across this article which seems to create a dummy variable to store the state in and I don’t think this is what I’m after exactly. Then came across this in the MQTT docs from home assistant and have placed this code in my configuration.yaml file. Here is the code I’m using:
@123 It looks like I spoke too soon, It worked for a while but after I rebooted and upgraded to Mosquitto 4.2, it broke. It looks like the broker is still receiving messages because this is in the log:
19-05-18 17:43:12 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tele/RF_Bridge/RESULT: b'{"RfReceived":{"Sync":11470,"Low":370,"High":1110,"Data":"E1AF46","RfKey":"None"}}
I think I’m having spacing issues. Are the ‘-alias’ and ‘action’ lines supposed to be indented in the same way as ‘-platform’ even though they are in separate files?
I have been trying to get one of these single code banggood rf switches to work using the example from Taras.
I can press the switch and the bridge receives the packet and publishes the word ON to the binary sensor but how do I get it to do the opposite when the switch is pressed again it only seems to publish ON if its state is OFF
These single code switches only have one code, so they will always send ‘ON’. What do you want to do with them ? I have a bunch of them, but I never tried to make them ‘OFF’, just use them in automations.
Instead of a switch, use an input_boolean to switch, and add an off_delay to your binary sensor.