dolezsa / thermal_comfort

Thermal Comfort sensor for HA (absolute humidity, heat index, dew point, thermal perception)
Other
610 stars 117 forks source link

Lovelace stuck on "Loading data" #19

Closed giu889 closed 2 years ago

giu889 commented 3 years ago

Today after a restart, Lovelace became stuck on the "Loading data" screen and was totally unusable. Deleting the integration from the custom_components folder using smb fixed the issue.

The issue seems to be related to the value of the temperature_sensor and humidity_sensor being nan.

This is the error found in home-assistant.log (repeating itself every 10 to 40 seconds):

2021-10-02 10:30:24 ERROR (MainThread) [homeassistant.components.websocket_api.messages] Unable to serialize to JSON. Bad data found at $.result[21](State: sensor.livingroom_absolutehumidity).attributes.temperature=nan(<class 'float'>, $.result[21](State: sensor.livingroom_absolutehumidity).attributes.humidity=nan(<class 'float'>, $.result[22](State: sensor.livingroom_heatindex).attributes.temperature=nan(<class 'float'>, $.result[22](State: sensor.livingroom_heatindex).attributes.humidity=nan(<class 'float'>, $.result[23](State: sensor.livingroom_dewpoint).attributes.temperature=nan(<class 'float'>, $.result[23](State: sensor.livingroom_dewpoint).attributes.humidity=nan(<class 'float'>, $.result[24](State: sensor.livingroom_perception).attributes.temperature=nan(<class 'float'>, $.result[24](State: sensor.livingroom_perception).attributes.humidity=nan(<class 'float'>

My config:

- platform: thermal_comfort
  sensors:
    livingroom:
      friendly_name: Thermal Comfort Bad DG
      temperature_sensor: sensor.dht_1_temp
      humidity_sensor: sensor.dht_1_hum
rautesamtr commented 2 years ago

I can reproduce the error with the following:

sensors:
  - platform: command_line
    name: Zero Temperature
    command: "echo 0"
    unit_of_measurement: "°C"
    value_template: "{{ 'NaN' | float }}"
  - platform: command_line
    name: Zero Humidity
    command: "echo 0"
    unit_of_measurement: "%"
    value_template: "{{ 'NaN' | float }}"
  - platform: thermal_comfort
    sensors:
      command:
        friendly_name: Command Room
        temperature_sensor: sensor.zero_temperature
        humidity_sensor: sensor.zero_humidity

That being said, a sensor implementation should never return NaN to begin with, and you should probably also report a bug in your sensor integration.