Sonoff bridge sensors and battery code

I’m using this to handle my open / close sensors:

  • platform: mqtt
    state_topic: “tele/RF_Bridge/RESULT”
    name: “Office”
    value_template: “{{value_json.RfReceived.Data}}”
    payload_on: “30E00A”
    payload_off: “30E00E”
    device_class: door
    I found that these sensors also receive 30E006 for low battery. Can someone tell me how to integrate that in here? I’m using binary sensor in the automation so not sure how to handle a new code.

  • platform: state
    entity_id: binary_sensor.Office
    from: ‘on’
    to: ‘off’

I will try adding a new binary sensor for each one with the on using the payload for the battery low.

The configuration of the contact sensor is likely to cause warning messages (“No matching payload for entity”).

It is subscribed to tele/RF_Bridge/RESULT and will receive all payloads published to this topic.
30E00A -> payload_on
30E00E -> payload_off
30E006 -> no match; warning message
payloads from other sensors -> no match; warning message

Here is one way to configure it so it always reports a valid state regardless of what it receives.

- platform: mqtt
  name: 'Office'
  state_topic: 'tele/RF_Bridge/RESULT'
  value_template: >-
    {% if value_json.RfReceived.Data == '30E00A' %}
      {{'ON'}}
    {% elif value_json.RfReceived.Data == '30E00E' %}
      {{'OFF'}}
    {% else %}
      {{states('binary_sensor.office') | upper}}
    {% endif %}
  device_class: door

Here’s the low-battery binary sensor:

- platform: mqtt
  name: 'Door Low Battery'
  state_topic: 'tele/RF_Bridge/RESULT'
  value_template: >-
    {% if value_json.RfReceived.Data == '30E006' %}
      {{'ON'}}
    {% else %}
      {{states('binary_sensor.door_low_battery') | upper}}
    {% endif %}
  off_delay: 600
  device_class: battery

For more information:
Sonoff RF Bridge. Strategies for receiving data.

Thank you very much. I’ll try that.