custom-components / climate.programmable_thermostat

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

Version 7.0 error when trying to start heating #26

Closed hugalafutro closed 3 years ago

hugalafutro commented 3 years ago

Updated to 7.0 from hacs, upon restarting HA the component was gone from dashboard, but still present in enabled integrations, in logs it showed Migration handler not found for entry Programmable Thermostat for programmable_thermostat. I deleted the integration, recreated it, but it does not work, when i move the thingy to raise the temperature, once it gets to the point where it should raise the temp it throws this error in logs:

Logger: homeassistant.components.websocket_api.http.connection.4026573128
Source: helpers/condition.py:342
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 12:35:46 (3 occurrences)
Last logged: 12:35:50

unsupported operand type(s) for -: 'datetime.datetime' and 'dict'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 135, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1448, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1483, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 482, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 664, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 519, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 544, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/config/custom_components/programmable_thermostat/climate.py", line 306, in async_set_temperature
    await self.control_system_mode()
  File "/config/custom_components/programmable_thermostat/climate.py", line 223, in control_system_mode
    await self._async_control_thermo(mode="heat")
  File "/config/custom_components/programmable_thermostat/climate.py", line 369, in _async_control_thermo
    await self._async_turn_on(mode=mode)
  File "/config/custom_components/programmable_thermostat/climate.py", line 258, in _async_turn_on
    if not self._is_device_active_function(forced=False) and self.is_active_long_enough(mode=mode):
  File "/config/custom_components/programmable_thermostat/climate.py", line 485, in is_active_long_enough
    return condition.state(self.hass, entity, current_state, self.min_cycle_duration)
  File "/usr/src/homeassistant/homeassistant/helpers/condition.py", line 342, in state
    return dt_util.utcnow() - for_period > entity.last_changed
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'dict'

Downgrading to 6.4 and recreating the integration works again.

johanolde commented 3 years ago

I have the same error message. Not sure if it turned up when upgrading to 7.0 or 118, but I have the same error message.

I downgraded to 6.4 and restarted, no other changes, and it seems to work fine again!

MapoDan commented 3 years ago

Ciao guys, Can you please provide the configuration you are using for this integration? If you are using the config_flow let me know and please give me the parameter you have set.

I tested it, but I'm not able to replicate the issue..

Thanks

hugalafutro commented 3 years ago

I only ever used the configuration flow. Currently on HA 0.118.1 running in docker on raspberry pi 4.

relevant section output from cat docker/homeassistant/data/.storage/core.config_entries

{ "entry_id": "17186409108d46b91f20c9d6e3a81009", "version": 1, "domain": "programmable_thermostat", "title": "Programmable Thermostat", "data": { "unique_id": "b2a3bca4-4370-4f4b-a20e-9460b4d23ce9", "name": "Programmable Thermostat", "heater": [ "switch.plug_samsung_heater_switch" ], "actual_temp_sensor": "sensor.bedroom_temp", "target_temp_sensor": "input_number.planned_temperature", "max_temp": 25, "min_temp": 10, "tolerance": 0.2, "hvac_options": 7, "auto_mode": "all", "initial_hvac_mode": "heat" }, "options": {}, "system_options": { "disable_new_entities": false }, "source": "user", "connection_class": "local_poll", "unique_id": null }

Not at home atm, when reporting the issue I was on HA 0.118, currently on 0.118.1, will try if it was HA related when I get home. edit: just noticed HA 0.118.2 is available as well

johanolde commented 3 years ago

Upgraded to 0.118.2 everything was working fine with 6.4, then I upgraded to 7.0 and integration broke again. Downgraded to 6.4, restarted, all good.

Config: "entry_id": "ef2b7262274f4d67b48cd2cd2536dca6", "version": 1, "domain": "programmable_thermostat", "title": "Sommarsovrum MkII", "data": { "actual_temp_sensor": "sensor.temperature_38", "auto_mode": "all", "heater": [ "switch.golvvarme_sommarsovrum" ], "hvac_options": 7, "max_temp": 23, "min_temp": 12, "name": "Sommarsovrum MkII", "target_temp_sensor": "input_number.termostat_sommarsovrum", "tolerance": 0.5, "unique_id": "895214f0-178a-47d6-a0e6-77eda97fdf07" }, "options": {}, "system_options": { "disable_new_entities": false }, "source": "user", "connection_class": "local_poll", "unique_id": null }, { "entry_id": "48df746c6c474defbf1a3c56eb4bb1fa", "version": 1, "domain": "programmable_thermostat", "title": "hall MkII", "data": { "actual_temp_sensor": "sensor.aeon_labs_zw074_multisensor_gen5_temperature_2", "auto_mode": "all", "heater": [ "switch.golvvarme_hall" ], "hvac_options": 7, "max_temp": 23, "min_temp": 12, "name": "hall MkII", "target_temp_sensor": "input_number.termostat_hall_nere", "tolerance": 0.5, "unique_id": "2e5ec39c-c7c6-4fa9-8a46-de7485edd1f5" }, "options": {}, "system_options": { "disable_new_entities": false }, "source": "user", "connection_class": "local_poll", "unique_id": null }, { "entry_id": "79c6184841a143b7bb9dde5aef466362", "version": 1, "domain": "programmable_thermostat", "title": "Toalett Nere MkII", "data": { "actual_temp_sensor": "sensor.temperature_27", "auto_mode": "all", "heater": [ "switch.golvvarme_toalett_nere" ], "hvac_options": 7, "max_temp": 23, "min_temp": 12, "name": "Toalett Nere MkII", "target_temp_sensor": "input_number.termostat_toalett_nere", "tolerance": 0.5, "unique_id": "97993234-9d2c-4b43-b9d8-9db8a0bc8e10" }, "options": {}, "system_options": { "disable_new_entities": false }, "source": "user", "connection_class": "local_poll", "unique_id": null },

MapoDan commented 3 years ago

Issue should be solved with version 7.1. Let me know if it is the same for you so I can close the issue.

hugalafutro commented 3 years ago

Hi, the migration still fails with Migration handler not found for entry Programmable Thermostat for programmable_thermostat and the integration is broken after updating, needs to be deleted and recreated again, however after recreating it via config flow again 7.1 works as expected. Thanks for the fix!