Trying to get home assistant recognizing my rf devices

I’m using Home Assistant 0.95.4 / OpenMQTTGateway

output from MQTT (home/OpenMQTTGateway/SRFBtoMQTT)

doorbell :

{“raw”:“24FE01400398D81F91”,“delay”:9470,“val_Tlow”:320,“val_Thigh”:920,“value”:14163857}

light switch :

{“raw”:“2724016803D41285A2”,“delay”:1002,“val_Tlow”:360,“val_Thigh”:980,“value”:1213858}

rf outlet :

on : {“raw”:“118A009601CCFFD55F”,“delay”:4490,“val_Tlow”:150,“val_Thigh”:460,“value”:16766303}

off : {“raw”:“119400A001C2FFD55F”,“delay”:4500,“val_Tlow”:160,“val_Thigh”:450,“value”:16766303}

this is my configuration.yaml

binary_sensor:
  platform: mqtt
  name: doorbell
  state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
  value_template: "{{ value_json.raw }}"
  off_delay: 30
  payload_on: "24EA01400398D81F91"
  payload_off: "0"
  device_class: 'sound'

binary_sensor:
  platform: mqtt
  name: light_back_sensor
  state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
  value_template: '{{ value_jason.value }}'
  off_delay: 5
  payload_on: 1213858
  payload_off: "0"
  
binary_sensor:
  platform: mqtt
  name: rf_outlet_sensor
  state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
  value_template: '{{ value_json.raw }}'
  payload_on:  "119E00A001C2FFD55F"
  payload_off: "119400A001C2FFD55F"
  

No success until now with all the tries. What am I doing wrong ?

First thing is to see what your MQTT broker is seeing. Use mosquItto_sub or another MQTT tool to see.

This is what mosquito is seeing (copied from MQTT fx)

afbeelding

Hello,

You should use the “value” field instead of raw one. Indeed the raw can vary for one device. Value should not. The counter part is that you are not able to distinguish the on and off signal of your rf outlet.

Yes, but even then I don’t get any automations triggers.

I see the mqtt messages arriving in the log

2019-07-06 11:28:45 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on home/OpenMQTTGateway/SRFBtoMQTT: b’{“raw”:“271A015E03DE1285A2”,“delay”:1001,“val_Tlow”:350,“val_Thigh”:990,“value”:123858}’
DEBUG (MainThread) [homeassistant.components.mqtt] Received message on home/OpenMQTTGateway/SRFBtoMQTT: b’{“raw”:“2724016803D41285A2”,“delay”:1002,“val_Tlow”:360,“val_Thigh”:980,“value”:1213858}’ 2019-07-06 11:28:57 INFO (MainThread) [homeassistant.components.automation] DEBUG (MainThread) [homeassistant.components.mqtt] Received message on home/OpenMQTTGateway/SRFBtoMQTT: b’{“raw”:“1194009601CCFFD157”,“delay”:4500,“val_Tlow”:150,“val_Thigh”:460,“value”:16765271}’

I ended up with this configuration.yaml

binary_sensor:
  platform: mqtt
  name: doorbell
  state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
  #value_template: "{{ value_json.raw }}"
  value_template: >- 
    {% if value_json.value == '14163857' %}
      {{'ON'}}
    {% else %}
      {{states('binary_sensor.doorbell') | upper}}
    {% endif %}
  off_delay: 30
  device_class: 'sound'

binary_sensor:
  platform: mqtt
  name: light_back_sensor
  state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
  #value_template: '{{ value_jason.value }}'
  value_template: >- 
    {% if value_json.value == '1213858' %}
      {{'ON'}}
    {% else %}
      {{states('binary_sensor.light_back_sensor') | upper}}
    {% endif %}
  off_delay: 5

binary_sensor:
  platform: mqtt
  name: rf_outlet_sensor
  state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
  value_template: >- 
    {% if value_json.value == '16766303' %}
      {{'ON'}}
    {% else %}
      {{states('binary_sensor.rf_outlet_sensor') | upper}}
    {% endif %}

but still nothing.

Have you checked this proposal :

it seems Home Assistant only sees the last binary sensor defined. I found out by moving things around in configuration.yaml. I don’t know why or how to fix it.

That’s because you have “binary_sensor:” entered more than once. You can only have one of those. I’m surprised there are no errors in the logs telling you that. But here is how you should configure it:

binary_sensor:
  - platform: mqtt
    name: doorbell
    state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
    #value_template: "{{ value_json.raw }}"
    value_template: >- 
      {% if value_json.value == '14163857' %}
        {{'ON'}}
      {% else %}
        {{states('binary_sensor.doorbell') | upper}}
      {% endif %}
    off_delay: 30
    device_class: 'sound'
  - binary_sensor:
    platform: mqtt
    name: light_back_sensor
    state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
    #value_template: '{{ value_jason.value }}'
    value_template: >- 
      {% if value_json.value == '1213858' %}
        {{'ON'}}
      {% else %}
        {{states('binary_sensor.light_back_sensor') | upper}}
      {% endif %}
    off_delay: 5
  - binary_sensor:
    platform: mqtt
    name: rf_outlet_sensor
    state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
    value_template: >- 
      {% if value_json.value == '16766303' %}
        {{'ON'}}
      {% else %} 
        {{states('binary_sensor.rf_outlet_sensor') | upper}}
      {% endif %}

Thanks ! This fixed it. Spent allready two days tinkering with configuration. Configuration -> General -> Configuration Validation never showed an error :disappointed_relieved:

Glad it’s working.

That’s the rule for all top level domains (switch, sensor, binary_sensor, light, automation, etc). They are all entered into your configuration as a list in the same way by starting each sub-section with a dash.