mathieu-mp / homeassistant-intex-spa

Home Assistant integration for Intex Spa
https://github.com/mathieu-mp/homeassistant-intex-spa
MIT License
32 stars 6 forks source link

AttributeError on custom:scheduler-component service call #26

Closed mathieu-mp closed 2 years ago

mathieu-mp commented 2 years ago
2022-07-23 10:30:00 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall climate.set_temperature (c:01G8N2TYT5VTMK3THDB0CTH260): hvac_mode=heat, temperature=33.0, entity_id=['climate.spa']>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1731, in catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 680, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 930, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 717, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 588, in async_service_temperature_set
await entity.async_set_temperature(**kwargs)
File "/config/custom_components/intex_spa/climate.py", line 108, in async_set_temperature
self.coordinator.async_set_updated_data(status)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 304, in async_set_updated_data
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 110, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 339, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 532, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 566, in _async_write_ha_state
attr = self.capability_attributes
File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 239, in capability_attributes
self.hass, self.min_temp, self.temperature_unit, self.precision
File "/config/custom_components/intex_spa/climate.py", line 85, in min_temp
if self.temperature_unit == TEMP_CELSIUS:
File "/config/custom_components/intex_spa/climate.py", line 72, in temperature_unit
if self.coordinator.data.unit == "°C":
AttributeError: 'NoneType' object has no attribute 'unit'
2022-07-23 10:30:05 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall climate.set_hvac_mode (c:01G8N2V3PF9JS2ETVH8R4VCSY1): hvac_mode=heat, entity_id=['climate.spa']>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1731, in catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 644, in entity_service_call
if not entity.available:
File "/config/custom_components/intex_spa/entity.py", line 48, in available
elif self.coordinator.data.error_code is False:
AttributeError: 'NoneType' object has no attribute 'error_code'
mathieu-mp commented 2 years ago

I assume is it linked to parallel updates of status at integration level

mathieu-mp commented 2 years ago

Solved by #27

mathieu-mp commented 2 years ago

This issue persists

Elkropac commented 2 years ago

Happened to me today on version 0.1.1. Also on climate entity. I wasn't doing anything special, just moving the preset temperature, to get current_temp update. The error was there for several updates of preset_temp and then it went away and it worked again without problem

Elkropac commented 2 years ago

I was running tshark today and when this exception started to pop up, there were no packets being sent to device at all

hevili commented 2 years ago

same problem... update from commit 2b69d0c to larest release... before the update it worked perfectly!

mathieu-mp commented 2 years ago

OK, thank you for your feedback. I'll work on it. Compare changes on homeassistant-intex-spa: https://github.com/mathieu-mp/homeassistant-intex-spa/compare/2b69d0c...0.1.1 Compare changes on intex-spa: https://github.com/mathieu-mp/intex-spa/compare/0.7.2...0.8.2

Elkropac commented 2 years ago

I tried to drop/discard packets from hassio to spa silently, but it works ok, spa becomes unavailable. It does not hang like in this issue

Elkropac commented 2 years ago

I got response with "result" = "timeout", never saw it before. Low level library seems to work ok, it tries again

$ python3 intex_spa_get_status.py 
DEBUG:asyncio:Using selector: EpollSelector
WARNING:intex_spa.intex_spa:Initializing IntexSpa instance
DEBUG:intex_spa.intex_spa:'status' intent: Handling new intent...
DEBUG:intex_spa.intex_spa:'status' intent: a spa query is needed
DEBUG:intex_spa.intex_spa:'status' intent: new spa query
INFO:intex_spa.intex_spa_network_layer:Not connected to the spa
DEBUG:intex_spa.intex_spa_network_layer:Opening TCP connection with the spa at 192.168.23.123:8990 with asyncio
INFO:intex_spa.intex_spa_network_layer:TCP connection established with the spa
DEBUG:intex_spa.intex_spa_network_layer:Sending bytes to the spa: b'{"data": "8888060FEE0F01DA", "sid": "16593429608232", "type": 1}'
DEBUG:intex_spa.intex_spa_network_layer:Receiving bytes from the spa: b'{"sid":"16593429608232","data":"","result":"timeout","type":2}\n'
WARNING:intex_spa.intex_spa:Exception raised during spa querying
DEBUG:intex_spa.intex_spa:'status' intent: new spa query
DEBUG:intex_spa.intex_spa_network_layer:Sending bytes to the spa: b'{"data": "8888060FEE0F01DA", "sid": "16593429671316", "type": 1}'
DEBUG:intex_spa.intex_spa_network_layer:Receiving bytes from the spa: b'{"sid":"16593429671316","data":"FFFF110F010300170000000081808020000022","result":"ok","type":2}\n'
DEBUG:intex_spa.intex_spa_status:Spa status: '{'power': True, 'filter': True, 'heater': False, 'jets': False, 'bubbles': False, 'sanitizer': False, 'unit': '°C', 'current_temp': 23, 'preset_temp': 32}'
DEBUG:intex_spa.intex_spa:'status' intent: new status is rendered
{'power': True, 'filter': True, 'heater': False, 'jets': False, 'bubbles': False, 'sanitizer': False, 'unit': '°C', 'current_temp': 23, 'preset_temp': 32}
Elkropac commented 2 years ago

Maybe , you should check, that "result" = "ok", before trying to work with data?

mathieu-mp commented 2 years ago

Maybe , you should check, that "result" = "ok", before trying to work with data?

Well, this assert raises an AssertionError exception which triggers a retry.

This is the same retry you saw on your previous message:

I got response with "result" = "timeout", never saw it before. Low level library seems to work ok, it tries again

Thank you all for your feedbacks ! I still haven't found the time to solve this (and while I didn't spend much time on it, I still have no clue).

Elkropac commented 2 years ago

Maybe , you should check, that "result" = "ok", before trying to work with data?

Well, this assert raises an AssertionError exception which triggers a retry.

Makes sense, i should really learn something about this stuff (assert, try ,catch ... ), thanks for explanation

This is the same retry you saw on your previous message:

I got response with "result" = "timeout", never saw it before. Low level library seems to work ok, it tries again

Yeah, i noticed the retry in test code and thought it does not propagate up to home assistant integration code, but it does not make sense

Thank you all for your feedbacks ! I still haven't found the time to solve this (and while I didn't spend much time on it, I still have no clue).

You are welcome, it must be something stuck somewhere ;)