I’m trying to use the codes sent from esphome Sonoff RF Bridge in HA.
I would like to create a binary_sensor for each RF device, with the update method through automation when receiving events. The problem is that I have not found any binary_sensor platform that will allow me that.
I have seen examples with mqtt, but I don’t want to use it.
Any pointers? does this kind of “virtual” binary_sensor platform exist? Is there another way? Should I write a custom component?
I’ve seen it, but I cannot figure out how to configure it.
I get an event:
‘{
“event_type”: “esphome.rf_code_received”,
“data”: {
“sync”: “30fc”,
“low”: “1b8”,
“high”: “4ce”,
“code”: “xxxxxx”
},
“origin”: “LOCAL”,
“time_fired”: “2020-08-12T08:10:20.222480+00:00”,
“context”: {
“id”: “42cd82ec99bf428f9af48ec3929b6e73”,
“parent_id”: null,
“user_id”: null
}
}’
How would the configuration look like?
you said RF sensor, as I said if there is a sensor already reporting the code, you can use template binary sensor to create your binary sensors and skipping step 1-2.
if this is not an option I can’t think anything other way (except node-red), maybe others may suggest something else… good luck!
Ideally, there would be an Event Binary Sensor. You would configure it to listen for events to set its state to on or off. However, it does not exist. What does exist is the MQTT Binary Sensor which can be configured to subscribe to a topic whose payloads set its state to on or off (but you’ve stated you don’t want to use MQTT).
The simplest option is to do what you described:
However, this approach requires the combination of a Input Boolean and a Template Binary Sensor whereas the same result can be achieved with just an MQTT Binary Sensor (i.e. half the quantity of entities if you were to use MQTT). It’s something to consider if you have many sensors to configure.
Should you change your mind about using MQTT, I suggest you consider employing Strategy 2 in this post.
where xxxxxx is your sensor code received through esphome.rc_code.received event. The event is processed through the following automation (please note that my motion sensor sends only motion on event, not on and off separately as different codes).