Closed mathieu-mp closed 2 years ago
is this related?
2022-06-20 17:17:39 ERROR (MainThread) [custom_components.intex_spa] Error fetching intex_spa data:
2022-06-20 17:18:09 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall switch.turn_on (c:01G611X014FMMB0MVRR50BTW7K): entity_id=['switch.spa_power']>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1722, in catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1741, 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 964, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 717, in _handle_entity_call
await result
File "/config/custom_components/intex_spa/switch.py", line 86, in async_turn_on
status = await self.coordinator.api.async_set(self._switch_type, True)
File "/usr/local/lib/python3.9/site-packages/intex_spa/intex_spa.py", line 152, in async_set
return await self._async_handle_intent(parameter, expected_state)
File "/usr/local/lib/python3.9/site-packages/intex_spa/intex_spa.py", line 83, in _async_handle_intent
await self.async_update_status()
File "/usr/local/lib/python3.9/site-packages/intex_spa/intex_spa.py", line 139, in async_update_status
return await self._async_handle_intent("status")
File "/usr/local/lib/python3.9/site-packages/intex_spa/intex_spa.py", line 106, in _async_handle_intent
query.render_response_status(received_bytes)
File "/usr/local/lib/python3.9/site-packages/intex_spa/intex_spa_query.py", line 87, in render_response_status
response = json.loads(received_bytes.decode())
File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I added firewall rule between my dev host and SPA. Then switched the power switch. First line of log pops up almost instatly, exception shows after 30s timeout. My firewall is set to REJECT packets, not to DROP
I was trying to figure out, what is returned in status
, when you cannot connect to SPA and if it needs to be handled in some update method instead of blindly updating status of coordinator data
I was more expecting something like disconnecting the spa between two status checks and let the magic happen ! ;-)
But your test is interesting so I created an issue from your log in the python package repo
I have clicked it again
2022-06-20 17:39:39 INFO (MainThread) [custom_components.intex_spa] Fetching intex_spa data recovered
2022-06-20 17:40:09 ERROR (MainThread) [custom_components.intex_spa] Error fetching intex_spa data:
2022-06-20 17:40:39 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall switch.turn_on (c:01G61360VPWFZEF2ZTFYRWFVWD): entity_id=['switch.spa_power']>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1722, in catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1741, 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 964, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 717, in _handle_entity_call
await result
File "/config/custom_components/intex_spa/switch.py", line 86, in async_turn_on
status = await self.coordinator.api.async_set(self._switch_type, True)
File "/usr/local/lib/python3.9/site-packages/intex_spa/intex_spa.py", line 152, in async_set
return await self._async_handle_intent(parameter, expected_state)
File "/usr/local/lib/python3.9/site-packages/intex_spa/intex_spa.py", line 83, in _async_handle_intent
await self.async_update_status()
File "/usr/local/lib/python3.9/site-packages/intex_spa/intex_spa.py", line 139, in async_update_status
return await self._async_handle_intent("status")
File "/usr/local/lib/python3.9/site-packages/intex_spa/intex_spa.py", line 106, in _async_handle_intent
query.render_response_status(received_bytes)
File "/usr/local/lib/python3.9/site-packages/intex_spa/intex_spa_query.py", line 87, in render_response_status
response = json.loads(received_bytes.decode())
File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-06-20 17:41:09 INFO (MainThread) [intex_spa.intex_spa_network_layer] Connection with the spa seems to be broken
2022-06-20 17:41:09 INFO (MainThread) [intex_spa.intex_spa_network_layer] TCP connection closed with the spa
I have clicked it again
- disable firewall (allow communication)
- 17:39:39 - update number 1 it found out it can communicate again
- enabled firewall
- around 17:39:50 - clicked on power switch
- 17:40:09 - update number 2 found out, it cannot communicate with spa
- 17:40:39 - exception from somewhere in homeassistant
- 17:41:09 - information from intex_spa class about not being able to communicate
Does it mean it that the entities became gray and unavailable, then back to available state and showing the actual state ?
At 17:39:39, entities were available. Few seconds after clicking switch, all became unavailable, but without the red exclamation mark in entities list
Should i test it with new commits you made? My spa dropped from wifi, so i will have to pair it again, which means i have to disable 5GHz wifi on my APs, so my phone stays on 2.4GHz
Yes, please test it again as I have added the availabilty property. But I didn't catch the JSONDecodeError yet.
I refactored the exceptions handling between intex_spa python package and home assistant integration and tested all planned combinations. Also, I catch a generic Exception, just in case anything unexpected happens.
It should do the job !
It should do the job, don't hesitate to reopen if needed
Verify unavailability behavior: