Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to handle initial 'unknown' value of temperature sensors #45

Open
litinoveweedle opened this issue Nov 22, 2021 · 2 comments
Open
Labels
bug Something isn't working

Comments

@litinoveweedle
Copy link

litinoveweedle commented Nov 22, 2021

When after HA reload values of linked sensors are not yet known, integrations is not able to handle this situation correctly and raise error as bellow.

Proposal: correct input sanitation shall be implemented to only update integration temperature if:

is_number(states(sensors.given_sensor))

Logger: custom_components.programmable_thermostat.climate
Source: custom_components/programmable_thermostat/climate.py:526
Integration: Programmable Thermostat (documentation)
First occurred: 9:00:15 PM (2 occurrences)
Last logged: 9:00:16 PM

climate.Heating TO1 - Unable to update current temperature from sensor: could not convert string to float: ''
climate.Heating TO2 - Unable to update current temperature from sensor: could not convert string to float: ''
Logger: homeassistant
Source: custom_components/programmable_thermostat/climate.py:340
Integration: Programmable Thermostat (documentation)
First occurred: 11:38:09 PM (2 occurrences)
Last logged: 11:38:09 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/programmable_thermostat/climate.py", line 340, in _async_target_changed
    self._restore_temp = float(new_state.state)
ValueError: could not convert string to float: ''
@MapoDan
Copy link
Collaborator

MapoDan commented Dec 20, 2021

Ciao,

this is strange..
The software is managing it with a function that a guy added to the code that is _getStateSafe
What I see is that the value received is not 'unknown' or 'unavailable', but an empty string.

If you have an idea how to fix this, feel free to send a pull request. Otherwise I'll have a look when I have time, but in this moment I'm pretty busy on some personal topics

Daniele

@MapoDan MapoDan added the bug Something isn't working label Dec 20, 2021
@litinoveweedle
Copy link
Author

Hello,
it actually depends on the way, how given sensor is updated. Previously I have no checks in my sensor REST API templating, so if sensor device was not yet ready templating returned error on conversion to float and sensors had value of string 'Unknown' To avoid that, I updated template of the sensors, to update only if device value is number / float:

value_template: "{{ value_json.Data.Value | int if 'Data' in value_json and 'Value' in value_json.Data and is_number(value_json.Data.Value)}}"

But now if sensor device is not yet ready, sensor is updated with empty string - as you correctly observed.

The issue in both cases is, that there is no way, how I can postpone thermostat init to wait until linked sensors is initialized with some meaningful value and therefore without triggering described problem. Maybe there could/should be defined/documented sensor initial value (probably undefined / None), which thermostat integration silently process as 'wait for init' without triggering error.

There is same issue reported even for native thermostat integration: home-assistant/core#22535

If you have any other idea how to get rid of these errors...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants