Setting up rf door sensor in Home Assistant with 8266 rf gateway

I am attempting to get a number of door / window sensors setup in Home Assistant using an RF gateway built on a D1 Mini. 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] }}"


Try with

value_template: "{{ value_json.value }}"

Thanks @PetricaM! I had tried that one and I also cross posted this over on the Home Assistant forum. Here’s what we eventually got working in case someone else runs into this.

  - platform: mqtt
    name: "test"
    state_topic: "home/OpenMQTTGateway/433toMQTT"
    value_template: >-
      {% if value_json.value == 7821834 %}
      {% elif value_json.value == 7821838 %}
      {% else %}
        {{states('binary_sensor.test') | upper}}
      {% endif %}
    availability_topic: "home/OpenMQTTGateway/LWT"
    payload_available: "online"
    payload_not_available: "offline"
    qos: 0
    device_class: opening
1 Like