custom-components / climate.programmable_thermostat

Programmable thermostat that let you have a smart thermostat on budget.
The Unlicense
115 stars 35 forks source link

Component doesn't start #8

Closed mezzagianni closed 4 years ago

mezzagianni commented 4 years ago

Home assistant ver. 0.101.3 Programmable Thermostat ver. 4.1 Configuration.yaml climate:

State "input_boolean.sala_heater1" = off State "input_number.trv1_set_temp" = 13.0

Error at HA startup: 2019-11-18 21:30:42 ERROR (MainThread) [homeassistant.components.climate] Error while setting up platform programmable_thermostat Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for return fut.result() File "/config/custom_components/programmable_thermostat/climate.py", line 76, in async_setup_platform max_temp, target_entity_id, tolerance, initial_hvac_mode, unit, related_climate)]) File "/config/custom_components/programmable_thermostat/climate.py", line 99, in init self._target_temp = float(hass.states.get(target_entity_id).state) AttributeError: 'NoneType' object has no attribute 'state'

Loaded the programmable_thermostat component in my custom_component folder using HACS.

Using the component "generic thermostat" with the same "target_temp_sensor" and "actual_temp_sensor" entities doesn't return error.

MapoDan commented 4 years ago

Ciao,

Unlikely I tried to built the same error as your, but no way to replicate it. It seems something related to platforms setup. Maybe your config is setting up first the climate then the input boolean.

What is sounding strange to me is the Generic Thermostat part. That integration doesn't accept an entity id as target temp.

Can you give me more details?

One more thing. Using a slider as target temp sensor is not useful since the thermostat entity (even the generic one) give you a slider to change the target temp.

Let me know

jumate commented 4 years ago

Same error as user mezzagianni

2019-12-06 19:08:42 ERROR (MainThread) [homeassistant.components.climate] Error while setting up platform Traceback (most recent call last): File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) File "/usr/lib/python3.7/asyncio/tasks.py", line 416, in wait_for return fut.result() File "/home/homeassistant/.homeassistant/custom_components/programmable_thermostat/climate.py", line 76, in async_setup_platform max_temp, target_entity_id, tolerance, initial_hvac_mode, unit, related_climate)]) File "/home/homeassistant/.homeassistant/custom_components/programmable_thermostat/climate.py", line 102, in init if hass.states.get(sensor_entity_id).state != STATE_UNKNOWN: AttributeError: 'NoneType' object has no attribute 'state'

Home Assistant 0.102.3

Configuration.yaml:

climate:

Content file: fichero.txt 19.0,19.0,19.0,19.0,19.0,19.0,19.0

MapoDan commented 4 years ago

Ciao Jumate, What is returning your sensor.target_temperature? It seems that it doesn't exist or something... Can you provide some info on that and what it is returned in the state table for that entity?

jumate commented 4 years ago

Hi

You're right, I had not given any real sensor value on that parameter. I have already configured it and everything ok.

Thank you.

mezzagianni commented 4 years ago

Ciao,

Unlikely I tried to built the same error as your, but no way to replicate it. It seems something related to platforms setup. Maybe your config is setting up first the climate then the input boolean.

In order to verify your hypothesis I created a file climate.yaml and included it at the end of the configuration file, but the problem remains the same.

What is sounding strange to me is the Generic Thermostat part. That integration doesn't accept an entity id as target temp.

Are you sure? The official page of the component https://www.home-assistant.io/integrations/generic_thermostat/ says:

_target_sensor (string)(Required) entity_id for a temperature sensor, targetsensor.state must be temperature.

Can you give me more details?

when updated home-assistant from 0.101.3 to 0.102.1 the problem seemed to be solved, then it was reappeared when updated home-assitant to 0.102.3

One more thing. Using a slider as target temp sensor is not useful since the thermostat entity (even the generic one) give you a slider to change the target temp.

I used an "input_number" as a variable to save a value that could be easily modified with a slider from the front-end.

Let me know

that's all...

bye

mezzagianni commented 4 years ago

I noticed something that could help you understand the problem.

The first time you restart after an HA version upgrade the "Programmable Thermostat" component is loaded without errors, then the subsequent HA restarts the "Programmable Thermostat" component is no longer loaded and reports an error.

Could it be a race condition in the component initialization procedure?

MapoDan commented 4 years ago

Ciao mezzagianni,

to be honest I don't have any clue since I'm not able to reproduce the error. I think that there is something strange in your config that cause the error. I'm using this to control heating system in my house and my brother's one and never had this kind of issue and I have restarted many times without updating anything..

Can you please provide the state screen of the table in developer-tools/state for both sensor.sala_temp1_173 and input_number.trv1_set_temp? Of course of a run in which you get the error of the component. What kind of sensor integration is it?

About that:

Are you sure? The official page of the component https://www.home-assistant.io/integrations/generic_thermostat/ says: target_sensor (string)(Required) entity_id for a temperature sensor, target_sensor.state must be temperature.

Is I'm sure, for target is accept the entity, but I was referring to target_temp. Anyway, that's not important. we have to solve the issue :)

mezzagianni commented 4 years ago

Ciao mezzagianni,

Ciao

to be honest I don't have any clue since I'm not able to reproduce the error.

Sigh!

I think that there is something strange in your config that cause the error. I'm using this to control heating system in my house and my brother's one and never had this kind of issue and I have restarted many times without updating anything..

Can you please provide the state screen of the table in developer-tools/state for both sensor.sala_temp1_173 and input_number.trv1_set_temp? Of course of a run in which you get the error of the component. What kind of sensor integration is it?

In order to minimize my mistakes I used your "file_restore" component to set "target_temp_sensor" and I used a Neo CoolCam Z-wave motion and temperature sensor to set "actual_temp_sensor", but without success.

This is my actual configuration:

I have attached the screenshots of "target_temp_sensor", "actual_temp_sensor" and "heater" from DevOp/States page: https://drive.google.com/file/d/1R5uPW2uc8KQbJ_v_gvNWL_SAs-Mbl2z8/view?usp=sharing https://drive.google.com/file/d/19iM83wD-lvFRJXViF_tQVaYscGUyMnSP/view?usp=sharing https://drive.google.com/file/d/1Dz4AX37JN16LgkENCwR3gO5d64o5UZf1/view?usp=sharing

About that:

Are you sure? The official page of the component https://www.home-assistant.io/integrations/generic_thermostat/ says: target_sensor (string)(Required) entity_id for a temperature sensor, target_sensor.state must be temperature.

Is I'm sure, for target is accept the entity, but I was referring to target_temp. Anyway, that's not important. we have to solve the issue :)

ok, never mind...

Meanwhile ... Best wishes for New Years.

tubededentifrice commented 4 years ago

I think some of those issues are caused because upon startup some entities might be initialized AFTER the programmable_thermostat and thus return unknown (or None?). I'll do a PR soon I think (for https://github.com/custom-components/climate.programmable_thermostat/issues/4 actually, but might solve this one as well).

MapoDan commented 4 years ago

Thanks to the big support of tubededentifrice, the issue has been fixed. Now the component will always start even if the sensor is not existing or lately initialised.

I'll close this thread by end of January if no one reports similar issues.

mezzagianni commented 4 years ago

Thanks to the big support of tubededentifrice, the issue has been fixed. Now the component will always start even if the sensor is not existing or lately initialised.

I'll close this thread by end of January if no one reports similar issues.

The original problem seems to be solved, the component ver. 4.2 now starts, but i get this error:

2020-01-06 16:50:47 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback EventBus.async_listen_once..onetime_listener(<Event homeassistant_start[L]>) at /usr/src/homeassistant/homeassistant/core.py:650 Traceback (most recent call last): File "/usr/local/lib/python3.7/asyncio/events.py", line 88, in _run self._context.run(self._callback, self._args) File "/usr/src/homeassistant/homeassistant/core.py", line 662, in onetime_listener self._hass.async_run_job(listener, event) File "/usr/src/homeassistant/homeassistant/core.py", line 370, in async_run_job target(args) File "/config/custom_components/programmable_thermostat/climate.py", line 154, in _async_startup self._async_update_program_temp(target_state) File "/config/custom_components/programmable_thermostat/climate.py", line 408, in _async_update_program_temp self._target_temp = float(state.state) AttributeError: 'str' object has no attribute 'state'

I state that I don't know python, but the error seems to say that the function "_async_update_program_temp" at line 405 receives a string and not an object so line 408 must be corrected in this way:

408c408
<             self._target_temp = float(state.state)
---
>             self._target_temp = float(state)

I hope I haven't said bullshit =:-))

bye

tubededentifrice commented 4 years ago

@mezzagianni You're right, I can't believe I forgot to commit that and only fixed it locally. I'll fix it ASAP. Sorry about this.

tubededentifrice commented 4 years ago

PR at https://github.com/custom-components/climate.programmable_thermostat/pull/12

MapoDan commented 4 years ago

PR merged.