Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95387

MQTT sensor status changed to N/A when value was not received

$
0
0

@snaiperr wrote:

Dear All, I have the following config:

sensor:
  - platform: mqtt
    state_topic: "home/studio/esp/st"
    value_template: "{{ value_json.dht_t }}"
    name: "dht_t"
    unit_of_measurement: "°C"
    expire_after: 60

switch:
  - platform: mqtt
    command_topic: "home/studio/esp/set/1"
    state_topic: "home/studio/esp/st"
    value_template: "{{ value_json.b1 }}"

as you can see the state_topic is the same for the both devices.
The problem is the following:
when device performed switch action, the device must to reply to the HA a new state, The reply must to include the all sensors data, in other case the state in HA immediately will be changed to the N/A for not received sensors.

In my case, when switch action performed, the electromagnetic noise is very big and device cannot read sensor thus reply does not contain the sensor data.

Example:
Here the standard status/state report from device:
home/studio/esp/st : b'{ "T_0053":25.00,"b1":1,"b2":1,"b3":1,"b4":1,"b5":0,"b6":0,"b7":0,"b8":0,"dht_t":25.70,"dht_h":42.00 }'

Here command to switch:
home/studio/esp/set/5 : b'1'

And in reply is missing dht_t and dht_h parameters:
home/studio/esp/st : b'{ "T_0053":25.00,"b1":1,"b2":1,"b3":1,"b4":1,"b5":1,"b6":0,"b7":0,"b8":0 }'

After 5 seconds in the next status report the dht parameters will be present and value will be propertly displayed.

The problem N1: the extra “N/A” state will be logged
The problem N2: as the parameter "expire_after: 60 " defined, the state N/A should be applied only in two scenarios: 1: time is expired, 2: the state N/A received from the device like
{ "dht_t" : null, "dht_h": none }

Posts: 6

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>