qqaatw / JciHitachiHA

A home assistant integration for controlling Jci-Hitachi devices, using LibJciHitachi backend. 台灣日立雲端模組
Apache License 2.0
118 stars 33 forks source link

冷氣控制會不定時失效,需要重啟HA才能恢復正常 #89

Open edison72 opened 5 days ago

edison72 commented 5 days ago

🐛 Describe the bug

冷氣控制會不定時失效,第一次發生在8月28日,第二次發生於9月20日,當失效時,點擊HA控制面板改變溫度會產生下列錯誤訊息: 執行觸發動作climate/set_temperature失敗。 'NoneType' object has no attribute 'expiration'

重啟HA後恢復正常連線。

Log files:

2024-09-20 00:29:12.073 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139983014449872] Unexpected exception Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 951, in async_service_temperature_set await entity.async_set_temperature(*kwargs) File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 726, in async_set_temperature await self.hass.async_add_executor_job( File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/jcihitachi_tw/climate.py", line 421, in set_temperature self.update() File "/config/custom_components/jcihitachi_tw/init.py", line 232, in update result = api.set_status(vars(data)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/JciHitachi/api.py", line 1293, in set_status self._check_before_publish() File "/usr/local/lib/python3.12/site-packages/JciHitachi/api.py", line 953, in _check_before_publish if self._aws_tokens.expiration - current_time <= 300: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'expiration'

home-assistant error.log home-assistant_jcihitachi_tw_2024-09-19T16-52-13.034Z.log

Environment Information

HA version = 2024.8.2 JciHitachi TW = 1.8.0

qqaatw commented 3 days ago

I think there might be a race condition between api.login and api.set_status. The upper part of the error log was truncated so I couldn't know what was going on. I would say if you're using any automation with your Hitachi devices, disable it for a few days and see if the issue is gone.

This bug started emerging a few months ago due to some internal changes in recent HA core updates. We would accept a PR that fixes it.