home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.17k stars 30.2k forks source link

MQTT sensor values from esphomelib sensor are not displayed #18240

Closed cybrwshl closed 5 years ago

cybrwshl commented 5 years ago

Home Assistant release with the issue: 0.81.6

Last working Home Assistant release (if known): Unknown

Operating environment (Hass.io/Docker/Windows/etc.): Docker

Component/platform: https://www.home-assistant.io/components/mqtt

Description of problem: MQTT sensor values from esphomelib sensor are not displayed

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

mqtt:
  broker: <PRIVATE_IP>
  discovery: true

Traceback (if applicable):

2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/bedroom_environment/bedroom_gas/config: b'{"unit_of_measurement":"\xe2\x84\xa6","expire_after":180,"icon":"mdi:gas-cylinder","name":"Bedroom Gas","state_topic":"bedroom_environment/sensor/bedroom_gas/state","availability_topic":"bedroom_environment/status"}'
2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on bedroom_environment/sensor/bedroom_gas/state: b'nan'
2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/bedroom_environment/bedroom_humidity/config: b'{"unit_of_measurement":"%","expire_after":180,"icon":"mdi:water-percent","name":"Bedroom Humidity","state_topic":"bedroom_environment/sensor/bedroom_humidity/state","availability_topic":"bedroom_environment/status"}'
2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on bedroom_environment/sensor/bedroom_humidity/state: b'nan'
2018-11-05 18:27:47 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: sensor bedroom_environment_bedroom_gas, sending update
2018-11-05 18:27:47 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: sensor bedroom_environment_bedroom_humidity, sending update
2018-11-05 18:27:47 INFO (MainThread) [homeassistant.components.mqtt] Got update for entity with hash: ('sensor', 'bedroom_environment_bedroom_gas') '{'unit_of_measurement': 'Ω', 'expire_after': 180, 'icon': 'mdi:gas-cylinder', 'name': 'Bedroom Gas', 'state_topic': 'bedroom_environment/sensor/bedroom_gas/state', 'availability_topic': 'bedroom_environment/status'}'
2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/bedroom_environment/bedroom_pressure/config: b'{"unit_of_measurement":"hPa","expire_after":180,"icon":"mdi:gauge","name":"Bedroom Pressure","state_topic":"bedroom_environment/sensor/bedroom_pressure/state","availability_topic":"bedroom_environment/status"}'
2018-11-05 18:27:47 INFO (MainThread) [homeassistant.components.mqtt] Got update for entity with hash: ('sensor', 'bedroom_environment_bedroom_humidity') '{'unit_of_measurement': '%', 'expire_after': 180, 'icon': 'mdi:water-percent', 'name': 'Bedroom Humidity', 'state_topic': 'bedroom_environment/sensor/bedroom_humidity/state', 'availability_topic': 'bedroom_environment/status'}'
2018-11-05 18:27:47 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: sensor bedroom_environment_bedroom_pressure, sending update
2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on bedroom_environment/sensor/bedroom_pressure/state: b'nan'
2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/bedroom_environment/bedroom_temperature/config: b'{"unit_of_measurement":"\xc2\xb0C","expire_after":180,"name":"Bedroom Temperature","state_topic":"bedroom_environment/sensor/bedroom_temperature/state","availability_topic":"bedroom_environment/status"}'
2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on bedroom_environment/sensor/bedroom_temperature/state: b'nan'
2018-11-05 18:27:47 INFO (MainThread) [homeassistant.components.mqtt] Got update for entity with hash: ('sensor', 'bedroom_environment_bedroom_pressure') '{'unit_of_measurement': 'hPa', 'expire_after': 180, 'icon': 'mdi:gauge', 'name': 'Bedroom Pressure', 'state_topic': 'bedroom_environment/sensor/bedroom_pressure/state', 'availability_topic': 'bedroom_environment/status'}'
2018-11-05 18:27:47 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: sensor bedroom_environment_bedroom_temperature, sending update
2018-11-05 18:27:47 INFO (MainThread) [homeassistant.components.mqtt] Got update for entity with hash: ('sensor', 'bedroom_environment_bedroom_temperature') '{'unit_of_measurement': '°C', 'expire_after': 180, 'name': 'Bedroom Temperature', 'state_topic': 'bedroom_environment/sensor/bedroom_temperature/state', 'availability_topic': 'bedroom_environment/status'}'
2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on bedroom_environment/sensor/bedroom_temperature/state: b'21.2'
2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on bedroom_environment/sensor/bedroom_pressure/state: b'671.4'
2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on bedroom_environment/sensor/bedroom_humidity/state: b'54.2'
2018-11-05 18:27:47 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on bedroom_environment/sensor/bedroom_gas/state: b'138087.0'

Additional information: I configured a ESP32 with an BME680 to send all sensor values via MQTT to HA. The auto discovery seems to work, but HA don't display any of the values in the ui. In the log you can see that all values are gathered, but nothing more!

image

Edit: I'm using an external mosquitto MQTT broker.

DickSwart commented 5 years ago

Same issue here

OttoWinter commented 5 years ago

What do you see under the MQTT topic bedroom_environment/status ?

unavailable means the ESP is not connected to the MQTT broker and the availability reporting fails.

giig982 commented 5 years ago

Same issue here on HA ver 0.82.1 with esphomeyaml ver. 1.8.2 on a NodeMCU with a DHT11 sensor.

The "status" topic for the sensor show it's "online" but after about 30" the sensor on Home Assistant is shown as "unknown".

If I launch a $mosquitto_sub -h 192.168.6.245 -t 'sensor_cameraletto/#' to read the status of the NodeMcu, I can see:

online 36.9 20.6 [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.mqtt:093]: 'CameraLetto Temperature': Pushing out value 20.799999 with 1 decimals of accuracy 20.8 [D][sensor.mqtt:093]: 'CameraLetto Humidity': Pushing out value 37.866665 with 1 decimals of accuracy 37.9 [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=44.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0% [D][sensor.dht:054]: Got Temperature=21.0°C Humidity=38.0%

EDIT: I have to clarify that the sensor is autodiscovered... but for a MQTT Sensor, HA set a default value of 0 to expire_after . @OttoWinter maybe is this the source of the problem?

h0jeZvgoxFepBQ2C commented 5 years ago

I have a similar problem, tried it first with MQTT and afterwards with native Homeassistant-API.

ESP connects to the API, but disconnects afterwards. No exceptions in the logs found:

[23:07:51][D][api:531]: Client 'Home Assistant 0.85.1 (192.168.0.178)' connected successfully!
[23:07:54][D][sensor.dht:066]: Got Temperature=20.7°C Humidity=51.1%
[23:08:24][D][sensor.dht:066]: Got Temperature=20.7°C Humidity=51.2%
[23:08:29][D][api:241]: '192.168.0.178' disconnected.
h0jeZvgoxFepBQ2C commented 5 years ago

Ok, for me its working now via the native API, sometimes just home assistant shows "unavailable" or old timestamps, even when the graph is displayed with actual and new data somehow.

OrangeTang16 commented 5 years ago

Is this still an issue you are experiencing? Can you please try upgrading to the latest version of Home Assistant (0.90) and report back if this is still a problem? Thanks!

stale[bot] commented 5 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.