RF Bridge with Tastmota. MQTT binary sensors are not working like they used to

Is anyone experiencing problems with this? I have had an RF Bridge for more than two years and everything was working fine. Now the sensors have either an unknown state or an unavailable state when HA starts.

MQTT binary sensors, lights, fans, humidifiers, and switches can now have an unknown state in case the state is unknown.

The state will be unknown until an MQTT message with the new state is received from your device.

What version of Tasmota are you using and which integration did you choose? Are you using the Tasmota integration? Using MQTT discovery with Tasmota is deprecated.

This is an example of a binary_sensor (magnetic door sensor that has only one code when opened):


- platform: mqtt
  name: "Porch Screen Door"
  state_topic: "Home/RF_Bridge/RESULT"
  payload_on: "901321"
  payload_off: "901321off"
  value_template: '{{value_json.RfReceived.Data}}'
  qos: 1
  device_class: 'door'
  off_delay: 5

The Sonoff RF bridge receives the code and sends the MQTT message to HA. When the door opens, HA shows the correct state of the door. My problem is that when HA restarts all those sensors have a state of unavailable. Same problem with all the PIR sensors. Until they sense movement they are unavailable.

I am creating an automation that publishes all MQTT closed/off codes when HA restarts. However I am having an issue with a script.

reset_mqtt_binary_sensor:
  description: 'Resets mqtt binary sensor'
  fields:
    code:
      description: 'Code to publish'
      example: 'XXXXXXoff'
  sequence:
    - service: mqtt.publish
      data:
        topic: Home/RF_Bridge/RESULT
        payload: >-
          "{\"RfReceived\": {\"Data\": \"{{ code }}\"}}"

##############################################
#This is how I call it within an automation

    - service: script.reset_mqtt_binary_sensor
      data:
        code: 'D95999off'


Unfortunately, I am doing something wrong.

I think you have too many quotes in your payload. Try this:

        payload: >-
          {"RfReceived": {"Data": "{{ code }}"}}

Please move this topic to #configuration.

1 Like

That worked! Thanks for your help!