Integrating RF devices with sonoff rf bridge on Tasmota Firmware

Guys,
I’ve been looking at all posts’ codes and eventually created this thing (as a test, my intention is to toggle a light by pushing button A on a 433MHz remote).

This is what I get from tasmota console on my RFbridge (whose MQTT topic is RFbridge01) when I push button A:

21:28:44 MQT: RFbridge01/tele/RESULT = {"Time":"2020-01-08T21:28:44","RfReceived":{"Sync":10220,"Low":360,"High":990,"Data":"510044","RfKey":"None"}}

In configuration.yaml I’ve added following code:

binary_sensor:
    - platform: mqtt
      state_topic: 'tele/RFbridge01/RESULT'
      name: 'RFbridgeButtonA'
      value_template: '{{ value_json.RfReceived.Data }}'
      payload_on: '510044'
      payload_off: 'OFF'
      qos: 1

In automation.yaml:

- id: 'reset payload A'
  alias: Reset button A state
  hide_entity: true
  trigger:
  - platform: state
    entity_id: binary_sensor.RFbridgeButtonA
    from: 'off'
    to: 'on'
    for:
      seconds: 5
  action:
  - service: mqtt.publish
    data:
      topic: tele/RFbridge01/RESULT
      payload: OFF

Finally, the automation for switching off the light (I’m confident this is ok) is:

- id: '1578410245761'
  alias: TEST 433MHz remote (button A)
  description: ''
  trigger:
  - entity_id: binary_sensor.rfbridgebuttona
    platform: state
    to: 'on'
  action:
  - device_id: c4b6af22343d472b89621b27643bccda
    domain: light
    entity_id: light.luce_tv
    type: toggle

I really cannot see where the issue is but it definitely doesn’t work as it currently is…

Thanks, cheers.

Possibly you need to change this.
Something like

value_template: '{{ value_json.RfReceived.Data == '510044'? ON : OFF }}'

and get rid of payload_on and payload_off (but what would you do if you want to add another RF button?)

Actually, I’d suggest to get rid of the whole binary_sensor and use just one automation with trigger: platform: mqtt and a condition to run only when 510044 is received.
Even if you want to keep that sensors, nowadays there is no need to create a separate automation to turn it off - check this out.

Ahmadk, it seems that HA does not like you value_template grammar: it gives me an exclamation mark on editor top right corner with following wording

bad indentation of a sequence entry at line 103, column 81:
     ... Data == '510044' ? 'ON' : 'OFF' }}'

Anyway I agree with you about the MQTT trigger, I will have to study a bit and probably post again for help… :stuck_out_tongue:

Thanks for helping

Sorry, I haven’t checked it before posting. This should work

{% if Data == '510044' %}ON{%else%}OFF{%endif%}
1 Like

AhmadK, based on your suggestion I’ve modified the code in configuration.yaml as follows:

binary_sensor:
    - platform: mqtt
      state_topic: 'tele/RFbridge01/RESULT'
      name: 'RFbridgeButtonA'
      value_template: '{% if value_json.RfReceived.Data == '510044' %}ON{%else%}OFF{%endif%}'
      qos: 1

Which does not work: still gives the red exclamation mark…
After looking at some YAML syntax forums, I’ve eventually modified the code this way:

binary_sensor:
    - platform: mqtt
      state_topic: 'tele/RFbridge01/RESULT'
      name: 'RFbridgeButtonA'
      value_template: >
        {%if value_json.RfReceived.Data == '510044' -%}ON
        {%- else%}OFF
        {%- endif%} 
      qos: 1

Still no-go (but at least it seems that syntax is fine since the exclamation mark finally disappeared…

I don’t know, it’s crazy that such a basic feature (using 433MHz devices to trigger actions) has no clear solutions online…

Have a look at this topic :

1 Like

Thanks a lot Francis… I’ve been looking for it before posting but couldn’t find it…

binary_sensor:
- platform: mqtt
  name: 'RFremotebuttonA'
  state_topic: 'RFbridge01/tele/RESULT'
  value_template: >-
    {% if value_json.RfReceived.Data == '510044' %}
      {{'ON'}}
    {% else %}
      {{states('binary_sensor.rfremotebuttona') | upper}}
    {% endif %}
  off_delay: 5

Now the sensor (no device class) goes ‘On’ when pushing the remote button A and after 5 seconds gets back to ‘Off’.
I still have a problem with the automation for switching on a switch… (I know sounds very stupid and trivial but I’ve tried everything).
Automation doesn’t work either this way:

- id: '1578848075751'
  alias: BUTTON A OF RFREMOTE
  description: ''
  trigger:
  - entity_id: binary_sensor.rfremotebuttona
    platform: state
    to: 'On'
  action:
  - device_id: 953a0c1d89ca44cdb35aaef9caadf07c
    domain: switch
    entity_id: switch.sonoff_basic01
    type: toggle

…or this way:

- id: '1578848075751'
  alias: BUTTON A OF RFREMOTE
  description: ''
  trigger:
  - entity_id: binary_sensor.rfremotebuttona
    platform: state
    to: 'On'
  action:
    entity_id: switch.sonoff_basic01
    service: switch.toggle

Of course, if I force (trigger) the automation (either first or second version) the switch duly alternates ‘On’ and ‘Off’ state…
I have plenty of automations in my automations.yaml (none relevant with RFbridge inputs thought) and they all regularly working.
Sorry guys, I know we are talking about basics but cannot make it work…

Your problem is YAML is case-sensitive so states are, too. Standard states are ‘on’/‘off’ and they are not the same as ‘On’ or ‘ON’. Docs rule.
This should work:

- id: '1578848075751'
  alias: BUTTON A OF RFREMOTE
  trigger:
  - entity_id: binary_sensor.rfremotebuttona
    platform: state
    to: 'on'
  action:
    entity_id: switch.sonoff_basic01
    service: switch.toggle

Speaking about why my code didn’t work - that’s because the issue was in your original code, you used the wrong mqtt topic (tele/RFbridge01/RESULT) where it should be RFbridge01/tele/RESULT, the rest is pretty much the same if you compare your working and non-working versions :wink:
Glad you finally sorted it out.

1 Like

Man,
I really feel like the noob I am…
I’ve noticed the mistake in the code I’ve originally provided only yesterday (I’ve been away for the weekend) and corrected without mentioning that in the forum.

Thanks a lot for your help, it was really appreciated.
Cheers

PS: The ‘ON’, ‘On’ and ‘on’ really destroyed me :wink:
I’m not a programmer at all and started only recently with this hobby which is just one of the few I have (www.youtube.com/bragee) and completely not relevant with my daily job (which takes the biggest percentage of my time).
This is only to anticipate that “there will be other questions in the future…” :crazy_face:

Actually, your issue encouraged me to make a small PR on Docs as for some reason they use ‘On’ and ‘Off’ for binary sensor… :\

And no, there is no need to feel like a noob as soon as you did your research (i.e had read docs and had tried something and it failed) and asked your question here properly (in a correct section providing enough info to understand it). After all, that’s this forum exists for. And I believe that’s great.

Good luck in your journey!

2 Likes

My setup was working OK for 2 Years until now i getting some unknown codes,I’m using the Tasmota 8.1 firmware(upgraded from 7.2) with No Portisch flashed!

The problem: I’m use to receive the The EE66EE {“Sync”:12530,“Low”:440,“High”:1240,“Data”:“EE66EE”,“RfKey”:“None”}},which is the correct PIR2 code for me(and i got only 1 RF sender), and i got these now in one hour,i have the default PIR2 jumpers in place,no neighbor with 433 Mhz sender
Payload: FFFFFF
Payload: 773377
Payload: F08B01
Payload: FFFFFF
Payload: 773377
Payload: 773377

Sync:4140,Low:70,"High:130 the wrong codes are with these parameters

The battery is OK
For every case i will open the PIR2 to see for cold solder joints or a loosey goossey jumpers

Every so often, about 10 times a day, one of the doors that are controlled by mqtt opens. When I check the sonoff RF Bridge console, the same message always appears:

12:01:43 MQT: Connected
12:01:43 MQT: tele/bridge/LWT = Online (retained)
12:01:43 MQT: cmnd/bridge/POWER = 
12:01:43 MQT: stat/bridge/RESULT = {"RfCode":"#C1A722"}

The RFCode C1A722, is the one that opens the door. But I don’t know why it is launched. Any ideas??Thanks and regards!!!

It still is RF433. Could be random interference.

I have two different computers in different places configured in the same way. the second team does not have this problem

What have computers to do with rfbridges? I have 2 sonoff rfbridges, and some signals are received by one and not the other, because the range of the sonoff rfbridge is limited.

I mean two different teams in teeth houses. One has this problem and the other does not

Hello All :slight_smile:
First I would like to thank you for all the thoughts about and the guidance that was provided to integrated RF Devices with HA and Sonoff RF Bridge.
I’ve been trying to setup some RF Plugs - SilverCrest and Sonoff RF Bridge. I did all the firmware upgrate with Tasmota and all is working fine. I can see the Power Plugs Remote control MQT messages and the codes. Within the forum I can see that the Payloads for On and Off should have only one corresponding code, however with my devices this is not the case - I can see three different codes for payload_on and payload_off variables and I’m really struggling to understand how I can setup the binary_sensors properly with the capability to be switched on/off from HA.
Can someone please share some thoughts? :slight_smile:

The Extract from the MQT Messages below.

14:26:11 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:26:11”,“RfReceived”:{“Sync”:7270,“Low”:550,“High”:1010,“Data”:“CFB27C”,“RfKey”:“None”}}
14:26:12 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:26:12”,“RfReceived”:{“Sync”:7280,“Low”:550,“High”:1020,“Data”:“C55FAC”,“RfKey”:“None”}}
14:29:47 MQT: tele/tasmota_DBB64D/STATE = {“Time”:“2020-05-11T14:29:47”,“Uptime”:“0T01:30:12”,“UptimeSec”:5412,“Heap”:27,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“MqttCount”:1,“Wifi”:{“AP”:1,“SSId”:“DiSaSTeR”,“BSSId”:“F8:1A:67:5A:FC:21”,“Channel”:7,“RSSI”:100,“Signal”:-50,“LinkCount”:1,“Downtime”:“0T00:00:06”}}
14:31:03 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:03”,“RfReceived”:{“Sync”:7310,“Low”:500,“High”:1070,“Data”:“C26540”,“RfKey”:“None”}}
14:31:03 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:03”,“RfReceived”:{“Sync”:7290,“Low”:540,“High”:1030,“Data”:“CFB270”,“RfKey”:“None”}}
14:31:08 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:08”,“RfReceived”:{“Sync”:7280,“Low”:510,“High”:1060,“Data”:“CD9410”,“RfKey”:“None”}}
14:31:10 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:10”,“RfReceived”:{“Sync”:7290,“Low”:510,“High”:1050,“Data”:“C74A30”,“RfKey”:“None”}}
14:31:12 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:12”,“RfReceived”:{“Sync”:7300,“Low”:530,“High”:1040,“Data”:“C55FA0”,“RfKey”:“None”}}
14:31:15 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:15”,“RfReceived”:{“Sync”:7300,“Low”:540,“High”:1030,“Data”:“CFB270”,“RfKey”:“None”}}
14:31:17 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:17”,“RfReceived”:{“Sync”:7280,“Low”:510,“High”:1060,“Data”:“CD9410”,“RfKey”:“None”}}
14:31:21 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:21”,“RfReceived”:{“Sync”:7310,“Low”:510,“High”:1050,“Data”:“C74A30”,“RfKey”:“None”}}
14:31:25 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:25”,“RfReceived”:{“Sync”:7280,“Low”:530,“High”:1040,“Data”:“C55FA0”,“RfKey”:“None”}}
14:31:27 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:27”,“RfReceived”:{“Sync”:7280,“Low”:540,“High”:1020,“Data”:“CFB270”,“RfKey”:“None”}}
14:31:30 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:30”,“RfReceived”:{“Sync”:7280,“Low”:510,“High”:1060,“Data”:“CD9410”,“RfKey”:“None”}}
14:31:34 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:34”,“RfReceived”:{“Sync”:7300,“Low”:520,“High”:1050,“Data”:“C74A30”,“RfKey”:“None”}}
14:31:42 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:42”,“RfReceived”:{“Sync”:7290,“Low”:530,“High”:1040,“Data”:“C55FA0”,“RfKey”:“None”}}
14:31:49 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:49”,“RfReceived”:{“Sync”:7310,“Low”:550,“High”:1030,“Data”:“CFB270”,“RfKey”:“None”}}
14:31:52 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:31:52”,“RfReceived”:{“Sync”:7290,“Low”:510,“High”:1060,“Data”:“CD9410”,“RfKey”:“None”}}
14:32:36 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:32:36”,“RfReceived”:{“Sync”:7310,“Low”:520,“High”:1050,“Data”:“C74A30”,“RfKey”:“None”}}
14:32:42 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:32:42”,“RfReceived”:{“Sync”:7310,“Low”:530,“High”:1040,“Data”:“C55FA0”,“RfKey”:“None”}}
14:32:45 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:32:45”,“RfReceived”:{“Sync”:7370,“Low”:550,“High”:1030,“Data”:“CFB270”,“RfKey”:“None”}}
14:32:49 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:32:49”,“RfReceived”:{“Sync”:7310,“Low”:510,“High”:1070,“Data”:“CD9410”,“RfKey”:“None”}}
14:32:54 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:32:54”,“RfReceived”:{“Sync”:7330,“Low”:520,“High”:1060,“Data”:“C74A30”,“RfKey”:“None”}}
14:32:57 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:32:57”,“RfReceived”:{“Sync”:7350,“Low”:540,“High”:1040,“Data”:“C55FA0”,“RfKey”:“None”}}
14:34:47 MQT: tele/tasmota_DBB64D/STATE = {“Time”:“2020-05-11T14:34:47”,“Uptime”:“0T01:35:12”,“UptimeSec”:5712,“Heap”:27,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:20,“MqttCount”:1,“Wifi”:{“AP”:1,“SSId”:“DiSaSTeR”,“BSSId”:“F8:1A:67:5A:FC:21”,“Channel”:7,“RSSI”:100,“Signal”:-50,“LinkCount”:1,“Downtime”:“0T00:00:06”}}
14:35:30 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:35:30”,“RfReceived”:{“Sync”:7330,“Low”:540,“High”:1030,“Data”:“CFB270”,“RfKey”:“None”}}
14:35:34 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:35:34”,“RfReceived”:{“Sync”:7330,“Low”:500,“High”:1070,“Data”:“CD9410”,“RfKey”:“None”}}
14:36:08 MQT: tele/tasmota_DBB64D/RESULT = {“Time”:“2020-05-11T14:36:08”,“RfReceived”:{“Sync”:7310,“Low”:510,“High”:1060,“Data”:“C74A30”,“RfKey”:“None”}}

That is all for the same plug ?

Yes :slight_smile: two buttons from the same Remote Control which has in total 10…

Hello All :slight_smile:

I’m still struggling to setup the proper switch for those Power Plugs however i’ve managed to create Rules within Tasmota to publish ON & OFF message and now with the following binary sensor I can see the state change.

Can someone please advise, what is the proper way to create an entity for the Plug to be able to switch it on or off from Home Assistant?

Rule1
on rfreceived#Data=C74A30 do publish2 RFBridge/balcony_light ON endon on rfreceived#Data=CFB270 do publish2 RFBridge/balcony_light ON endon on rfreceived#Data=C26540 do publish2 RFBridge/balcony_light ON endon on rfreceived#Data=C6F1B0 do publish2 RFBridge/balcony_light ON"}

**Rule2 **
on rfreceived#Data=CD9410 do publish2 RFBridge/balcony_light OFF endon on rfreceived#Data=C55FA0 do publish2 RFBridge/balcony_light OFF endon on rfreceived#Data=C3CB90 do publish2 RFBridge/balcony_light OFF endon on rfreceived#Data=CC1020 do publish2 RFBridge/balcony_light OFF

binary_sensor:

  • platform: mqtt
    state_topic: “RFBridge/balcony_light”
    availability_topic: “tele/RFBridge/LWT”
    #value_template: ‘{{value_json.RfReceived.Data}}’
    name: ‘Balcony Light’
    payload_on: “ON”
    payload_off: “OFF”
    payload_available: “Online”
    payload_not_available: “Offline”
    device_class: plug
    qos: 1