AppDaemon stopped working after a system reboot

I did a reboot of my system, and after it started up again, nothing AppDaemon is working.

When I restart AppDaemon, I see:

2022-03-27 10:07:10.058842 WARNING notify_trash_pickup: notify_trash_pickup: Entity sensor.trash_pickup not found in namespace default
2022-03-27 10:07:10.063822 WARNING leaving_notifications: leaving_notifications: Entity binary_sensor.openclose_basement_entrance_door not found in namespace default
2022-03-27 10:07:10.066199 WARNING leaving_notifications: leaving_notifications: Entity binary_sensor.openclose_front_door not found in namespace default
2022-03-27 10:07:10.070789 WARNING motion_door_window_notify: ------------------------------------------------------------
2022-03-27 10:07:10.071256 WARNING motion_door_window_notify: Unexpected error running initialize() for motion_door_window_notify
2022-03-27 10:07:10.071780 WARNING motion_door_window_notify: ------------------------------------------------------------
2022-03-27 10:07:10.073811 WARNING motion_door_window_notify: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/appdaemon/app_management.py", line 165, in initialize_app
    await utils.run_in_executor(self, init)
  File "/usr/lib/python3.9/site-packages/appdaemon/utils.py", line 337, in run_in_executor
    response = future.result()
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/appdaemon/apps/notify/motion_door_window_notify.py", line 13, in initialize
    self.motionSensors = self.app_config['global_sensors']['motion_sensors']
KeyError: 'global_sensors'
2022-03-27 10:07:10.074271 WARNING motion_door_window_notify: ------------------------------------------------------------
2022-03-27 10:07:10.079322 WARNING dontkillthebaby: dontkillthebaby: Entity binary_sensor.baby_safety_dining_room not found in namespace default
2022-03-27 10:07:10.085599 WARNING AppDaemon: Unable to find module global_entities - initialize() skipped
2022-03-27 10:07:10.086365 WARNING AppDaemon: Unable to find module global_functions - initialize() skipped
2022-03-27 10:07:10.127217 WARNING awake: awake: Entity binary_sensor.aephir_in_bed not found in namespace default
2022-03-27 10:07:10.129961 WARNING awake: awake: Entity binary_sensor.kristina_in_bed not found in namespace default
2022-03-27 10:07:10.169327 WARNING doors_or_windows_open: doors_or_windows_open: Entity binary_sensor.openclose_bedroom_window_1 not found in namespace default
2022-03-27 10:07:10.172458 WARNING doors_or_windows_open: doors_or_windows_open: Entity binary_sensor.openclose_bathroom_window not found in namespace default
2022-03-27 10:07:10.175441 WARNING doors_or_windows_open: doors_or_windows_open: Entity binary_sensor.openclose_washing_room_window_1 not found in namespace default
2022-03-27 10:07:10.178765 WARNING doors_or_windows_open: doors_or_windows_open: Entity binary_sensor.openclose_basement_entrance_door not found in namespace default
2022-03-27 10:07:10.181059 WARNING doors_or_windows_open: doors_or_windows_open: Entity binary_sensor.openclose_front_door not found in namespace default
2022-03-27 10:07:10.183269 WARNING doors_or_windows_open: doors_or_windows_open: Entity binary_sensor.door_window_sensor_158d000234dc7b not found in namespace default
2022-03-27 10:07:10.185565 WARNING doors_or_windows_open: doors_or_windows_open: Entity binary_sensor.openclose_bedroom_window_1 not found in namespace default
2022-03-27 10:07:10.187935 WARNING doors_or_windows_open: doors_or_windows_open: Entity binary_sensor.openclose_bathroom_window not found in namespace default
2022-03-27 10:07:10.190336 WARNING doors_or_windows_open: doors_or_windows_open: Entity binary_sensor.openclose_washing_room_window_1 not found in namespace default
2022-03-27 10:07:10.195440 WARNING convert_3d_print_time: convert_3d_print_time: Entity sensor.prusa_i3_mk3s_time_elapsed not found in namespace default
2022-03-27 10:07:10.198593 WARNING convert_3d_print_time: convert_3d_print_time: Entity sensor.prusa_i3_mk3s_time_remaining not found in namespace default
2022-03-27 10:07:10.253139 INFO workday: input_boolean.vacation_mode
2022-03-27 10:07:10.375721 WARNING meta_tracker: ------------------------------------------------------------
2022-03-27 10:07:10.376175 WARNING meta_tracker: Unexpected error running initialize() for meta_tracker
2022-03-27 10:07:10.376436 WARNING meta_tracker: ------------------------------------------------------------
2022-03-27 10:07:10.378568 WARNING meta_tracker: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/appdaemon/app_management.py", line 165, in initialize_app
    await utils.run_in_executor(self, init)
  File "/usr/lib/python3.9/site-packages/appdaemon/utils.py", line 337, in run_in_executor
    response = future.result()
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/appdaemon/apps/device_tracker/meta_device_tracker.py", line 45, in initialize
    self.where_are_we(None, None, None, None, None)
  File "/config/appdaemon/apps/device_tracker/meta_device_tracker.py", line 92, in where_are_we
    new_state = self.get_state(triggered_entity).lower()
AttributeError: 'dict' object has no attribute 'lower'
2022-03-27 10:07:10.379626 WARNING meta_tracker: ------------------------------------------------------------
2022-03-27 10:07:10.402584 WARNING dryer_finished: dryer_finished: Entity sensor.wemo_insight_01_current_power not found in namespace default
2022-03-27 10:07:10.464497 WARNING test: ------------------------------------------------------------
2022-03-27 10:07:10.464973 WARNING test: Unexpected error running initialize() for test
2022-03-27 10:07:10.465913 WARNING test: ------------------------------------------------------------
2022-03-27 10:07:10.471565 WARNING test: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/appdaemon/app_management.py", line 165, in initialize_app
    await utils.run_in_executor(self, init)
  File "/usr/lib/python3.9/site-packages/appdaemon/utils.py", line 337, in run_in_executor
    response = future.result()
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/appdaemon/apps/test/test.py", line 9, in initialize
    self.listen_state("input_boolean.vacation_mode")
  File "/usr/lib/python3.9/site-packages/appdaemon/utils.py", line 226, in inner_sync_wrapper
    f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
  File "/usr/lib/python3.9/site-packages/appdaemon/utils.py", line 346, in run_coroutine_threadsafe
    result = future.result(self.AD.internal_function_timeout)
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 445, in result
    return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result
    raise self._exception
  File "/usr/lib/python3.9/site-packages/appdaemon/adapi.py", line 1399, in listen_state
    return await self.get_entity_api(namespace, entity_id).listen_state(callback, **kwargs)
  File "/usr/lib/python3.9/site-packages/appdaemon/entity.py", line 271, in listen_state
    return await self.AD.state.add_state_callback(name, namespace, entity_id, callback, kwargs)
  File "/usr/lib/python3.9/site-packages/appdaemon/state.py", line 266, in add_state_callback
    "function": cb.__name__,
AttributeError: 'str' object has no attribute '__name__'
2022-03-27 10:07:10.471948 WARNING test: ------------------------------------------------------------
2022-03-27 10:07:10.529929 INFO AppDaemon: App initialization complete
Exception in thread thread-29:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.9/site-packages/appdaemon/threading.py", line 891, in worker
    callback = "{}() in {}".format(funcref.__name__, name)
AttributeError: 'str' object has no attribute '__name__'
2022-03-27 10:07:11.872192 CRITICAL AppDaemon: Thread thread-29 has died
2022-03-27 10:07:11.873992 CRITICAL AppDaemon: Pinned apps were: ['test']
2022-03-27 10:07:11.874827 CRITICAL AppDaemon: Thread will be restarted
2022-03-27 10:07:11.875513 INFO AppDaemon: Adding thread 29
2022-03-27 10:07:13.122986 CRITICAL AppDaemon: Thread thread-29 has died
2022-03-27 10:07:13.123540 CRITICAL AppDaemon: Pinned apps were: ['test']
2022-03-27 10:07:13.123980 CRITICAL AppDaemon: Thread will be restarted
2022-03-27 10:07:13.124304 INFO AppDaemon: Adding thread 29

The complaint about not found in namespace default is mostly about things (sensors, etc.) that I create with AppDaemon, so since AppDaemon doesn’t work, of course it can’t create or find them.

The last part (the test app) repeats for a while, and finally the following repeats in perpetuity:

```2022-03-27 10:09:27.661029 WARNING AppDaemon: ------------------------------------------------------------ 2022-03-27 10:09:28.820276 WARNING AppDaemon: ------------------------------------------------------------ 2022-03-27 10:09:28.821731 WARNING AppDaemon: Unexpected error during utility() 2022-03-27 10:09:28.822119 WARNING AppDaemon: ------------------------------------------------------------ 2022-03-27 10:09:28.823392 WARNING AppDaemon: Traceback (most recent call last): File "/usr/lib/python3.9/site-packages/appdaemon/utility_loop.py", line 163, in loop (warning_step, warning_iterations,) = await self.AD.threading.check_q_size( File "/usr/lib/python3.9/site-packages/appdaemon/threading.py", line 328, in check_q_size iso8601.parse_date( File "/usr/lib/python3.9/site-packages/iso8601/iso8601.py", line 127, in parse_date raise ParseError(f"Unable to parse date string {datestring!r}") iso8601.iso8601.ParseError: Unable to parse date string 'never' ```

Any idea what happened? And why a system reboot would mess something up in a HassOS VM add-on? It worked fine minutes before the reboot…

I’m using the add-on (v. 0.8.2) on HassOS (v 5.10.103) with Hass core v 2022.3.7.

So, with a bit of help from @proggie on the discord channel, I found the problem. A typo in a test app I wasn’t using.

I had:
self.listen_state("input_boolean.vacation_mode") instead of
self.listen_state(self.test, "input_boolean.vacation_mode")).

And combined with the fact that removing the app didn’t help until I fixed the problem AND did a restart of the AppDaemon Add on. Tried both, but no luck until I did both together.