I’ve looked it over quite a few times now and can’t see what I’m missing. I have the following string coming in through my gateway every 20s. I assume that means things are all good between my sensor and my gateway.
{"topic":"home/OMG_01/LORAtoMQTT/Soil01","node_id":"ID846758","hum":"29.27","temp":"25.95","adc":"76","bat":"949"}
Coupled with the following code in my config.yaml file.
mqtt:
sensor:
- name: "Soil01_Humidity"
state_topic: "home/OMG_01/LORAtoMQTT/Soil01"
value_template: >-
{% if (value_json.message|from_json).node_id == "ID846758" %}
{{ (value_json.message|from_json).hum }}
{% else %}
{{ is_state_attr("sensor.soil01_humidity") | round(2) }}
{% endif %}
unit_of_measurement: '%'
icon: mdi:water-percent
- name: "Soil01_Temperature"
state_topic: "home/OMG_01/LORAtoMQTT/Soil01"
value_template: >-
{% if (value_json.message|from_json).node_id == "ID846758" %}
{{ (value_json.message|from_json).temp }}
{% else %}
{{ is_state_attr("sensor.soil01_temperature") | round(2) }}
{% endif %}
unit_of_measurement: '°C'
icon: mdi:thermometer
- name: "Soil01_ADC"
state_topic: "home/OMG_01/LORAtoMQTT/Soil01"
value_template: >-
{% if (value_json.message|from_json).node_id == "ID846758" %}
{{ (value_json.message|from_json).adc }}
{% else %}
{{ is_state_attr("sensor.soil01_adc") }}
{% endif %}
unit_of_measurement: '%'
icon: mdi:flower
- name: "Soil01_Battery"
state_topic: "home/OMG_01/LORAtoMQTT/Soil01"
value_template: >-
{% if (value_json.message|from_json).node_id == "ID846758" %}
{{ (value_json.message|from_json).bat }}
{% else %}
{{ is_state_attr("sensor.soil01_battery") }}
{% endif %}
unit_of_measurement: 'V'
icon: mdi:battery
There must be something I’m missing between my gateway and home assistant.
Edit: I suspect my problem has to do with topics…