Skip to content

AppDaemon 4.5.11 constantly disconnects from HA Core 2025.7.1 with "TypeError: argument of type 'NoneType' is not iterable" #2399

@frido100

Description

@frido100

What happened?

Umgebungsinformationen:

  • AppDaemon Add-on Version: 0.17.7 (AppDaemon 4.5.11)
  • Home Assistant OS Version: 16.0 (amd64 / generic-x86-64)
  • Home Assistant Core Version: 2025.7.1
  • Home Assistant Supervisor Version: 2025.07.1
  • Host-System: Dedizierter Intel NUC (läuft unter Proxmox, aber HA OS ist direkt auf dem NUC installiert).
  • Python Version: 3.12.11 (aus AppDaemon Log)

Problembeschreibung:

Das AppDaemon Add-on startet erfolgreich, verbindet sich mit Home Assistant Core und authentifiziert sich. Kurz danach trennt es die Verbindung mit WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds und einem ClientConnectionResetError. Dieser Zyklus wiederholt sich ständig, wodurch AppDaemon unbrauchbar ist.

Im Log ist zu sehen, dass diesen Disconnects regelmäßig ein TypeError: argument of type 'NoneType' is not iterable vorausgeht. Dieser TypeError tritt in der internen AppDaemon-Logik (specifically in appdaemon/state.py bei entity_exists) auf, wenn versucht wird, einen state_changed-Event zu verarbeiten.

Es scheint sich nicht um ein Problem mit einer spezifischen Entität zu handeln, da der TypeError durch verschiedene Entitäten ausgelöst wurde (z.B. sensor.ann_kathrin_15_buetooth_distance, sensor.mi_hub_undefinedtype_singleton, sensor.shellyplug_s_80646f83ea7c_power). Dies deutet auf ein generelles Timing- oder Initialisierungsproblem in AppDaemon bei der Verarbeitung von state_changed-Events beim Start oder Reconnect hin, bei dem die interne Status-Struktur temporär inkonsistent ist (NoneType statt eines iterierbaren Objekts).

Bereits durchgeführte Fehlerbehebungsschritte (ohne Erfolg):

  • Kompletter Neustart des Home Assistant Host-Systems (NUC).
  • AppDaemon Add-on deinstalliert und neu installiert.
  • Neues Long-Lived Access Token für AppDaemon generiert und in der Add-on-Konfiguration hinterlegt.
  • ha_url in appdaemon.yaml wurde testweise auf http://supervisor/core geändert und auch komplett auskommentiert, um die automatische Erkennung zu nutzen – Problem bleibt bestehen.
  • Die app_init_delay, appdaemon_startup_conditions und plugin_startup_conditions wurden in appdaemon.yaml schrittweise erhöht (bis zu 60/45/30 Sekunden) – Problem bleibt bestehen.
  • Temporäre Deaktivierung der im Log genannten Entitäten (sensor.ann_kathrin_15_buetooth_distance, sensor.mi_hub_undefinedtype_singleton, sensor.shellyplug_s_80646f83ea7c_power) – der TypeError wird dann von anderen Entitäten ausgelöst, das Problem bleibt bestehen.

appdaemon.yaml Konfiguration:

appdaemon:
  latitude: 50.1833
  longitude: 8.4833
  elevation: 350
  time_zone: Europe/Berlin
  plugins:
    HASS:
      type: hass
      # ha_url: [http://10.0.0.157:8123](http://10.0.0.157:8123) # Diese Zeile wurde testweise auskommentiert
      token: !secret appdaemon_token # Token ist korrekt und aktuell
      retry_secs: 10
      ws_timeout: 30
      app_init_delay: 20 # Ursprünglicher Wert, wurde testweise erhöht
      appdaemon_startup_conditions:
        delay: 15 # Ursprünglicher Wert, wurde testweise erhöht
        event:
          event_type: homeassistant_started
      plugin_startup_conditions:
        delay: 10 # Ursprünglicher Wert, wurde testweise erhöht
        event:
          event_type: homeassistant_started



### Version

4.5.11

### Installation type

Home Assistant add-on

### Relevant log output

```sh
Home Assistant Supervisor: 2025.07.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-appdaemon: starting
s6-rc: info: service init-appdaemon successfully started
s6-rc: info: service appdaemon: starting
s6-rc: info: service appdaemon successfully started
s6-rc: info: service legacy-services: starting
[09:54:12] INFO: Starting AppDaemon...
s6-rc: info: service legacy-services successfully started
2025-07-11 09:54:17.777698 INFO AppDaemon: ------------------------------------------------------------
2025-07-11 09:54:17.778293 INFO AppDaemon: AppDaemon Version 4.5.11 starting
2025-07-11 09:54:17.778466 INFO AppDaemon: ------------------------------------------------------------
2025-07-11 09:54:17.778599 INFO AppDaemon: Python version is 3.12.11
2025-07-11 09:54:17.779028 INFO AppDaemon: Configuration read from: /config/appdaemon.yaml
2025-07-11 09:54:17.779260 INFO AppDaemon: Added log: AppDaemon
2025-07-11 09:54:17.779409 INFO AppDaemon: Added log: Error
2025-07-11 09:54:17.779529 INFO AppDaemon: Added log: Access
2025-07-11 09:54:17.779635 INFO AppDaemon: Added log: Diag
2025-07-11 09:54:17.780638 INFO AppDaemon: Using /config/apps as app_dir
2025-07-11 09:54:17.782063 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module appdaemon.plugins.hass.hassplugin
2025-07-11 09:54:17.782394 INFO HASS: HASS Plugin initialization complete
2025-07-11 09:54:17.789778 INFO AppDaemon: HTTP configured but no consumers are configured - disabling
2025-07-11 09:54:17.792939 WARNING AppDaemon: No apps found in /config/apps. This is probably a mistake
2025-07-11 09:54:17.793507 INFO AppDaemon: Starting Apps with 10 workers and 10 pins
2025-07-11 09:54:17.796125 INFO AppDaemon: Waiting for plugins to be ready
2025-07-11 09:54:17.797255 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:54:17.798275 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:54:17.799351 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:54:17.801398 INFO AppDaemon: All plugins ready
2025-07-11 09:54:17.802672 INFO AppDaemon: Scheduler running in realtime
2025-07-11 09:54:17.807248 INFO AppDaemon: App initialization complete
2025-07-11 09:54:17.887763 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:54:17.889414 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:54:22.890315 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:54:22.891224 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:54:22.892805 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:54:22.991242 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:54:22.993109 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:54:27.856658 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:54:27.857538 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:54:27.997326 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:54:27.998633 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:54:28.000156 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:54:28.082961 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:54:28.084741 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:54:32.958589 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:54:32.959181 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:54:32.960148 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:54:33.085064 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:54:33.085719 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:54:33.086331 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:54:33.142085 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:54:33.143657 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:54:38.053245 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:54:38.053924 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:54:38.055076 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:54:38.145045 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:54:38.145657 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:54:38.146303 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:54:38.209715 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:54:38.212155 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:54:43.121044 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:54:43.121743 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:54:43.122729 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:54:43.213118 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:54:43.213715 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:54:43.214354 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:54:43.266322 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:54:43.267819 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:54:48.187151 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:54:48.187856 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:54:48.188775 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:54:48.268693 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:54:48.269208 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:54:48.269847 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:54:48.316044 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:54:48.317368 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:54:53.248221 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:54:53.248804 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:54:53.249615 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:54:53.319607 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:54:53.320125 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:54:53.320803 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:54:53.380015 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:54:53.382349 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:54:58.298659 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:54:58.299438 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:54:58.300346 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:54:58.382124 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:54:58.383138 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:54:58.383807 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:54:58.418659 WARNING AppDaemon: ------------------------------------------------------------
2025-07-11 09:54:58.419025 WARNING AppDaemon: Unexpected error during process_event()
2025-07-11 09:54:58.419245 WARNING AppDaemon: ------------------------------------------------------------
2025-07-11 09:54:58.420655 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/appdaemon/events.py", line 239, 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 780, 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-07-11 09:54:58.421191 WARNING AppDaemon: {
    "event_type": "state_changed",
    "data": {
        "entity_id": "button.lumi_v3_1747_info",
        "old_state": {
            "entity_id": "button.lumi_v3_1747_info",
            "state": "2024-12-09T12:40:59.847797+00:00",
            "attributes": {
                "button.info": "Mi Hub",
                "model": "lumi.gateway.v3",
                "did": "78244769",
                "mac": "78:11:DC:AF:17:47",
                "lan_ip": "10.0.0.90",
                "app_link": "mihome://device?uid=1725410708&did=78244769",
                "miot_type": "urn:miot-spec-v2:device:gateway:0000A019:lumi-v3:2",
                "available": true,
                "home_room": "Meisenweg 10 Untergescho\u00df Flur",
                "icon": "mdi:information",
                "updater": "cloud",
                "updated_at": "2025-07-11 09:54:43.453329+02:00",
                "gateway.guard_mode": false,
                "alarm": false,
                "alarm.volume": 0,
                "light.on": false,
                "motion_sensor.illumination": 523,
                "state_updater": "cloud",
                "state_property": null,
                "converters": [
                    "button.info",
                    "light.light.on",
                    "switch.alarm",
                    "number.alarm.volume",
                    "sensor.motion_sensor.illumination"
                ],
                "customizes": {},
                "info": null,
                "device_class": "update",
                "friendly_name": "Mi Hub Info"
            },
            "last_changed": "2025-07-10T20:14:23.641430+00:00",
            "last_reported": "2025-07-11T07:54:43.453912+00:00",
            "last_updated": "2025-07-11T07:54:43.453912+00:00",
            "context": {
                "id": "01JZW7NFVX40E2VBV0N3WEBF3A",
                "parent_id": null,
                "user_id": null
            }
        },
        "new_state": {
            "entity_id": "button.lumi_v3_1747_info",
            "state": "2024-12-09T12:40:59.847797+00:00",
            "attributes": {
                "button.info": "Mi Hub",
                "model": "lumi.gateway.v3",
                "did": "78244769",
                "mac": "78:11:DC:AF:17:47",
                "lan_ip": "10.0.0.90",
                "app_link": "mihome://device?uid=1725410708&did=78244769",
                "miot_type": "urn:miot-spec-v2:device:gateway:0000A019:lumi-v3:2",
                "available": true,
                "home_room": "Meisenweg 10 Untergescho\u00df Flur",
                "icon": "mdi:information",
                "updater": "cloud",
                "updated_at": "2025-07-11 09:54:58.404348+02:00",
                "gateway.guard_mode": false,
                "alarm": false,
                "alarm.volume": 0,
                "light.on": false,
                "motion_sensor.illumination": 523,
                "state_updater": "cloud",
                "state_property": null,
                "converters": [
                    "button.info",
                    "light.light.on",
                    "switch.alarm",
                    "number.alarm.volume",
                    "sensor.motion_sensor.illumination"
                ],
                "customizes": {},
                "info": null,
                "device_class": "update",
                "friendly_name": "Mi Hub Info"
            },
            "last_changed": "2025-07-10T20:14:23.641430+00:00",
            "last_reported": "2025-07-11T07:54:58.404901+00:00",
            "last_updated": "2025-07-11T07:54:58.404901+00:00",
            "context": {
                "id": "01JZW7NYF4KN7WP59SV8VGY4B2",
                "parent_id": null,
                "user_id": null
            }
        },
        "metadata": {
            "time_fired": "2025-07-11T07:54:58.404901+00:00",
            "origin": "LOCAL",
            "context": {
                "id": "01JZW7NYF4KN7WP59SV8VGY4B2",
                "parent_id": null,
                "user_id": null
            }
        }
    }
}
2025-07-11 09:54:58.421423 WARNING AppDaemon: ------------------------------------------------------------
2025-07-11 09:54:58.440408 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:54:58.442016 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:55:03.357601 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:55:03.358291 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:55:03.359249 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:55:03.443994 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:55:03.444729 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:55:03.445473 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:55:03.502895 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:55:03.504338 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:55:08.418751 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:55:08.420247 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:55:08.423198 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:55:08.629706 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:55:08.643430 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:55:08.653928 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:55:08.809053 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:55:08.811616 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:55:13.479790 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:55:13.481256 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:55:13.483885 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:55:13.813611 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:55:13.816052 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:55:13.817492 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:55:13.985906 WARNING AppDaemon: ------------------------------------------------------------
2025-07-11 09:55:13.986211 WARNING AppDaemon: Unexpected error during process_event()
2025-07-11 09:55:13.986451 WARNING AppDaemon: ------------------------------------------------------------
2025-07-11 09:55:13.987296 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/appdaemon/events.py", line 239, 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 780, 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-07-11 09:55:13.987811 WARNING AppDaemon: {
    "event_type": "state_changed",
    "data": {
        "entity_id": "sensor.1006761d87a4c738_distance",
        "old_state": {
            "entity_id": "sensor.1006761d87a4c738_distance",
            "state": "2.4",
            "attributes": {
                "state_class": "measurement",
                "current_mac": "48:fe:1b:10:6e:82",
                "unit_of_measurement": "m",
                "device_class": "distance",
                "friendly_name": "Anna-Maria_Bluetooth Distance"
            },
            "last_changed": "2025-07-11T07:55:09.874449+00:00",
            "last_reported": "2025-07-11T07:55:09.874449+00:00",
            "last_updated": "2025-07-11T07:55:09.874449+00:00",
            "context": {
                "id": "01JZW7P9NJE30CR1AAKXZVHYS6",
                "parent_id": null,
                "user_id": null
            }
        },
        "new_state": {
            "entity_id": "sensor.1006761d87a4c738_distance",
            "state": "2.5",
            "attributes": {
                "state_class": "measurement",
                "current_mac": "48:fe:1b:10:6e:82",
                "unit_of_measurement": "m",
                "device_class": "distance",
                "friendly_name": "Anna-Maria_Bluetooth Distance"
            },
            "last_changed": "2025-07-11T07:55:13.887021+00:00",
            "last_reported": "2025-07-11T07:55:13.887021+00:00",
            "last_updated": "2025-07-11T07:55:13.887021+00:00",
            "context": {
                "id": "01JZW7PDJZ4F7Y6DNMVH8D18HD",
                "parent_id": null,
                "user_id": null
            }
        },
        "metadata": {
            "time_fired": "2025-07-11T07:55:13.887021+00:00",
            "origin": "LOCAL",
            "context": {
                "id": "01JZW7PDJZ4F7Y6DNMVH8D18HD",
                "parent_id": null,
                "user_id": null
            }
        }
    }
}
2025-07-11 09:55:13.988050 WARNING AppDaemon: ------------------------------------------------------------
2025-07-11 09:55:13.988391 WARNING AppDaemon: Previous message repeated 1 times
2025-07-11 09:55:13.988610 WARNING AppDaemon: ------------------------------------------------------------
2025-07-11 09:55:13.989395 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/appdaemon/events.py", line 239, 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 780, 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-07-11 09:55:13.989818 WARNING AppDaemon: {
    "event_type": "state_changed",
    "data": {
        "entity_id": "sensor.ann_kathrin_15_buetooth_distance",
        "old_state": {
            "entity_id": "sensor.ann_kathrin_15_buetooth_distance",
            "state": "2.7",
            "attributes": {
                "state_class": "measurement",
                "current_mac": "41:ee:af:cd:61:c4",
                "unit_of_measurement": "m",
                "device_class": "distance",
                "friendly_name": "Ann-Kathrin_15_Buetooth Distance"
            },
            "last_changed": "2025-07-11T07:55:07.877319+00:00",
            "last_reported": "2025-07-11T07:55:07.877319+00:00",
            "last_updated": "2025-07-11T07:55:07.877319+00:00",
            "context": {
                "id": "01JZW7P7Q52MC8C1CJ5DWV5MHJ",
                "parent_id": null,
                "user_id": null
            }
        },
        "new_state": {
            "entity_id": "sensor.ann_kathrin_15_buetooth_distance",
            "state": "2.4",
            "attributes": {
                "state_class": "measurement",
                "current_mac": "41:ee:af:cd:61:c4",
                "unit_of_measurement": "m",
                "device_class": "distance",
                "friendly_name": "Ann-Kathrin_15_Buetooth Distance"
            },
            "last_changed": "2025-07-11T07:55:13.893520+00:00",
            "last_reported": "2025-07-11T07:55:13.893520+00:00",
            "last_updated": "2025-07-11T07:55:13.893520+00:00",
            "context": {
                "id": "01JZW7PDK5KGEDGDZNFGRND5AR",
                "parent_id": null,
                "user_id": null
            }
        },
        "metadata": {
            "time_fired": "2025-07-11T07:55:13.893520+00:00",
            "origin": "LOCAL",
            "context": {
                "id": "01JZW7PDK5KGEDGDZNFGRND5AR",
                "parent_id": null,
                "user_id": null
            }
        }
    }
}
2025-07-11 09:55:13.990052 WARNING AppDaemon: ------------------------------------------------------------
2025-07-11 09:55:14.019658 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:55:14.021615 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:55:17.804363 WARNING HASS: ------------------------------------------------------------
2025-07-11 09:55:17.804692 WARNING HASS: Unexpected error during websocket send
2025-07-11 09:55:17.804947 WARNING HASS: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, 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-07-11 09:55:17.805273 WARNING HASS: ------------------------------------------------------------
2025-07-11 09:55:17.855855 WARNING HASS: Previous message repeated 1 times
2025-07-11 09:55:17.856142 WARNING HASS: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, 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-07-11 09:55:17.856475 WARNING HASS: ------------------------------------------------------------
2025-07-11 09:55:18.762651 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:55:18.763648 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:55:18.765167 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:55:19.022166 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:55:19.023004 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:55:19.023972 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:55:19.091216 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:55:19.093406 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:55:22.896536 WARNING HASS: ------------------------------------------------------------
2025-07-11 09:55:22.896916 WARNING HASS: Unexpected error during websocket send
2025-07-11 09:55:22.897189 WARNING HASS: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, 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-07-11 09:55:22.897551 WARNING HASS: ------------------------------------------------------------
2025-07-11 09:55:22.959500 WARNING HASS: Previous message repeated 1 times
2025-07-11 09:55:22.959850 WARNING HASS: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, 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-07-11 09:55:22.960124 WARNING HASS: ------------------------------------------------------------
2025-07-11 09:55:23.910716 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:55:23.911866 INFO HASS: Completed initialization in 4.9s
2025-07-11 09:55:23.913709 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:55:24.094821 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:55:24.095736 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:55:24.097059 INFO HASS: Waiting for Home Assistant to start
2025-07-11 09:55:24.188179 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
2025-07-11 09:55:24.190977 INFO AppDaemon: Stopping apps from namespace 'default' because the plugin failed
2025-07-11 09:55:28.004121 WARNING HASS: ------------------------------------------------------------
2025-07-11 09:55:28.004531 WARNING HASS: Unexpected error during websocket send
2025-07-11 09:55:28.004832 WARNING HASS: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, 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-07-11 09:55:28.005193 WARNING HASS: ------------------------------------------------------------
2025-07-11 09:55:28.052283 WARNING HASS: Previous message repeated 1 times
2025-07-11 09:55:28.052614 WARNING HASS: ------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/appdaemon/utils.py", line 483, in wrapper
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/appdaemon/plugins/hass/hassplugin.py", line 369, 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-07-11 09:55:28.052890 WARNING HASS: ------------------------------------------------------------
2025-07-11 09:55:29.068858 WARNING HASS: Timed out [0:00:10] waiting for request: {'type': 'get_states', 'id': 5}
2025-07-11 09:55:29.069869 INFO HASS: Completed initialization in 5.0s
2025-07-11 09:55:29.071436 INFO AppDaemon: Processing restart for plugin namespace 'default'
2025-07-11 09:55:29.192799 INFO HASS: Connected to Home Assistant 2025.7.1 with aiohttp websocket
2025-07-11 09:55:29.194595 INFO HASS: Authenticated to Home Assistant 2025.7.1
2025-07-11 09:55:29.196781 INFO HASS: Waiting for Home Assistant to start
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service appdaemon: stopping
2025-07-11 09:55:29.277463 INFO AppDaemon: SIGTERM Received
2025-07-11 09:55:29.277906 INFO AppDaemon: AppDaemon is shutting down
2025-07-11 09:55:29.310759 INFO HASS: Disconnecting from Home Assistant
2025-07-11 09:55:30.041001 INFO AppDaemon: Saving all namespaces
2025-07-11 09:55:30.041410 INFO AppDaemon: AppDaemon is stopped.
[09:55:30] INFO: Service AppDaemon exited with code 0 (by signal 0)
s6-rc: info: service appdaemon successfully stopped
s6-rc: info: service init-appdaemon: stopping
s6-rc: info: service init-appdaemon successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped

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

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions