kongo09/philips-airpurifier-coap

The status of the device does not change

Closed this issue · 11 comments

After updating v0.10.7, the problem returned, the status of the device a HA does not change.
For example: I turn off the light. Everything turns off on the device, but in HA the status is ON. In version 0.10.6, there was such a problem after rebooting ON. But after 180 seconds there was a reconnection and after that everything worked correctly

Can you please downgrade and see if the problem disappears?

I worry that this is the connectivity problem and that it's just bad luck when it happens, not matter which version you are using.

@kongo09
0.10.6 works but incorrectly. After restarting HA, I try to turn on the light. The light turns on but the status is off. After 180s, reconnection occurs and the status becomes correct (video 3:40) After that there are no problems. The connection is no longer lost. The problem is only after restarting HA
home-assistant_0.10.7.log
home-assistant_0.10.6.log
https://user-images.githubusercontent.com/86417742/168566404-ee635f26-a8af-426f-ba97-dc62dab7d321.mp4

I'm not really convinced that the two versions make a difference here. The changes from v0.10.6 to v0.10.7 are minor and shouldn't affect turning on the light at all. My hypothesis is that this is coincidence and you might as well get it running with v0.10.7 and not running with v0.10.6. Maybe you try a few times with both versions and let me know if I'm right or not.

In the end, this might lead to the well-known connectivity problem, for which we don't really have a solution so far.

0.10.7 has been installed for several hours. And it didn't work.
0.10.6 does not work only the first 180s after restarting HA. There is a message in the log. After it, everything works correctly
2022-05-18 13:06:36 DEBUG (MainThread) [custom_components.philips_airpurifier_coap.timer] Starting Timer 180s.
2022-05-18 13:06:36 DEBUG (MainThread) [custom_components.philips_airpurifier_coap.philips] Reconnecting

Next following "Starting Time 180s." does not result in Reconnecting.
Log for several days. Reconnecting only after restarting HA.
home-assistant.zip
It turns out that a mandatory reconnection is required after the restart HA
You have added a new condition "RuntimeError", perhaps because of it, reconnection does not occur
I will set 0.10.7 for a longer period and analyze the logs.

If you can propose a pull request to fix it, I would be more than grateful

@kongo09
I can't run the project in IntelliJ IDEA :( At startup, I installed the aioairctrl and homeassistant packages. Is there anything else required to run? Can you tell me what the problem is?

`C:\Users\pxuxmxa\AppData\Local\Programs\Python\Python38\python.exe C:\Users\pxuxmxa\AppData\Roaming\JetBrains\IdeaIC2022.1\plugins\python-ce\helpers\pydev\pydevd.py --cmd-line --multiprocess --qt-support=auto --client 127.0.0.1 --port 52832 --file D:/Distrib/Instal/git/philips-airpurifier-coap/philips-airpurifier-coap/custom_components/philips_airpurifier_coap/init.py
Traceback (most recent call last):
File "C:\Users\pxuxmxa\AppData\Roaming\JetBrains\IdeaIC2022.1\plugins\python-ce\helpers\pydev\pydevd.py", line 16, in
from _pydevd_bundle.pydevd_collect_try_except_info import collect_return_info
File "C:\Users\pxuxmxa\AppData\Roaming\JetBrains\IdeaIC2022.1\plugins\python-ce\helpers\pydev_pydevd_bundle\pydevd_collect_try_except_info.py", line 12, in
from _pydevd_bundle.pydevd_constants import IS_PY38_OR_GREATER
File "C:\Users\pxuxmxa\AppData\Roaming\JetBrains\IdeaIC2022.1\plugins\python-ce\helpers\pydev_pydevd_bundle\pydevd_constants.py", line 222, in
from _pydev_imps.pydev_saved_modules import thread
File "C:\Users\pxuxmxa\AppData\Roaming\JetBrains\IdeaIC2022.1\plugins\python-ce\helpers\pydev_pydev_imps_pydev_saved_modules.py", line 8, in
import socket
File "C:\Users\pxuxmxa\AppData\Local\Programs\Python\Python38\lib\socket.py", line 52, in
import os, sys, io, selectors
File "C:\Users\pxuxmxa\AppData\Local\Programs\Python\Python38\lib\selectors.py", line 12, in
import select
File "D:\Distrib\Instal\git\philips-airpurifier-coap\philips-airpurifier-coap\custom_components\philips_airpurifier_coap\select.py", line 9, in
from homeassistant.components.select import SelectEntity
File "C:\Users\pxuxmxa\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\components_init
.py", line 14, in
from homeassistant.core import HomeAssistant, split_entity_id
File "C:\Users\pxuxmxa\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\core.py", line 28, in
from homeassistant import async_timeout_backcompat, block_async_io, loader, util
File "C:\Users\pxuxmxa\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\block_async_io.py", line 2, in
from http.client import HTTPConnection
File "C:\Users\pxuxmxa\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 768, in
class HTTPConnection:
File "C:\Users\pxuxmxa\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 816, in HTTPConnection
def init(self, host, port=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
AttributeError: partially initialized module 'socket' has no attribute '_GLOBAL_DEFAULT_TIMEOUT' (most likely due to a circular import)

Process finished with exit code 1`

@mhetzi
Due to the addition of the condition, the device status stopped being displayed correctly for me. Previously, 180c after the HA reboot, the status was displayed correctly. Now even after 180 the status is incorrect. Need help :) If the condition is removed, everything will work again

            except RuntimeError:
                try:
                    #Ensure that the runtime error, is because hass is going down!
                    asyncio.get_running_loop()
                except RuntimeError:
                    #Yes seems like hass is going down, stepping out
                    _LOGGER.warning("RuntimeError! Stopping Timer...")
                    self._auto_restart = False
                    self._task = None
                    return

@pxuxmxa could you test this. Sorry didnt notice this error. Device is mostly in standby when its warm outside.

@mhetzi
The problem that the first 180c statuses do not change, remains. But after that everything works correctly. It suits me as it is. Thank you:)

Thanks, I'll merge it later then

v0.10.8 released. I'll close this then, ok?