MQTT Binary_Sensor configuration not working

Hi folks,

I finally got my ByeByeStandby 433MHz RF switches configured in HA RfCode payloads. While working through the triage to get them working I noticed that the Sonoff Bridge records the following in the log when a key is pressed on the remote:

22:33:37 SER: Received A4 2A 58 01 68 04 1A 14 00 15 55
22:33:37 MQT: tele/sonoffrfbr/RESULT = {“RfReceived”:{“Sync”:10840,“Low”:360,“High”:1050,“Data”:“140015”,“RfKey”:1}}
22:33:40 SER: Received A4 2A 4E 01 68 04 1A 14 00 14 55
22:33:40 MQT: tele/sonoffrfbr/RESULT = {“RfReceived”:{“Sync”:10830,“Low”:360,“High”:1050,“Data”:“140014”,“RfKey”:5}}

This set me away thinking that I could configure a sensor to change whenever a button on the remote was pressed, by monitoring for that payload, or more specifically the ‘Data’ portion. My intention ultimately is to use the sensor state in later automations.

The config of the Sensor doesn’t work and I even tried looking for the RfKey value instead as some others seem to have done, but neither work and the binary sensors always show as off in the front end.

The config I’m using is:

binary_sensor:
  • platform: mqtt
    name: “BB1button”
    state_topic: “tele/sonoffrfbr/RESULT”
    value_template: ‘{{ value_json.RfReceived.Data }}’
    payload_on: “140015”
    payload_off: “140014”
  • platform: mqtt
    name: “BB1button2”
    state_topic: “tele/sonoffrfbr/RESULT”
    value_template: ‘{{ value_json.RfReceived.Rfkey }}’
    payload_on: “1”
    payload_off: “5”

I’m also seeing warnings in the logs:

2018-11-02 22:17:06 WARNING (MainThread) [homeassistant.components.binary_sensor.mqtt] No matching payload found for entity: BB1button with state_topic: tele/sonoffrfbr/RESULT
2018-11-02 22:17:06 WARNING (MainThread) [homeassistant.components.binary_sensor.mqtt] No matching payload found for entity: BB1button2 with state_topic: tele/sonoffrfbr/RESULT

Can anyone advise what is wrong with my configuration or advise of a better way to monitor for Remote key presses?

Thanks.

Please edit your post and format your code as per the blue banner at the top of the page.

Are the mqtt messages being sent to your mqtt broker or only the bridge?

I did a copy and paste of your configuration, and the quote marks were not ascii. Replacing them all with standard ascii (including in the message being sent), caused everything to work as expected.

binary_sensor:
    - platform: mqtt
      name: "BB1button"
      state_topic: "tele/sonoffrfbr/RESULT"
      value_template: '{{ value_json.RfReceived.Data }}'
      payload_on: "140015"
      payload_off: "140014"

With the message sent like
For Off

$ mosquitto_pub -t tele/sonoffrfbr/RESULT -m '{"RfReceived":{"Sync":10830,"Low":360,"High":1050,"Data":"140014","RfKey":5}}'

For On

$ mosquitto_pub -t tele/sonoffrfbr/RESULT -m '{"RfReceived":{"Sync":10830,"Low":360,"High":1050,"Data":"140015","RfKey":5}}'

Thank you so much for your help, I’d probably never have spotted those rogue quote marks.

I guess I must have picked them up when I cut ‘n’ pasted the value_template command from an example elsewhere as I was editing my config in Configurator. As soon as I corrected those and the lowercase ‘k’ in RfKey, both the sensors worked fine.

Apologies I didn’t get the formatting right for the code I pasted in, I’ll try to get it right next time.

1 Like