MQTT sensor values not displaying

Hi,

I have been using HA for a while, I have added a couple of new sensors that send their values via MQTT. I have an existing set of sensors sending via the same server, working perfectly.

The new sensors will not display a value on the dashboard. I have confirmed that they are reaching the MQTT server and available. Could someone see if they can see something obvious…

Example JSON payload sent to MQTT

{"water-temp":27.50,"Humidity":95.00,"air-temp":26.10,"count":6120}

Extract from my config: Note the top two are working, bottom 3 are not

sensor:
  # Weather prediction
  - platform: yr
  - platform: mqtt
    name: "Temperature"
    state_topic: "office/sensor1"
    unit_of_measurement: 'c'
    value_template: "{{ value_json.temperature }}"
  - platform: mqtt
    name: "fishtemp"
    state_topic: "sensor/fishtank"
    unit_of_measurement: 'c'
    value_template: "{{ value_json.temperature }}"
  - platform: mqtt
    name: "waterlevel"
    state_topic: "sensor/fishtank"
    value_template: "{{ value_json.waterlevel }}"  
  - platform: mqtt
    name: "biopodwatertemp"
    state_topic: "biopod/readings"
    unit_of_measurement: 'c'
    value_template: "{{ value_json.water-temp }}"
  - platform: mqtt
    name: "biopodhumdity"
    state_topic: "biopod/readings"
    unit_of_measurement: '%'
    value_template: "{{ value_json.Humidty }}"
  - platform: mqtt
    name: "biopodairtemp"
    state_topic: "biopod/readings"
    unit_of_measurement: 'c'
    value_template: "{{ value_json.air-temp }}"    

Screenshot of the dashboard & Config (I had to combine as new users can only send one image)

Only value in the Logs

2019-11-02 21:07:18 WARNING (MainThread) [homeassistant.components.sensor] Setup of platform yr is taking over 10 seconds.

Example payload from the working sensors

{"temperature":19.37,"count":2229,"waterlevel":28}

Try it with:

  - platform: mqtt
    name: "biopodwatertemp"
    state_topic: "biopod/readings"
    unit_of_measurement: 'c'
    value_template: "{{ value_json['water-temp'] }}"
  - platform: mqtt
    name: "biopodairtemp"
    state_topic: "biopod/readings"
    unit_of_measurement: 'c'
    value_template: "{{ value_json['air-temp'] }}"

for the key’s with hyphens.
The Humidity value_template should work when you correct the typo.

value_template: "{{ value_json.Humidity }}"
1 Like

You legend, thank you! On the typo… thanks, dyslexia and coding does not go hand in hand, many a night wasted on a simple typo!