appdaemon icon indicating copy to clipboard operation
appdaemon copied to clipboard

AppDaemon crashes, HASS plugin failed

Open collateral87 opened this issue 7 months ago • 46 comments

What happened?

Hi, i run AD addon 0.17.2 on homeassistant 2025.5.3.

My logs are flooded with errors:

2025-06-01 01:45:13.540741 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:45:13.541223 INFO HASS: Completed initialization in 5.0s 2025-06-01 01:45:13.542517 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-01 01:45:13.542687 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-01 01:45:13.543673 INFO AppDaemon: Calling initialize() for hello_world 2025-06-01 01:45:13.544187 INFO hello_world: Hello from AppDaemon 2025-06-01 01:45:13.544395 INFO hello_world: You are now ready to run Apps! 2025-06-01 01:45:13.608743 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-01 01:45:13.609084 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-01 01:45:13.609454 INFO HASS: Waiting for Home Assistant to start 2025-06-01 01:45:13.657350 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-01 01:45:13.658828 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-01 01:45:13.658957 INFO AppDaemon: Stopping apps: {'hello_world'} s6-rc: info: service legacy-services: stopping s6-rc: info: service legacy-services successfully stopped s6-rc: info: service appdaemon: stopping 2025-06-01 01:45:17.832299 INFO AppDaemon: SIGTERM Received 2025-06-01 01:45:17.832431 INFO AppDaemon: AppDaemon is shutting down 2025-06-01 01:45:18.379454 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-01 01:45:18.379948 INFO AppDaemon: Shutting down webserver 2025-06-01 01:45:18.589293 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-01 01:45:18.589559 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:45:18.589613 WARNING HASS: Unexpected error while getting hass state 2025-06-01 01:45:18.589683 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 761, in get_complete_state hass_state = (await self.websocket_send_json(type="get_states"))["result"] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ KeyError: 'result'

and after several tries this follows:

**More logs**

2025-06-01 01:47:29.578070 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:29.603762 INFO HASS: Previous message repeated 1 times 2025-06-01 01:47:29.603835 WARNING HASS: Unexpected error during websocket send 2025-06-01 01:47:29.603875 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 337, in websocket_send_json await self.ws.send_json(request) File "/usr/lib/python3.12/site-packages/aiohttp/client_ws.py", line 261, in send_json await self.send_str(dumps(data), compress=compress) File "/usr/lib/python3.12/site-packages/aiohttp/client_ws.py", line 245, in send_str await self._writer.send_frame( File "/usr/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame raise ClientConnectionResetError("Cannot write to closing transport") aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

2025-06-01 01:47:29.603925 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:29.603975 WARNING HASS: Error getting services - retrying 2025-06-01 01:47:29.604154 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:29.604210 WARNING HASS: Unexpected error while getting hass services 2025-06-01 01:47:29.604268 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 589, in get_hass_services services: dict[str, dict[str, dict]] = (await self.websocket_send_json(type="get_services"))["result"] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ TypeError: 'NoneType' object is not subscriptable

2025-06-01 01:47:29.604318 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:30.022188 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-01 01:47:30.022489 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:30.022540 WARNING HASS: Unexpected error while getting hass state 2025-06-01 01:47:30.022585 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 761, in get_complete_state hass_state = (await self.websocket_send_json(type="get_states"))["result"] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ KeyError: 'result'

2025-06-01 01:47:30.022628 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:30.023111 INFO HASS: Completed initialization in 5.0s 2025-06-01 01:47:30.023983 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-01 01:47:30.024086 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-01 01:47:30.024705 INFO AppDaemon: Calling initialize() for hello_world 2025-06-01 01:47:30.025147 INFO hello_world: Hello from AppDaemon 2025-06-01 01:47:30.025343 INFO hello_world: You are now ready to run Apps! 2025-06-01 01:47:30.091694 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-01 01:47:30.092038 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-01 01:47:30.092370 INFO HASS: Waiting for Home Assistant to start 2025-06-01 01:47:30.110661 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-01 01:47:30.110744 WARNING AppDaemon: Unexpected error during process_event() 2025-06-01 01:47:30.110792 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-01 01:47:30.111068 WARNING AppDaemon: Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/events.py", line 234, in process_event self.AD.state.set_state_simple(namespace, entity_id, data["data"]["new_state"]) File "/usr/lib/python3.12/site-packages/appdaemon/state.py", line 777, in set_state_simple if self.entity_exists(namespace, entity_id): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/state.py", line 473, in entity_exists return namespace in self.state and entity in self.state[namespace] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: argument of type 'NoneType' is not iterable

2025-06-01 01:47:30.111194 WARNING AppDaemon: { "event_type": "state_changed", "data": { "entity_id": "automation.0_5_minute_man", "old_state": { "entity_id": "automation.0_5_minute_man", "state": "on", "attributes": { "id": "1689807491921", "last_triggered": "2025-05-31T23:47:00.105900+00:00", "mode": "single", "current": 0, "icon": "mdi:timer-play-outline", "friendly_name": "0.5-Minute-Man" }, "last_changed": "2025-05-31T22:16:28.992578+00:00", "last_reported": "2025-05-31T23:47:00.106516+00:00", "last_updated": "2025-05-31T23:47:00.106516+00:00", "context": { "id": "01JWMBVPC9M6HFCWH3MKPX83YH", "parent_id": null, "user_id": null } }, "new_state": { "entity_id": "automation.0_5_minute_man", "state": "on", "attributes": { "id": "1689807491921", "last_triggered": "2025-05-31T23:47:30.105885+00:00", "mode": "single", "current": 1, "icon": "mdi:timer-play-outline", "friendly_name": "0.5-Minute-Man" }, "last_changed": "2025-05-31T22:16:28.992578+00:00", "last_reported": "2025-05-31T23:47:30.105899+00:00", "last_updated": "2025-05-31T23:47:30.105899+00:00", "context": { "id": "01JWMBWKNSF96PGAAFYZ6D5JKT", "parent_id": null, "user_id": null } } }, "metadata": { "time_fired": "2025-05-31T23:47:30.105899+00:00", "context": { "id": "01JWMBWKNSF96PGAAFYZ6D5JKT", "parent_id": null, "user_id": null }, "origin": "LOCAL" } } 2025-06-01 01:47:30.111263 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-01 01:47:30.111354 INFO AppDaemon: Previous message repeated 1 times 2025-06-01 01:47:30.111392 WARNING AppDaemon: Unexpected error during process_event() 2025-06-01 01:47:30.111428 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-01 01:47:30.111622 WARNING AppDaemon: Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/events.py", line 234, in process_event self.AD.state.set_state_simple(namespace, entity_id, data["data"]["new_state"]) File "/usr/lib/python3.12/site-packages/appdaemon/state.py", line 777, in set_state_simple if self.entity_exists(namespace, entity_id): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/state.py", line 473, in entity_exists return namespace in self.state and entity in self.state[namespace] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: argument of type 'NoneType' is not iterable

2025-06-01 01:47:30.111719 WARNING AppDaemon: { "event_type": "state_changed", "data": { "entity_id": "automation.0_5_minute_man", "old_state": { "entity_id": "automation.0_5_minute_man", "state": "on", "attributes": { "id": "1689807491921", "last_triggered": "2025-05-31T23:47:30.105885+00:00", "mode": "single", "current": 1, "icon": "mdi:timer-play-outline", "friendly_name": "0.5-Minute-Man" }, "last_changed": "2025-05-31T22:16:28.992578+00:00", "last_reported": "2025-05-31T23:47:30.105899+00:00", "last_updated": "2025-05-31T23:47:30.105899+00:00", "context": { "id": "01JWMBWKNSF96PGAAFYZ6D5JKT", "parent_id": null, "user_id": null } }, "new_state": { "entity_id": "automation.0_5_minute_man", "state": "on", "attributes": { "id": "1689807491921", "last_triggered": "2025-05-31T23:47:30.105885+00:00", "mode": "single", "current": 0, "icon": "mdi:timer-play-outline", "friendly_name": "0.5-Minute-Man" }, "last_changed": "2025-05-31T22:16:28.992578+00:00", "last_reported": "2025-05-31T23:47:30.106524+00:00", "last_updated": "2025-05-31T23:47:30.106524+00:00", "context": { "id": "01JWMBWKNSF96PGAAFYZ6D5JKT", "parent_id": null, "user_id": null } } }, "metadata": { "time_fired": "2025-05-31T23:47:30.106524+00:00", "context": { "id": "01JWMBWKNSF96PGAAFYZ6D5JKT", "parent_id": null, "user_id": null }, "origin": "LOCAL" } } 2025-06-01 01:47:30.111787 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-01 01:47:30.111866 INFO AppDaemon: Previous message repeated 1 times 2025-06-01 01:47:30.111904 WARNING AppDaemon: Unexpected error during process_event() 2025-06-01 01:47:30.111948 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-01 01:47:30.112107 WARNING AppDaemon: Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/events.py", line 234, in process_event self.AD.state.set_state_simple(namespace, entity_id, data["data"]["new_state"]) File "/usr/lib/python3.12/site-packages/appdaemon/state.py", line 777, in set_state_simple if self.entity_exists(namespace, entity_id): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/state.py", line 473, in entity_exists return namespace in self.state and entity in self.state[namespace] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: argument of type 'NoneType' is not iterable

2025-06-01 01:47:30.112230 WARNING AppDaemon: { "event_type": "state_changed", "data": { "entity_id": "sensor.ha_text_ai_deepseek", "old_state": { "entity_id": "sensor.ha_text_ai_deepseek", "state": "ready", "attributes": { "model": "deepseek-chat", "api_provider": "deepseek", "api_status": "ready", "total_errors": 0, "instance_name": "deepseek", "normalized_name": "deepseek", "is_processing": false, "is_rate_limited": false, "is_maintenance": false, "endpoint_status": "ready", "uptime": 5466.93, "history_size": 0, "total_tokens": 27, "prompt_tokens": 8, "completion_tokens": 19, "successful_requests": 1, "failed_requests": 0, "average_latency": 4.77, "max_latency": 4.77, "min_latency": 4.773988, "response": "", "question": "", "last_model": "deepseek-chat", "last_timestamp": "2025-05-31T22:16:22.180716+00:00", "icon": "mdi:robot", "friendly_name": "HA Text AI deepseek" }, "last_changed": "2025-05-31T22:16:27.105468+00:00", "last_reported": "2025-05-31T23:47:29.106695+00:00", "last_updated": "2025-05-31T23:47:29.106695+00:00", "context": { "id": "01JWMBWJPJRQKQKDXY87JHRVVX", "parent_id": null, "user_id": null } }, "new_state": { "entity_id": "sensor.ha_text_ai_deepseek", "state": "ready", "attributes": { "model": "deepseek-chat", "api_provider": "deepseek", "api_status": "ready", "total_errors": 0, "instance_name": "deepseek", "normalized_name": "deepseek", "is_processing": false, "is_rate_limited": false, "is_maintenance": false, "endpoint_status": "ready", "uptime": 5467.93, "history_size": 0, "total_tokens": 27, "prompt_tokens": 8, "completion_tokens": 19, "successful_requests": 1, "failed_requests": 0, "average_latency": 4.77, "max_latency": 4.77, "min_latency": 4.773988, "response": "", "question": "", "last_model": "deepseek-chat", "last_timestamp": "2025-05-31T22:16:22.180716+00:00", "icon": "mdi:robot", "friendly_name": "HA Text AI deepseek" }, "last_changed": "2025-05-31T22:16:27.105468+00:00", "last_reported": "2025-05-31T23:47:30.106782+00:00", "last_updated": "2025-05-31T23:47:30.106782+00:00", "context": { "id": "01JWMBWKNT6RFWP3G2WS6Z5BAG", "parent_id": null, "user_id": null } } }, "metadata": { "time_fired": "2025-05-31T23:47:30.106782+00:00", "context": { "id": "01JWMBWKNT6RFWP3G2WS6Z5BAG", "parent_id": null, "user_id": null }, "origin": "LOCAL" } } 2025-06-01 01:47:30.112307 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-01 01:47:30.124109 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-01 01:47:30.125359 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-01 01:47:30.125458 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-01 01:47:34.129304 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:34.129436 WARNING HASS: Unexpected error during websocket send 2025-06-01 01:47:34.129516 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 337, in websocket_send_json await self.ws.send_json(request) File "/usr/lib/python3.12/site-packages/aiohttp/client_ws.py", line 261, in send_json await self.send_str(dumps(data), compress=compress) File "/usr/lib/python3.12/site-packages/aiohttp/client_ws.py", line 245, in send_str await self._writer.send_frame( File "/usr/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame raise ClientConnectionResetError("Cannot write to closing transport") aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

2025-06-01 01:47:34.129592 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:34.129875 INFO HASS: Previous message repeated 1 times 2025-06-01 01:47:34.129951 WARNING HASS: Unexpected error while getting hass config 2025-06-01 01:47:34.130021 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 577, in get_hass_config if meta := (await self.websocket_send_json(type="get_config")).get("result"): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get'

2025-06-01 01:47:34.130086 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:34.145015 INFO HASS: Previous message repeated 1 times 2025-06-01 01:47:34.145102 WARNING HASS: Unexpected error during websocket send 2025-06-01 01:47:34.145168 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 337, in websocket_send_json await self.ws.send_json(request) File "/usr/lib/python3.12/site-packages/aiohttp/client_ws.py", line 261, in send_json await self.send_str(dumps(data), compress=compress) File "/usr/lib/python3.12/site-packages/aiohttp/client_ws.py", line 245, in send_str await self._writer.send_frame( File "/usr/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame raise ClientConnectionResetError("Cannot write to closing transport") aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

2025-06-01 01:47:34.145233 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:34.145323 WARNING HASS: Error getting services - retrying 2025-06-01 01:47:34.145522 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:34.145590 WARNING HASS: Unexpected error while getting hass services 2025-06-01 01:47:34.145651 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 589, in get_hass_services services: dict[str, dict[str, dict]] = (await self.websocket_send_json(type="get_services"))["result"] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ TypeError: 'NoneType' object is not subscriptable

2025-06-01 01:47:34.145711 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:34.631910 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:34.632045 WARNING HASS: Unexpected error during websocket send 2025-06-01 01:47:34.632123 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 337, in websocket_send_json await self.ws.send_json(request) File "/usr/lib/python3.12/site-packages/aiohttp/client_ws.py", line 261, in send_json await self.send_str(dumps(data), compress=compress) File "/usr/lib/python3.12/site-packages/aiohttp/client_ws.py", line 245, in send_str await self._writer.send_frame( File "/usr/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame raise ClientConnectionResetError("Cannot write to closing transport") aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

2025-06-01 01:47:34.632195 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:34.632478 INFO HASS: Previous message repeated 1 times 2025-06-01 01:47:34.632543 WARNING HASS: Unexpected error while getting hass config 2025-06-01 01:47:34.632609 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 577, in get_hass_config if meta := (await self.websocket_send_json(type="get_config")).get("result"): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get'

2025-06-01 01:47:34.632674 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:34.647431 INFO HASS: Previous message repeated 1 times 2025-06-01 01:47:34.647502 WARNING HASS: Unexpected error during websocket send 2025-06-01 01:47:34.647567 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 337, in websocket_send_json await self.ws.send_json(request) File "/usr/lib/python3.12/site-packages/aiohttp/client_ws.py", line 261, in send_json await self.send_str(dumps(data), compress=compress) File "/usr/lib/python3.12/site-packages/aiohttp/client_ws.py", line 245, in send_str await self._writer.send_frame( File "/usr/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame raise ClientConnectionResetError("Cannot write to closing transport") aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

2025-06-01 01:47:34.647632 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:34.647700 WARNING HASS: Error getting services - retrying 2025-06-01 01:47:34.647893 WARNING HASS: ------------------------------------------------------------ 2025-06-01 01:47:34.647969 WARNING HASS: Unexpected error while getting hass services 2025-06-01 01:47:34.648032 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 589, in get_hass_services services: dict[str, dict[str, dict]] = (await self.websocket_send_json(type="get_services"))["result"] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ TypeError: 'NoneType' object is not subscriptable

appdaemon.yaml:

---
appdaemon:
  latitude: 52.379189
  longitude: 4.899431
  elevation: 2
  time_zone: Europe/Amsterdam
  plugins:
    HASS:
      type: hass
      ha_url: http://172.16.0.3:8123
      token: xxx
http:
  url: http://0.0.0.0:5050
admin:
api:
hadashboard:

i have no idea what is going on here

Version

4.5.3

Installation type

Home Assistant add-on

Relevant log output


Relevant code in the app or config file that caused the issue


Anything else?

I tried also version 4.5.5 on docker, same issue

collateral87 avatar Jun 01 '25 07:06 collateral87

Thanks for reporting, we will have a look

acockburn avatar Jun 01 '25 13:06 acockburn

Hope u can find a good resolution for the problem.

fastender avatar Jun 01 '25 21:06 fastender

@acockburn Just FYI: on Homeassistant Addon 0.17.3 (which contains AD 4.5.7), the issue persists. @fastender Do you have the same problem? I just wonder, why no one else seams to have this issue. I think it cames with AD 4.5.0

collateral87 avatar Jun 02 '25 08:06 collateral87

Thanks - we are still looking at it. It's weird that no-one else is reporting it, so it seems like a local config issue. The errors we are seeing in the logs point to a closed or closing connection with HomeAssistant. We are adding code in 4.5.8 to make this a little clearer and more graceful but this may not address the underlying issue, so lets see what happens with the next release and possibly think about some additional debugging info when we see what that looks like.

acockburn avatar Jun 02 '25 12:06 acockburn

I have similar output in my log files. I'm currently running AppDaemon 4.5.7 as a docker container, connecting to Home Assistant 2025.5.3

2025-06-02 22:21:41.954254 WARNING AppDaemon: ------------------------------------------------------------
2025-06-02 22:21:42.011887 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-06-02 22:21:42.638384 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-06-02 22:21:43.881582 WARNING HASS: ------------------------------------------------------------
2025-06-02 22:21:43.882330 WARNING HASS: Unexpected error during websocket send
2025-06-02 22:21:43.882960 WARNING HASS: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 338, in websocket_send_json
    await self.ws.send_json(request)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 259, in send_json
    await self.send_str(dumps(data), compress=compress)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 243, in send_str
    await self._writer.send_frame(
  File "/usr/local/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame
    raise ClientConnectionResetError("Cannot write to closing transport")
aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport
2025-06-02 22:21:43.883642 WARNING HASS: ------------------------------------------------------------
2025-06-02 22:21:43.885835 INFO HASS: Previous message repeated 1 times
2025-06-02 22:21:43.886398 WARNING HASS: Unexpected error while getting hass config
2025-06-02 22:21:43.887006 WARNING HASS: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 578, in get_hass_config
    if meta := (await self.websocket_send_json(type="get_config")).get("result"):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
2025-06-02 22:21:43.887540 WARNING HASS: ------------------------------------------------------------
2025-06-02 22:21:43.997236 WARNING HASS: ------------------------------------------------------------
2025-06-02 22:21:43.998252 WARNING HASS: Unexpected error during websocket send
2025-06-02 22:21:43.998833 WARNING HASS: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 338, in websocket_send_json
    await self.ws.send_json(request)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 259, in send_json
    await self.send_str(dumps(data), compress=compress)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 243, in send_str
    await self._writer.send_frame(
  File "/usr/local/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame
    raise ClientConnectionResetError("Cannot write to closing transport")
aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport
2025-06-02 22:21:43.999378 WARNING HASS: ------------------------------------------------------------
2025-06-02 22:21:43.999913 WARNING HASS: Error getting services - retrying
2025-06-02 22:21:44.001573 WARNING HASS: ------------------------------------------------------------
2025-06-02 22:21:44.002271 WARNING HASS: Unexpected error while getting hass services
2025-06-02 22:21:44.002833 WARNING HASS: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/appdaemon/utils.py", line 478, in wrapper
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 590, in get_hass_services
    services: dict[str, dict[str, dict]] = (await self.websocket_send_json(type="get_services"))["result"]
                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

My AppDaemon.yaml file looks like this:

appdaemon:
  latitude: 0
  longitude: 0
  elevation: 0
  time_zone: Europe/Amsterdam
  exclude_dirs:
    - cx_core
  plugins:
    HASS:
      type: hass
      ha_url: http://192.168.2.100:8123
      token: !secret TOKEN
      cert_verify: True
http:
  url: http://0.0.0.0:5050
admin:
api:
hadashboard:

AdeZwart avatar Jun 02 '25 20:06 AdeZwart

Thanks - we are still looking at it. It's weird that no-one else is reporting it, so it seems like a local config issue. The errors we are seeing in the logs point to a closed or closing connection with HomeAssistant. We are adding code in 4.5.8 to make this a little clearer and more graceful but this may not address the underlying issue, so lets see what happens with the next release and possibly think about some additional debugging info when we see what that looks like.

Unfortunately, you're right. 4.5.8 doesn't solve the problem for me. I've since tested version 4.4.2, and everything works fine there, if that helps.

collateral87 avatar Jun 03 '25 15:06 collateral87

I'm facing similar, if not the same, issue. After appdeamon loads my apps (i.e. buttons), it throws following and exits.

2025-06-03 21:03:34.916759 WARNING AppDaemon: ------------------------------------------------------------
2025-06-03 21:03:34.917205 WARNING AppDaemon: Unexpected error during run()
2025-06-03 21:03:34.917589 WARNING AppDaemon: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/appdaemon/__main__.py", line 157, in run
    loop.run_until_complete(asyncio.gather(*pending))
  File "/usr/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/appdaemon/utility_loop.py", line 144, in loop
    await self.AD.app_management.check_app_updates(mode=UpdateMode.INIT)
  File "/usr/lib/python3.12/site-packages/appdaemon/app_management.py", line 812, in check_app_updates
    await self._import_modules(update_actions)
  File "/usr/lib/python3.12/site-packages/appdaemon/app_management.py", line 1058, in _import_modules
    load_order = self.dependency_manager.python_sort(modules)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/appdaemon/dependency_manager.py", line 210, in python_sort
    order = [n for n in topo_sort(self.python_deps.dep_graph) if n in modules]
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/appdaemon/dependency.py", line 261, in topo_sort
    raise CircularDependency(f"Visited {visited} already, but {node} depends on {deps}")
appdaemon.dependency.CircularDependency: Visited ['cx_core.feature_support.cover', 'cx_devices.lutron', 'cx_const', 'collections.abc', 'typing', 'cx_core', 'cx_core.type.media_player_controller', 'cx_core.stepper.stop_stepper', 'cx_core.stepper', 'abc', 'dataclasses', 'cx_core.type_controller', 'cx_core.feature_support', 'cx_core.controller', 'asyncio', 're', 'functools', 'cx_core.action_type', 'cx_core.action_type.call_service_action_type', 'cx_core.integration', 'cx_helper', 'importlib', 'os', 'pkgutil', 'cx_core.action_type.base', 'cx_core.action_type.predefined_action_type', 'inspect', 'cx_core.action_type.delay_action_type', 'cx_core.action_type.scene_action_type', 'ast', 'collections', 'time', 'appdaemon.adapi', 'cx_version', 'appdaemon.utils', 'appdaemon.plugins.hass.hassapi', 'appdaemon.plugins.mqtt.mqttapi', 'cx_core.release_hold_controller', 'cx_core.integration.z2m', 'json', 'cx_core.stepper.index_loop_stepper', 'cx_core.feature_support.media_player', 'cx_core.type.cover_controller', 'cx_core.type.z2m_light_controller', 'cx_core.type.light_controller', 'cx_core.feature_support.light', 'cx_core.color_helper', 'cx_core.integration.zha', 'cx_core.integration.deconz', 'cx_core.stepper.bounce_stepper', 'cx_core.stepper.loop_stepper', 'cx_core.type.switch_controller'] already, but cx_devices.lutron depends on {'cx_const', 'cx_core', 'cx_core.type.z2m_light_controller'}
2025-06-03 21:03:34.923852 INFO AppDaemon: Previous message repeated 1 times
2025-06-03 21:03:34.924263 INFO AppDaemon: AppDaemon Exited
[21:03:35] INFO: Service AppDaemon exited with code 0 (by signal 0)

I tried to do the exclude_dirs thing, but to no avail

2025-06-03 21:06:17.198295 ERROR Error: FailedImport: Failed to import 'controllerx'
2025-06-03 21:06:17.202767 ERROR Error:   AttributeError: module 'appdaemon.utils' has no attribute 'sync_wrapper'
2025-06-03 21:06:17.208746 ERROR Error:     File "/usr/lib/python3.12/site-packages/appdaemon/app_management.py", line 1066, in safe_import
2025-06-03 21:06:17.209674 ERROR Error:       await self.import_module(module_name)
2025-06-03 21:06:17.210300 ERROR Error:     File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 529, in wrapper
2025-06-03 21:06:17.210954 ERROR Error:       return await run_in_executor(self, func, *args, **kwargs)
2025-06-03 21:06:17.211626 ERROR Error:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-06-03 21:06:17.212240 ERROR Error:     File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 554, in run_in_executor
2025-06-03 21:06:17.212865 ERROR Error:       return await future
2025-06-03 21:06:17.213534 ERROR Error:              ^^^^^^^^^^^^
2025-06-03 21:06:17.214195 ERROR Error:     File "/usr/lib/python3.12/concurrent/futures/thread.py", line 59, in run
2025-06-03 21:06:17.215625 ERROR Error:       result = self.fn(*self.args, **self.kwargs)
2025-06-03 21:06:17.216079 ERROR Error:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-06-03 21:06:17.216541 ERROR Error:     File "/usr/lib/python3.12/site-packages/appdaemon/app_management.py", line 698, in import_module
2025-06-03 21:06:17.216978 ERROR Error:       raise exc
2025-06-03 21:06:17.217404 ERROR Error:     File "/usr/lib/python3.12/site-packages/appdaemon/app_management.py", line 690, in import_module
2025-06-03 21:06:17.217793 ERROR Error:       importlib.import_module(module_name)
2025-06-03 21:06:17.218209 ERROR Error:     File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
2025-06-03 21:06:17.218608 ERROR Error:       return _bootstrap._gcd_import(name[level:], package, level)
2025-06-03 21:06:17.219170 ERROR Error:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-06-03 21:06:17.219698 ERROR Error:     File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
2025-06-03 21:06:17.220163 ERROR Error:     File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
2025-06-03 21:06:17.220585 ERROR Error:     File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
2025-06-03 21:06:17.221019 ERROR Error:     File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
2025-06-03 21:06:17.221492 ERROR Error:     File "<frozen importlib._bootstrap_external>", line 999, in exec_module
2025-06-03 21:06:17.221935 ERROR Error:     File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
2025-06-03 21:06:17.222330 ERROR Error:     File "/homeassistant/appdaemon/apps/controllerx/controllerx.py", line 7, in <module>
2025-06-03 21:06:17.222733 ERROR Error:       from cx_core import (
2025-06-03 21:06:17.223133 ERROR Error:     File "/homeassistant/appdaemon/apps/controllerx/cx_core/__init__.py", line 1, in <module>
2025-06-03 21:06:17.223577 ERROR Error:       from cx_core.controller import Controller, action
2025-06-03 21:06:17.224154 ERROR Error:     File "/homeassistant/appdaemon/apps/controllerx/cx_core/controller.py", line 65, in <module>
2025-06-03 21:06:17.224579 ERROR Error:       class Controller(Hass, Mqtt):  # type: ignore[misc]
2025-06-03 21:06:17.224987 ERROR Error:     File "/homeassistant/appdaemon/apps/controllerx/cx_core/controller.py", line 350, in Controller
2025-06-03 21:06:17.225390 ERROR Error:       @utils.sync_wrapper  # type: ignore[misc]
2025-06-03 21:06:17.225790 ERROR Error:        ^^^^^^^^^^^^^^^^^^
2025-06-03 21:06:17.226205 ERROR Error: ===========================================================================
2025-06-03 21:06:17.227421 WARNING AppDaemon: Failed to start apps: {'jakubs_bedside_lamp', 'cisels_bedside_lamp', 'both_bedside_lamps', 'living_room_lights_on_button', 'studio_button'}
2025-06-03 21:06:17.228366 INFO AppDaemon: App initialization complete```

jakubheglas avatar Jun 03 '25 19:06 jakubheglas

@jakubheglas - this seems like a different issue, and is related to the controllerx app issue being tracked here: https://github.com/xaviml/controllerx/issues/1184

acockburn avatar Jun 03 '25 19:06 acockburn

Thanks - we are still looking at it. It's weird that no-one else is reporting it, so it seems like a local config issue. The errors we are seeing in the logs point to a closed or closing connection with HomeAssistant. We are adding code in 4.5.8 to make this a little clearer and more graceful but this may not address the underlying issue, so lets see what happens with the next release and possibly think about some additional debugging info when we see what that looks like.

Unfortunately, you're right. 4.5.8 doesn't solve the problem for me. I've since tested version 4.4.2, and everything works fine there, if that helps.

Whatever errors are present must have changed at least. The lines of code referenced in your initial post no longer exist because the websocket response is now wrapped in a match/case structure, so it's no longer possible for it to throw a KeyError

jsl12 avatar Jun 04 '25 00:06 jsl12

Thanks - we are still looking at it. It's weird that no-one else is reporting it, so it seems like a local config issue. The errors we are seeing in the logs point to a closed or closing connection with HomeAssistant. We are adding code in 4.5.8 to make this a little clearer and more graceful but this may not address the underlying issue, so lets see what happens with the next release and possibly think about some additional debugging info when we see what that looks like.

Unfortunately, you're right. 4.5.8 doesn't solve the problem for me. I've since tested version 4.4.2, and everything works fine there, if that helps.

Whatever errors are present must have changed at least. The lines of code referenced in your initial post no longer exist because the websocket response is now wrapped in a match/case structure, so it's no longer possible for it to throw a KeyError

Below you find the logs from my 4.5.8 instance.

Logs from 4.5.8 2025-06-04 10:57:08.544206 INFO AppDaemon: AppDaemon Version 4.5.8 starting 2025-06-04 10:57:08.544246 INFO AppDaemon: ------------------------------------------------------------ 2025-06-04 10:57:08.544277 INFO AppDaemon: Python version is 3.12.10 2025-06-04 10:57:08.544401 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml 2025-06-04 10:57:08.544466 INFO AppDaemon: Added log: AppDaemon 2025-06-04 10:57:08.544495 INFO AppDaemon: Added log: Error 2025-06-04 10:57:08.544516 INFO AppDaemon: Added log: Access 2025-06-04 10:57:08.544537 INFO AppDaemon: Added log: Diag 2025-06-04 10:57:08.544934 INFO AppDaemon: Using /conf/apps as app_dir 2025-06-04 10:57:08.545397 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module appdaemon.plugins.hass.hassplugin 2025-06-04 10:57:08.545486 INFO HASS: HASS Plugin initialization complete 2025-06-04 10:57:08.547373 INFO AppDaemon: Initializing HTTP 2025-06-04 10:57:08.547456 INFO AppDaemon: Using 'ws' for event stream 2025-06-04 10:57:08.547573 INFO AppDaemon: HTTP Listening on port 5050 2025-06-04 10:57:08.548525 INFO AppDaemon: Starting API 2025-06-04 10:57:08.549127 INFO AppDaemon: Starting Admin Interface 2025-06-04 10:57:08.549209 INFO AppDaemon: Starting Dashboards 2025-06-04 10:57:08.553058 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-04 10:57:08.553403 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-04 10:57:08.553735 INFO HASS: Waiting for Home Assistant to start 2025-06-04 10:57:08.555651 INFO AppDaemon: Starting Apps with 1 workers and 1 pins 2025-06-04 10:57:08.561040 INFO AppDaemon: Running on port 5050 2025-06-04 10:57:08.561136 INFO AppDaemon: Waiting for plugins to be ready 2025-06-04 10:57:08.574664 INFO AppDaemon: All plugins ready 2025-06-04 10:57:08.575072 INFO AppDaemon: Scheduler running in realtime 2025-06-04 10:57:08.580073 INFO AppDaemon: New app config: hello_world 2025-06-04 10:57:08.582734 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-04 10:57:08.583420 INFO AppDaemon: Calling initialize() for hello_world 2025-06-04 10:57:08.601610 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-04 10:57:08.608467 INFO hello_world: Hello from AppDaemon 2025-06-04 10:57:08.608729 INFO hello_world: You are now ready to run Apps! 2025-06-04 10:57:08.608994 INFO AppDaemon: App initialization complete 2025-06-04 10:57:08.610846 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-04 10:57:08.610939 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-04 10:57:13.603654 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-04 10:57:13.604050 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-04 10:57:13.604433 INFO HASS: Waiting for Home Assistant to start 2025-06-04 10:57:13.649381 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-04 10:57:13.651655 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-04 10:57:13.651760 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-04 10:57:18.574840 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-04 10:57:18.575445 INFO HASS: Completed initialization in 5.0s 2025-06-04 10:57:18.651029 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-04 10:57:18.651409 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-04 10:57:18.651765 INFO HASS: Waiting for Home Assistant to start 2025-06-04 10:57:18.695304 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-04 10:57:18.697577 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-04 10:57:18.697680 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-04 10:57:23.625217 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-04 10:57:23.625961 INFO HASS: Completed initialization in 5.0s 2025-06-04 10:57:23.628154 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-04 10:57:23.628275 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-04 10:57:23.628944 INFO AppDaemon: Calling initialize() for hello_world 2025-06-04 10:57:23.629623 INFO hello_world: Hello from AppDaemon 2025-06-04 10:57:23.630081 INFO hello_world: You are now ready to run Apps! 2025-06-04 10:57:23.697975 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-04 10:57:23.698415 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-04 10:57:23.698850 INFO HASS: Waiting for Home Assistant to start 2025-06-04 10:57:23.743438 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-04 10:57:23.746257 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-04 10:57:23.746394 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-04 10:57:28.672847 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-04 10:57:28.673470 INFO HASS: Completed initialization in 5.0s 2025-06-04 10:57:28.675921 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-04 10:57:28.676033 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-04 10:57:28.676646 INFO AppDaemon: Calling initialize() for hello_world 2025-06-04 10:57:28.677110 INFO hello_world: Hello from AppDaemon 2025-06-04 10:57:28.677457 INFO hello_world: You are now ready to run Apps! 2025-06-04 10:57:28.744982 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-04 10:57:28.745321 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-04 10:57:28.745674 INFO HASS: Waiting for Home Assistant to start 2025-06-04 10:57:28.790688 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-04 10:57:28.792923 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-04 10:57:28.793015 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-04 10:57:33.719096 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-04 10:57:33.719644 INFO HASS: Completed initialization in 5.0s 2025-06-04 10:57:33.721518 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-04 10:57:33.721650 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-04 10:57:33.722325 INFO AppDaemon: Calling initialize() for hello_world 2025-06-04 10:57:33.722842 INFO hello_world: Hello from AppDaemon 2025-06-04 10:57:33.723114 INFO hello_world: You are now ready to run Apps! 2025-06-04 10:57:33.793248 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-04 10:57:33.793764 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-04 10:57:33.794272 INFO HASS: Waiting for Home Assistant to start 2025-06-04 10:57:33.839819 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-04 10:57:33.843192 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-04 10:57:33.843375 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-04 10:57:38.766730 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-04 10:57:38.767300 INFO HASS: Completed initialization in 5.0s 2025-06-04 10:57:38.769227 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-04 10:57:38.769334 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-04 10:57:38.769970 INFO AppDaemon: Calling initialize() for hello_world 2025-06-04 10:57:38.770628 INFO hello_world: Hello from AppDaemon 2025-06-04 10:57:38.771098 INFO hello_world: You are now ready to run Apps! 2025-06-04 10:57:38.841725 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-04 10:57:38.842097 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-04 10:57:38.842454 INFO HASS: Waiting for Home Assistant to start 2025-06-04 10:57:38.907442 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-04 10:57:38.909989 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-04 10:57:38.910161 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-04 10:57:43.816045 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-04 10:57:43.816736 INFO HASS: Completed initialization in 5.0s 2025-06-04 10:57:43.819073 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-04 10:57:43.819188 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-04 10:57:43.819847 INFO AppDaemon: Calling initialize() for hello_world 2025-06-04 10:57:43.820550 INFO hello_world: Hello from AppDaemon 2025-06-04 10:57:43.821067 INFO hello_world: You are now ready to run Apps! 2025-06-04 10:57:43.911107 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-04 10:57:43.912366 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-04 10:57:43.912781 INFO HASS: Waiting for Home Assistant to start 2025-06-04 10:57:43.955779 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-04 10:57:43.958053 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-04 10:57:43.958143 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-04 10:57:48.876397 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-04 10:57:48.877101 INFO HASS: Completed initialization in 5.0s 2025-06-04 10:57:48.879379 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-04 10:57:48.879503 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-04 10:57:48.880252 INFO AppDaemon: Calling initialize() for hello_world 2025-06-04 10:57:48.881000 INFO hello_world: Hello from AppDaemon 2025-06-04 10:57:48.881489 INFO hello_world: You are now ready to run Apps! 2025-06-04 10:57:48.968321 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-04 10:57:48.968720 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-04 10:57:48.969007 INFO HASS: Waiting for Home Assistant to start 2025-06-04 10:57:49.014090 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-04 10:57:49.017376 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-04 10:57:49.017550 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-04 10:57:53.931203 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-04 10:57:53.931874 INFO HASS: Completed initialization in 5.0s 2025-06-04 10:57:53.934061 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-04 10:57:53.934173 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-04 10:57:53.934875 INFO AppDaemon: Calling initialize() for hello_world 2025-06-04 10:57:53.935555 INFO hello_world: Hello from AppDaemon 2025-06-04 10:57:53.936040 INFO hello_world: You are now ready to run Apps! 2025-06-04 10:57:54.015657 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-04 10:57:54.016037 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-04 10:57:54.016375 INFO HASS: Waiting for Home Assistant to start 2025-06-04 10:57:54.036027 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-04 10:57:54.036113 WARNING AppDaemon: Unexpected error during process_event() 2025-06-04 10:57:54.036152 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-04 10:57:54.036703 WARNING AppDaemon: Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/appdaemon/events.py", line 234, in process_event self.AD.state.set_state_simple(namespace, entity_id, data["data"]["new_state"]) File "/usr/local/lib/python3.12/site-packages/appdaemon/state.py", line 777, in set_state_simple if self.entity_exists(namespace, entity_id): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/appdaemon/state.py", line 473, in entity_exists return namespace in self.state and entity in self.state[namespace] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: argument of type 'NoneType' is not iterable

2025-06-04 10:57:54.036813 WARNING AppDaemon: { "event_type": "state_changed", "data": { "entity_id": "sensor.0x001788010df71747_illuminance", "old_state": { "entity_id": "sensor.0x001788010df71747_illuminance", "state": "158", "attributes": { "state_class": "measurement", "unit_of_measurement": "lx", "device_class": "illuminance", "friendly_name": "Bewegungsmelder (Hasenk\u00e4fig Garten) Beleuchtungsst\u00e4rke" }, "last_changed": "2025-06-04T08:57:44.073024+00:00", "last_reported": "2025-06-04T08:57:44.073024+00:00", "last_updated": "2025-06-04T08:57:44.073024+00:00", "context": { "id": "01JWX2J8W90AKPFDF8MV78P3SQ", "parent_id": null, "user_id": null } }, "new_state": { "entity_id": "sensor.0x001788010df71747_illuminance", "state": "159", "attributes": { "state_class": "measurement", "unit_of_measurement": "lx", "device_class": "illuminance", "friendly_name": "Bewegungsmelder (Hasenk\u00e4fig Garten) Beleuchtungsst\u00e4rke" }, "last_changed": "2025-06-04T08:57:54.020047+00:00", "last_reported": "2025-06-04T08:57:54.020047+00:00", "last_updated": "2025-06-04T08:57:54.020047+00:00", "context": { "id": "01JWX2JJK4R1Y9NR8GHEDXGEVX", "parent_id": null, "user_id": null } }, "metadata": { "origin": "LOCAL", "context": { "id": "01JWX2JJK4R1Y9NR8GHEDXGEVX", "parent_id": null, "user_id": null }, "time_fired": "2025-06-04T08:57:54.020047+00:00" } } } 2025-06-04 10:57:54.036864 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-04 10:57:54.058999 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-04 10:57:54.060946 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-04 10:57:54.061038 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-04 10:57:58.992891 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-04 10:57:58.993676 INFO HASS: Completed initialization in 5.0s 2025-06-04 10:57:58.995588 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-04 10:57:58.995706 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-04 10:57:58.996347 INFO AppDaemon: Calling initialize() for hello_world 2025-06-04 10:57:58.997037 INFO hello_world: Hello from AppDaemon 2025-06-04 10:57:58.997519 INFO hello_world: You are now ready to run Apps! 2025-06-04 10:57:59.061589 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-04 10:57:59.062008 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-04 10:57:59.062457 INFO HASS: Waiting for Home Assistant to start 2025-06-04 10:57:59.106504 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-04 10:57:59.109134 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-04 10:57:59.109230 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-04 10:58:04.037923 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-04 10:58:04.038582 INFO HASS: Completed initialization in 5.0s .... .... ....

collateral87 avatar Jun 04 '25 09:06 collateral87

@frenck - do you have any thoughts here? The logs are showing issues connecting and/or staying connected from AD to HASS' websocket, which should not be an issue in the add-on environment as far as I know.

acockburn avatar Jun 04 '25 12:06 acockburn

Please let me know if i could help with trying or testing

collateral87 avatar Jun 04 '25 13:06 collateral87

I also had a working Appdaemon in use for a few dashboards. Now I have Home Assistant 2025.5.3, Appdaemon addon 0.17.4. It tries to start but stops directly and then tries to restart again. This is repeated over and over..... I have not changed anything in my settings since it last worked (unfortunately I do not have the version number when it actually worked). My appdaemon.yaml is:


secrets: /config/secrets.yaml appdaemon: latitude: !secret latitude_home longitude: !secret longitude_home elevation: !secret elevation_home time_zone: Europe/Copenhagen plugins: HASS: type: hass token: !env_var SUPERVISOR_TOKEN disable_apps: 1 http: url: http://0.0.0.0:5050 admin: api: hadashboard:

And this is the log: 2025-06-04 15:30:32.422953 INFO AppDaemon: ------------------------------------------------------------ 2025-06-04 15:30:32.423232 INFO AppDaemon: AppDaemon Version 4.5.8 starting 2025-06-04 15:30:32.423305 INFO AppDaemon: ------------------------------------------------------------ 2025-06-04 15:30:32.423359 INFO AppDaemon: Python version is 3.12.10 2025-06-04 15:30:32.423536 INFO AppDaemon: Configuration read from: /config/appdaemon.yaml 2025-06-04 15:30:32.423637 INFO AppDaemon: Added log: AppDaemon 2025-06-04 15:30:32.423693 INFO AppDaemon: Added log: Error 2025-06-04 15:30:32.423740 INFO AppDaemon: Added log: Access 2025-06-04 15:30:32.423792 INFO AppDaemon: Added log: Diag [15:30:32] INFO: [32mService AppDaemon exited with code 0 (by signal 0)[0m [15:30:33] INFO: [32mStarting AppDaemon...[0m { "admin": {}, "api": {}, "appdaemon": { "ad_version": "4.5.8", "admin_delay": 1, "api_key": null, "api_port": null, "api_ssl_certificate": null, "api_ssl_key": null, "app_dir": "/config/apps", "ascii_encode": true, "cert_verify": true, "check_app_updates_profile": false, "config_dir": "/config", "config_file": "/config/appdaemon.yaml", "disable_apps": true, "elevation": 37, "endtime": null, "exclude_dirs": [], "ext": ".yaml", "filters": [], "import_method": null, "import_paths": [], "internal_function_timeout": "0:01:00", "invalid_config_warnings": true, "latitude": 56.0, "load_distribution": "roundrobbin", "log_thread_actions": false, "loglevel": "DEBUG", "longitude": 13.0, "max_clock_skew": 1, "max_utility_skew": "0:00:02", "missing_app_warnings": true, "module_debug": {}, "namespaces": {}, "pin_apps": true, "pin_threads": null, "plugin_performance_update": 10, "plugins": { "HASS": { "api_class": "Hass", "api_module": "appdaemon.plugins.hass.hassapi", "appdaemon_startup_conditions": null, "cert_path": null, "cert_verify": true, "commtype": "WS", "config_sleep_time": 60, "connect_timeout": 1.0, "disable": false, "enable_started_event": true, "ha_key": null, "ha_url": "http://supervisor/core", "name": "HASS", "namespace": "default", "namespaces": [], "persist_entities": false, "plugin_class": "HassPlugin", "plugin_module": "appdaemon.plugins.hass.hassplugin", "plugin_startup_conditions": null, "q_timeout": 30, "reconnect_delay": 5.0, "refresh_delay": "0:10:00", "refresh_timeout": 30, "retry_secs": 5, "services_sleep_time": 60, "suppress_log_messages": false, "token": "**********", "type": "hass", "use_dictionary_unpacking": true, "ws_timeout": "0:00:10" } }, "production_mode": false, "qsize_warning_iterations": 10, "qsize_warning_step": 60, "qsize_warning_threshold": 50, "starttime": null, "stop_function": "<bound method ADMain.stop of <appdaemon.main.ADMain object at 0x7f69742d3980>>", "suppress_log_messages": false, "thread_duration_warning_threshold": 10, "threadpool_workers": 10, "threads": null, "time_zone": "Europe/Copenhagen", "timewarp": 1, "total_threads": null, "use_dictionary_unpacking": false, "use_stream": false, "utility_delay": 1, "uvloop": false, "write_toml": false }, "hadashboard": { "compile_on_start": false, "config_dir": "/config", "config_file": "/config/appdaemon.yaml", "dashboard": true, "dashboard_dir": null, "force_compile": false, "profile_dashboard": false }, "http": { "headers": null, "password": null, "ssl_certificate": null, "ssl_key": null, "static_dirs": null, "transport": "ws", "url": "http://0.0.0.0:5050/" }, "log": null, "logs": null, "old_admin": null } 2025-06-04 15:30:35.649023 INFO AppDaemon: ------------------------------------------------------------ 2025-06-04 15:30:35.649423 INFO AppDaemon: AppDaemon Version 4.5.8 starting 2025-06-04 15:30:35.649542 INFO AppDaemon: ------------------------------------------------------------ 2025-06-04 15:30:35.649625 INFO AppDaemon: Python version is 3.12.10 2025-06-04 15:30:35.649892 INFO AppDaemon: Configuration read from: /config/appdaemon.yaml 2025-06-04 15:30:35.650026 INFO AppDaemon: Added log: AppDaemon 2025-06-04 15:30:35.650098 INFO AppDaemon: Added log: Error 2025-06-04 15:30:35.650147 INFO AppDaemon: Added log: Access 2025-06-04 15:30:35.650190 INFO AppDaemon: Added log: Diag [15:30:35] INFO: [32mService AppDaemon exited with code 0 (by signal 0)[0m [15:30:36] INFO: [32mStarting AppDaemon...[0m { "admin": {}, "api": {}, "appdaemon": {

... ETC, THIS IS REPEATED OVER AND OVER ...

I have a similar setup at a totally different location and there it starts, however without showing any dashboards in the GUI! I will discuss this in another issue.

MacValley avatar Jun 04 '25 13:06 MacValley

Thanks for the report and logs.

acockburn avatar Jun 04 '25 13:06 acockburn

OK, I may have reproduced this or something like it ... stay tuned.

acockburn avatar Jun 04 '25 21:06 acockburn

We just release 4.5.9 which has a fix for at least one of these issues - I'd appreciate it if folks could retest.

acockburn avatar Jun 05 '25 15:06 acockburn

First of all, thank you @acockburn for your effort.

I tried 4.5.9, unfortunately without success. Here are the logs:

Logs with 4.5.9 2025-06-05 21:34:02.413944 INFO AppDaemon: ------------------------------------------------------------ 2025-06-05 21:34:02.414165 INFO AppDaemon: AppDaemon Version 4.5.9 starting 2025-06-05 21:34:02.414210 INFO AppDaemon: ------------------------------------------------------------ 2025-06-05 21:34:02.414245 INFO AppDaemon: Python version is 3.12.11 2025-06-05 21:34:02.414357 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml 2025-06-05 21:34:02.414435 INFO AppDaemon: Added log: AppDaemon 2025-06-05 21:34:02.414470 INFO AppDaemon: Added log: Error 2025-06-05 21:34:02.414499 INFO AppDaemon: Added log: Access 2025-06-05 21:34:02.414525 INFO AppDaemon: Added log: Diag 2025-06-05 21:34:02.414927 INFO AppDaemon: Using /conf/apps as app_dir 2025-06-05 21:34:02.415411 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module appdaemon.plugins.hass.hassplugin 2025-06-05 21:34:02.415510 INFO HASS: HASS Plugin initialization complete 2025-06-05 21:34:02.417347 INFO AppDaemon: Initializing HTTP 2025-06-05 21:34:02.417436 INFO AppDaemon: Using 'ws' for event stream 2025-06-05 21:34:02.417548 INFO AppDaemon: HTTP Listening on port 5050 2025-06-05 21:34:02.418392 INFO AppDaemon: Starting API 2025-06-05 21:34:02.419001 INFO AppDaemon: Starting Admin Interface 2025-06-05 21:34:02.419083 INFO AppDaemon: Starting Dashboards 2025-06-05 21:34:02.423011 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-05 21:34:02.423543 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-05 21:34:02.424068 INFO HASS: Waiting for Home Assistant to start 2025-06-05 21:34:02.425759 INFO AppDaemon: Starting Apps with 1 workers and 1 pins 2025-06-05 21:34:02.426576 INFO AppDaemon: Running on port 5050 2025-06-05 21:34:02.426651 INFO AppDaemon: Waiting for plugins to be ready 2025-06-05 21:34:02.426936 INFO AppDaemon: All plugins ready 2025-06-05 21:34:02.427284 INFO AppDaemon: Scheduler running in realtime 2025-06-05 21:34:02.452040 WARNING AppDaemon: app.hello_world already exists, will not be adding it 2025-06-05 21:34:02.452274 INFO AppDaemon: New app config: hello_world 2025-06-05 21:34:02.456150 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-05 21:34:02.457651 INFO AppDaemon: Calling initialize() for hello_world 2025-06-05 21:34:02.474797 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-05 21:34:02.486737 INFO hello_world: Hello from AppDaemon 2025-06-05 21:34:02.487057 INFO hello_world: You are now ready to run Apps! 2025-06-05 21:34:02.487390 INFO AppDaemon: App initialization complete 2025-06-05 21:34:02.489134 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-05 21:34:02.489224 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-05 21:34:07.476997 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-05 21:34:07.477328 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-05 21:34:07.478048 INFO HASS: Waiting for Home Assistant to start 2025-06-05 21:34:07.565958 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-05 21:34:07.568435 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-05 21:34:07.568560 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-05 21:34:12.449896 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-05 21:34:12.450612 INFO HASS: Completed initialization in 5.0s 2025-06-05 21:34:12.567525 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-05 21:34:12.568476 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-05 21:34:12.568838 INFO HASS: Waiting for Home Assistant to start 2025-06-05 21:34:12.614827 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-05 21:34:12.617278 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-05 21:34:12.617393 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-05 21:34:17.500882 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-05 21:34:17.501888 INFO HASS: Completed initialization in 4.9s 2025-06-05 21:34:17.504726 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-05 21:34:17.504845 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-05 21:34:17.505491 INFO AppDaemon: Calling initialize() for hello_world 2025-06-05 21:34:17.506138 INFO hello_world: Hello from AppDaemon 2025-06-05 21:34:17.506626 INFO hello_world: You are now ready to run Apps! 2025-06-05 21:34:17.616884 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-05 21:34:17.617234 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-05 21:34:17.617540 INFO HASS: Waiting for Home Assistant to start 2025-06-05 21:34:17.669143 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-05 21:34:17.671495 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-05 21:34:17.671601 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-05 21:34:22.588364 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-05 21:34:22.588920 INFO HASS: Completed initialization in 5.0s 2025-06-05 21:34:22.590529 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-05 21:34:22.590647 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-05 21:34:22.591248 INFO AppDaemon: Calling initialize() for hello_world 2025-06-05 21:34:22.591699 INFO hello_world: Hello from AppDaemon 2025-06-05 21:34:22.591933 INFO hello_world: You are now ready to run Apps! 2025-06-05 21:34:22.671562 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-05 21:34:22.671971 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-05 21:34:22.672279 INFO HASS: Waiting for Home Assistant to start 2025-06-05 21:34:22.716140 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-05 21:34:22.718076 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-05 21:34:22.718180 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-05 21:34:27.637343 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-05 21:34:27.638083 INFO HASS: Completed initialization in 5.0s 2025-06-05 21:34:27.640976 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-05 21:34:27.641118 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-05 21:34:27.641893 INFO AppDaemon: Calling initialize() for hello_world 2025-06-05 21:34:27.642575 INFO hello_world: Hello from AppDaemon 2025-06-05 21:34:27.642848 INFO hello_world: You are now ready to run Apps! 2025-06-05 21:34:27.718761 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-05 21:34:27.719244 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-05 21:34:27.720796 INFO HASS: Waiting for Home Assistant to start 2025-06-05 21:34:27.774029 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-05 21:34:27.776774 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-05 21:34:27.776893 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-05 21:34:32.692855 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-05 21:34:32.693435 INFO HASS: Completed initialization in 5.0s 2025-06-05 21:34:32.695676 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-05 21:34:32.695888 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-05 21:34:32.697151 INFO AppDaemon: Calling initialize() for hello_world 2025-06-05 21:34:32.697904 INFO hello_world: Hello from AppDaemon 2025-06-05 21:34:32.698271 INFO hello_world: You are now ready to run Apps! 2025-06-05 21:34:32.776298 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-05 21:34:32.776673 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-05 21:34:32.777012 INFO HASS: Waiting for Home Assistant to start 2025-06-05 21:34:32.832512 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-05 21:34:32.835386 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-05 21:34:32.835550 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-05 21:34:37.744273 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-05 21:34:37.744793 INFO HASS: Completed initialization in 5.0s 2025-06-05 21:34:37.746347 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-05 21:34:37.746472 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-05 21:34:37.747079 INFO AppDaemon: Calling initialize() for hello_world 2025-06-05 21:34:37.747550 INFO hello_world: Hello from AppDaemon 2025-06-05 21:34:37.747808 INFO hello_world: You are now ready to run Apps! 2025-06-05 21:34:37.834434 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-05 21:34:37.834800 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-05 21:34:37.835162 INFO HASS: Waiting for Home Assistant to start 2025-06-05 21:34:37.877278 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-05 21:34:37.879297 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-05 21:34:37.879471 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-05 21:34:42.810542 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-05 21:34:42.811268 INFO HASS: Completed initialization in 5.0s 2025-06-05 21:34:42.813958 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-05 21:34:42.814149 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-05 21:34:42.815320 INFO AppDaemon: Calling initialize() for hello_world 2025-06-05 21:34:42.816019 INFO hello_world: Hello from AppDaemon 2025-06-05 21:34:42.816303 INFO hello_world: You are now ready to run Apps! 2025-06-05 21:34:42.967822 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-05 21:34:42.968411 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-05 21:34:42.968940 INFO HASS: Waiting for Home Assistant to start 2025-06-05 21:34:43.016316 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-05 21:34:43.018248 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-05 21:34:43.018347 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-05 21:34:47.855235 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-05 21:34:47.855856 INFO HASS: Completed initialization in 5.0s 2025-06-05 21:34:47.857585 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-05 21:34:47.857707 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-05 21:34:47.858319 INFO AppDaemon: Calling initialize() for hello_world 2025-06-05 21:34:47.858802 INFO hello_world: Hello from AppDaemon 2025-06-05 21:34:47.859102 INFO hello_world: You are now ready to run Apps! 2025-06-05 21:34:48.017674 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-05 21:34:48.018027 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-05 21:34:48.018372 INFO HASS: Waiting for Home Assistant to start 2025-06-05 21:34:48.039992 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-05 21:34:48.040079 WARNING AppDaemon: Unexpected error during process_event() 2025-06-05 21:34:48.040126 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-05 21:34:48.040945 WARNING AppDaemon: Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/appdaemon/events.py", line 236, in process_event self.AD.state.set_state_simple(namespace, entity_id, data["data"]["new_state"]) File "/usr/local/lib/python3.12/site-packages/appdaemon/state.py", line 778, in set_state_simple if self.entity_exists(namespace, entity_id): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/appdaemon/state.py", line 473, in entity_exists return namespace in self.state and entity in self.state[namespace] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: argument of type 'NoneType' is not iterable

2025-06-05 21:34:48.041098 WARNING AppDaemon: { "event_type": "state_changed", "data": { "entity_id": "sensor.ha_text_ai_deepseek", "old_state": { "entity_id": "sensor.ha_text_ai_deepseek", "state": "ready", "attributes": { "model": "deepseek-chat", "api_provider": "deepseek", "api_status": "ready", "total_errors": 0, "instance_name": "deepseek", "normalized_name": "deepseek", "is_processing": false, "is_rate_limited": false, "is_maintenance": false, "endpoint_status": "ready", "uptime": 7842.24, "history_size": 0, "total_tokens": 27, "prompt_tokens": 8, "completion_tokens": 19, "successful_requests": 1, "failed_requests": 0, "average_latency": 4.77, "max_latency": 4.77, "min_latency": 4.773988, "response": "", "question": "", "last_model": "deepseek-chat", "last_timestamp": "2025-06-05T17:24:04.783230+00:00", "icon": "mdi:robot", "friendly_name": "HA Text AI deepseek" }, "last_changed": "2025-06-05T17:24:13.703682+00:00", "last_reported": "2025-06-05T19:34:47.026762+00:00", "last_updated": "2025-06-05T19:34:47.026762+00:00", "context": { "id": "01JX0SDEZJKF8PGPYX1YYEYZK4", "parent_id": null, "user_id": null } }, "new_state": { "entity_id": "sensor.ha_text_ai_deepseek", "state": "ready", "attributes": { "model": "deepseek-chat", "api_provider": "deepseek", "api_status": "ready", "total_errors": 0, "instance_name": "deepseek", "normalized_name": "deepseek", "is_processing": false, "is_rate_limited": false, "is_maintenance": false, "endpoint_status": "ready", "uptime": 7843.24, "history_size": 0, "total_tokens": 27, "prompt_tokens": 8, "completion_tokens": 19, "successful_requests": 1, "failed_requests": 0, "average_latency": 4.77, "max_latency": 4.77, "min_latency": 4.773988, "response": "", "question": "", "last_model": "deepseek-chat", "last_timestamp": "2025-06-05T17:24:04.783230+00:00", "icon": "mdi:robot", "friendly_name": "HA Text AI deepseek" }, "last_changed": "2025-06-05T17:24:13.703682+00:00", "last_reported": "2025-06-05T19:34:48.026999+00:00", "last_updated": "2025-06-05T19:34:48.026999+00:00", "context": { "id": "01JX0SDFYT89HTHQ790NV38DEB", "parent_id": null, "user_id": null } }, "metadata": { "origin": "LOCAL", "time_fired": "2025-06-05T19:34:48.026999+00:00", "context": { "id": "01JX0SDFYT89HTHQ790NV38DEB", "parent_id": null, "user_id": null } } } } 2025-06-05 21:34:48.041166 WARNING AppDaemon: ------------------------------------------------------------ 2025-06-05 21:34:48.070290 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2025-06-05 21:34:48.072330 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed 2025-06-05 21:34:48.072443 INFO AppDaemon: Stopping apps: {'hello_world'} 2025-06-05 21:34:52.989376 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5} 2025-06-05 21:34:52.990275 INFO HASS: Completed initialization in 5.0s 2025-06-05 21:34:52.993252 INFO AppDaemon: Processing restart for plugin namespace 'default' 2025-06-05 21:34:52.993500 INFO AppDaemon: Starting apps: {'hello_world'} 2025-06-05 21:34:52.994703 INFO AppDaemon: Calling initialize() for hello_world 2025-06-05 21:34:52.995588 INFO hello_world: Hello from AppDaemon 2025-06-05 21:34:52.995998 INFO hello_world: You are now ready to run Apps! 2025-06-05 21:34:53.071814 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket 2025-06-05 21:34:53.072307 INFO HASS: Authenticated to Home Assistant 2025.5.3 2025-06-05 21:34:53.072881 INFO HASS: Waiting for Home Assistant to start

More Logs:

2025-06-05 21:48:29.105531 WARNING HASS: ------------------------------------------------------------ 2025-06-05 21:48:29.670513 WARNING HASS: ------------------------------------------------------------ 2025-06-05 21:48:29.670603 WARNING HASS: Unexpected error during websocket send 2025-06-05 21:48:29.670642 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, in websocket_send_json await self.ws.send_json(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 259, in send_json await self.send_str(dumps(data), compress=compress) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 243, in send_str await self._writer.send_frame( File "/usr/local/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame raise ClientConnectionResetError("Cannot write to closing transport") aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

2025-06-05 21:48:29.670678 WARNING HASS: ------------------------------------------------------------ 2025-06-05 21:48:29.690219 WARNING HASS: Previous message repeated 1 times 2025-06-05 21:48:29.690279 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, in websocket_send_json await self.ws.send_json(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 259, in send_json await self.send_str(dumps(data), compress=compress) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 243, in send_str await self._writer.send_frame( File "/usr/local/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame raise ClientConnectionResetError("Cannot write to closing transport") aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

2025-06-05 21:48:29.690318 WARNING HASS: ------------------------------------------------------------ 2025-06-05 21:48:29.754941 WARNING HASS: Previous message repeated 1 times 2025-06-05 21:48:29.755036 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, in websocket_send_json await self.ws.send_json(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 259, in send_json await self.send_str(dumps(data), compress=compress) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 243, in send_str await self._writer.send_frame( File "/usr/local/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame raise ClientConnectionResetError("Cannot write to closing transport") aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

2025-06-05 21:48:29.755075 WARNING HASS: ------------------------------------------------------------ 2025-06-05 21:48:29.782703 WARNING HASS: Previous message repeated 1 times 2025-06-05 21:48:29.782792 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, in websocket_send_json await self.ws.send_json(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 259, in send_json await self.send_str(dumps(data), compress=compress) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 243, in send_str await self._writer.send_frame( File "/usr/local/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame raise ClientConnectionResetError("Cannot write to closing transport") aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

2025-06-05 21:48:29.782830 WARNING HASS: ------------------------------------------------------------ 2025-06-05 21:48:30.292787 WARNING HASS: ------------------------------------------------------------ 2025-06-05 21:48:30.292873 WARNING HASS: Unexpected error during websocket send 2025-06-05 21:48:30.292913 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, in websocket_send_json await self.ws.send_json(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 259, in send_json await self.send_str(dumps(data), compress=compress) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 243, in send_str await self._writer.send_frame( File "/usr/local/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame raise ClientConnectionResetError("Cannot write to closing transport") aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

2025-06-05 21:48:30.292948 WARNING HASS: ------------------------------------------------------------ 2025-06-05 21:48:30.315518 WARNING HASS: Previous message repeated 1 times 2025-06-05 21:48:30.315592 WARNING HASS: ------------------------------------------------------------ Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper result = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, in websocket_send_json await self.ws.send_json(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 259, in send_json await self.send_str(dumps(data), compress=compress) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 243, in send_str await self._writer.send_frame( File "/usr/local/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame raise ClientConnectionResetError("Cannot write to closing transport") aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

2025-06-05 21:48:30.315631 WARNING HASS: ------------------------------------------------------------ 2025-06-05 21:48:30.409683 WARNING HASS: Previous message repeated 1 times 2025-06-05 21:48:30.409769 WARNING HASS: ------------------------------------------------------------

However, I have made a few observations: My main Home Assistant instance works without issues with 4.4.2, but not with 4.5.x. I have now created a new small test instance with a Home Assistant Docker image. AppDaemon 4.5.x runs on that one too?? I can't explain why that is. My main instance is admittedly relatively large. I don't know if that makes a difference.

Image

(I also tested NodeRed because I thought it also uses WebSocket connections. That works fine too.)

collateral87 avatar Jun 05 '25 19:06 collateral87

Thanks we will keep plugging away on this. It's good to know that a clean install works with 4.5.x for you - but I still want to figure out what is going wrong here.

acockburn avatar Jun 05 '25 19:06 acockburn

I'm not sure how to do this, but starting up AppDaemon with "-D DEBUG" added to the command line would tell us why the repeated disconnections are happening - the rest is probably related to bad things happening while AD is disconnected. If that's not possible, we will add a way to do it in `AppDaemon.yaml'

acockburn avatar Jun 05 '25 19:06 acockburn

Here my logs with "-D DEBUG" on AD 4.5.9

logs.txt

collateral87 avatar Jun 05 '25 20:06 collateral87

I want to contribute in whatever way to test, BUT: How do I find 4.5.9, and more importantly, how do I install it? I also want the possibility to downgrade to 4.4 where it seems to work. No matter where I look, I cannot find documentation about this. I just uninstalled my 4.5.8 version (the one that continually crashes immediately after start). I kept my data, restarted HA, installed Appdaemon (no chance to choose version), and the error persists. Continually crashes.

MacValley avatar Jun 06 '25 08:06 MacValley

I want to contribute in whatever way to test, BUT: How do I find 4.5.9, and more importantly, how do I install it? I also want the possibility to downgrade to 4.4 where it seems to work. No matter where I look, I cannot find documentation about this. I just uninstalled my 4.5.8 version (the one that continually crashes immediately after start). I kept my data, restarted HA, installed Appdaemon (no chance to choose version), and the error persists. Continually crashes.

4.5.9 was pulled so you'll need to wait for the next. If you are using the addon you can go back to 4.4.2 if you have a backup? I do not use the backup in HA but I belive you can restore just the addon?

Pythm avatar Jun 06 '25 08:06 Pythm

We will be releasing 4.5.10 later today. Analysis of the debug log provided by @collateral87 seems to point to disconnections on the HASS side, causing AD to restart the apps cyclically. We know the connection is established and we are able to gather initial information, but it seems to disconnect shortly after. Are there any errors you are seeing on the HASS side? Since this is running as an add-on I don't see how it can be a networking issue.

acockburn avatar Jun 06 '25 14:06 acockburn

In response to your message that it has something to do with my Home Assistant instance, I disabled all integrations and reactivated them step by step (it was really tedious 🙈) and found the culprit... Glances.

https://www.home-assistant.io/integrations/glances/

When I disable this integration, apdaemon starts and does not terminate the websocket connection. Something is not compatible with the AD versions starting from 4.5.0. Can you @acockburn explain what is going wrong here?

collateral87 avatar Jun 06 '25 18:06 collateral87

OK, great detective work - I have no idea why this would be the case, but it's definitely something to go on. Anything in the HASS logs that might help?

acockburn avatar Jun 06 '25 20:06 acockburn

Unfortunatly i found nothing

collateral87 avatar Jun 06 '25 21:06 collateral87

I think I have very similar problems with switching to AD 4.5.x. My setup is simple - HA 2025.1.4 (venv) and AD in docker. 4.4.2 worked without any issue (this setup has only telegram bot, no more other apps, but I commented apps.yaml for these tests). After I switched to 4.5.8 (for example), I'm getting constant reconnection via ws:

2025-06-10 23:14:09.017575 INFO AppDaemon: ------------------------------------------------------------
2025-06-10 23:14:09.019375 INFO AppDaemon: AppDaemon Version 4.5.8 starting
2025-06-10 23:14:09.019836 INFO AppDaemon: ------------------------------------------------------------
2025-06-10 23:14:09.020309 INFO AppDaemon: Python version is 3.12.10
2025-06-10 23:14:09.021820 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml
2025-06-10 23:14:09.022688 WARNING AppDaemon: Extra config field 'hass_timeout'. This will be ignored
2025-06-10 23:14:09.023160 INFO AppDaemon: Added log: AppDaemon
2025-06-10 23:14:09.023603 INFO AppDaemon: Added log: Error
2025-06-10 23:14:09.024004 INFO AppDaemon: Added log: Access
2025-06-10 23:14:09.024441 INFO AppDaemon: Added log: Diag
2025-06-10 23:14:09.027474 INFO AppDaemon: Using /conf/apps as app_dir
2025-06-10 23:14:09.030950 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module appdaemon.plugins.hass.hassplugin
2025-06-10 23:14:09.031941 INFO HASS: HASS Plugin initialization complete
2025-06-10 23:14:09.058976 INFO AppDaemon: HTTP configured but no consumers are configured - disabling
2025-06-10 23:14:09.070100 WARNING AppDaemon: Loaded an empty config file: apps/apps.yaml
2025-06-10 23:14:09.073083 INFO AppDaemon: Starting Apps with 0 workers and 0 pins
2025-06-10 23:14:09.073959 INFO AppDaemon: Waiting for plugins to be ready
2025-06-10 23:14:09.075582 INFO HASS: Connected to Home Assistant 2025.1.4 with aiohttp websocket
2025-06-10 23:14:09.079291 INFO HASS: Authenticated to Home Assistant 2025.1.4
2025-06-10 23:14:09.083519 INFO HASS: Waiting for Home Assistant to start
2025-06-10 23:14:09.092912 INFO AppDaemon: All plugins ready
2025-06-10 23:14:09.097229 INFO AppDaemon: Scheduler running in realtime
2025-06-10 23:14:09.243125 INFO AppDaemon: App initialization complete
2025-06-10 23:14:09.306611 WARNING HASS: Disconnected from Home Assistant, retrying in 10 seconds
2025-06-10 23:14:09.344151 INFO AppDaemon: Previous message repeated 1 times
2025-06-10 23:14:09.344752 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-06-10 23:14:19.319332 INFO HASS: Connected to Home Assistant 2025.1.4 with aiohttp websocket
2025-06-10 23:14:19.324343 INFO HASS: Authenticated to Home Assistant 2025.1.4
2025-06-10 23:14:19.329843 INFO HASS: Waiting for Home Assistant to start
2025-06-10 23:14:19.524722 WARNING HASS: Disconnected from Home Assistant, retrying in 10 seconds
2025-06-10 23:14:19.578858 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
...
2025-06-10 23:15:09.100932 WARNING HASS: ------------------------------------------------------------
2025-06-10 23:15:09.101971 WARNING HASS: Unexpected error during websocket send
2025-06-10 23:15:09.102853 WARNING HASS: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, in websocket_send_json
    await self.ws.send_json(request)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 259, in send_json
    await self.send_str(dumps(data), compress=compress)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_ws.py", line 243, in send_str
    await self._writer.send_frame(
  File "/usr/local/lib/python3.12/site-packages/aiohttp/_websocket/writer.py", line 73, in send_frame
    raise ClientConnectionResetError("Cannot write to closing transport")
aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

and later I see such messages:

2025-06-10 23:15:41.121271 WARNING AppDaemon: ------------------------------------------------------------
2025-06-10 23:15:41.121974 WARNING AppDaemon: Unexpected error during process_event()
2025-06-10 23:15:41.122605 WARNING AppDaemon: ------------------------------------------------------------
2025-06-10 23:15:41.126353 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/appdaemon/events.py", line 234, in process_event
    self.AD.state.set_state_simple(namespace, entity_id, data["data"]["new_state"])
  File "/usr/local/lib/python3.12/site-packages/appdaemon/state.py", line 777, in set_state_simple
    if self.entity_exists(namespace, entity_id):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/appdaemon/state.py", line 473, in entity_exists
    return namespace in self.state and entity in self.state[namespace]
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

2025-06-10 23:15:41.127456 WARNING AppDaemon: {
    "event_type": "state_changed",
    "data": {
        "entity_id": "sensor.d25_power",
        "old_state": {
            "entity_id": "sensor.d25_power",
...
2025-06-10 23:16:45.781796 WARNING AppDaemon: ------------------------------------------------------------
2025-06-10 23:16:45.895829 INFO AppDaemon: Previous message repeated 1 times
2025-06-10 23:16:45.896950 WARNING AppDaemon: Unexpected error during process_event()
2025-06-10 23:16:45.897972 WARNING AppDaemon: ------------------------------------------------------------
2025-06-10 23:16:45.901078 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/appdaemon/events.py", line 234, in process_event
    self.AD.state.set_state_simple(namespace, entity_id, data["data"]["new_state"])
  File "/usr/local/lib/python3.12/site-packages/appdaemon/state.py", line 777, in set_state_simple
    if self.entity_exists(namespace, entity_id):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/appdaemon/state.py", line 473, in entity_exists
    return namespace in self.state and entity in self.state[namespace]
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

Looks like it finally fetched some data but why it falls into error? With 4.5.10 I have similar picture. My config is:

secrets: /home/homeassistant/.homeassistant/secrets.yaml
logs:
  main_log:
    filename: /home/homeassistant/.homeassistant/appdaemon.log
  error_log:
    filename: /home/homeassistant/.homeassistant/appdaemon-error.log
#    filename: STDERR

appdaemon:
#  threads: 5
  time_zone: Europe/Kyiv
  latitude: 48.492640
  longitude: 35.138802
  elevation: 70
  plugins:
    HASS:
      type: hass
      ha_url: http://172.18.0.1:8123
      token: !secret appdaemon_token

      # умови на перший конект ПІСЛЯ рестарту HA
      plugin_startup_conditions:
        delay: 20                      # дати HA 20 с спокою
        event:                         # чекати офіц. подію
          event_type: homeassistant_started

      # решта опцій – РІВНЯ plugin, а не всередині conditions
      ws_timeout: 90                   # 60 с на get_states
      hass_timeout: 90
      retry_secs: 10                   # пауза між ретраями

#hadashboard:
#  dash_url: http://127.0.0.1:5050
#  #dash_password: !secret dash_password
#  dashboard_dir: /home/serge/dev/ha/homeassistant/dashboards/
#  #dash_compile_on_start: 1
#  #dash_force_compile: 1

http:
  url: http://127.0.0.1:5050

I added plugin_startup_conditions settings per chatgpt recommendation, they don't help anyway. My docker-compose:

  appdaemon:
    container_name: appdaemon
    restart: unless-stopped
    build:
      context: appdaemon
      dockerfile: Dockerfile
    ports:
      - "5050:5050"
    volumes:
      # Set which local directory will contain all your app daemon configuration
      - /home/homeassistant/.homeassistant/:/conf
...
    user: "${APPD_USER}:${APPD_GROUP}"

and I override build with some simple Dockerfile (I need some packages inside):

#FROM acockburn/appdaemon:4.4.2
FROM acockburn/appdaemon:4.5.10
RUN apk add bash ffmpeg mosquitto-clients
COPY xDockerStart.sh /usr/src/app/
RUN chmod +x /usr/src/app/xDockerStart.sh
ENTRYPOINT [ "./xDockerStart.sh" ]

and xDockerStart.sh has just umask:

#!/bin/sh
umask 002
exec ./dockerStart.sh

That's all. Hope this is helpful? Please let me know if you need any more info. Thanks in advance!

sergeolkhovik avatar Jun 10 '25 20:06 sergeolkhovik

Are you using the glances integration?

acockburn avatar Jun 10 '25 20:06 acockburn

Yes, glances are used to gather data from other home PCs but I don't use glances on this mini PC that hosts both HA and AD.

sergeolkhovik avatar Jun 11 '25 08:06 sergeolkhovik

Today I've updated AD to v4.5.10 and I don't use glances in my setup. I am using the System Monitor integration to retrieve details from the machine running it all. I've tried disabling that integration, but I see the same errors (see attached log file).

Next week I'll have some time to try disabling all my integrations and enabling one by one to see if I can find something similar as @collateral87.

_appdaemon_logs.txt

AdeZwart avatar Jun 13 '25 11:06 AdeZwart