Setting up door sensor with 8266 rf gateway using OpenMQTTGateway

I am attempting to get a number of door / window sensors setup in Home Assistant using an RF gateway built on a D1 Mini. using OpenMQTTGateway I have the gateway working and receive the following payloads when the door is opened or closed:

closed: {"value":7821838,"protocol":1,"length":24,"delay":455}
open: {"value":7821834,"protocol":1,"length":24,"delay":455}

and I have the following binary sensor in HASS:

  - platform: mqtt
    name: "test"
    state_topic: "home/OpenMQTTGateway/433toMQTT"
    payload_on: "7821834"
    payload_off: "7821838"
    value_template: "{{ value }}"
    qos: 0
    device_class: opening

I have tried a number of templates to obtain the value but nothing seems to work. Any ideas? So far I have tried:

value_template: "{{ value.x }}"
value_template: "{{ trigger.payload_json[value] }}"
value_template: "{{ trigger.payload[value] }}"
  - platform: mqtt
    name: "test"
    state_topic: "home/OpenMQTTGateway/433toMQTT"
    value_template: >-
      {% if value_json.value == '7821834' %}
        {{'ON'}}
      {% elif value_json.value == '7821838' %}
        {{'OFF'}}
      {% else %}
        {{states('binary_sensor.test') | upper}}
      {% endif %}
    qos: 0
    device_class: opening

See the following post for more information. It discusses two strategies for receiving data from a Sonoff RF Bridge but it is applicable to any RF receiver that uses just one MQTT topic to publish data received from multiple devices.

2 Likes

Thank you! Only change I had to make to your config example to get it working was removing the ’ from around the numbers of the payload! Much appreciated!

Good catch! My mistake was not noticing value is numeric not string. Glad to hear it’s working for you now.

Update to this. I am now running Tasmota on the d1 mini as OMG was not stable and would crash and require reflashing to get it working again. Tasmota has been rock solid and running for 14 days with zero issues.