hassio-addons / addon-appdaemon

AppDaemon4 - Home Assistant Community Add-ons
https://addons.community
MIT License
151 stars 47 forks source link

Namespace issue in latest version (0.11.0) #225

Closed randomletters closed 1 year ago

randomletters commented 1 year ago

Problem/Motivation

After updating AppDaemon to the latest version my custom namespace stopped working. It looks like it is not able to create the namespace during startup, so all my entities created under that namespace do not function as expected.

Expected behavior

During startup I create a custom namespace 'mynamespace' so I can take advantage of the persistent storage on custom entities. In the previous version (0.10.1) this functioned without error.

Actual behavior

Error shown below. Namespace not created and custom entities do not store data.

Steps to reproduce

Add a custom namespace to appdaemon.yaml

  namespaces:
    mynamespace:
      writeback: hybrid

Proposed changes

My current workaround is to downgrade appdaemon to 0.10.1 but I don't know how long that will work. I looked at the diff for the two versions and it seems that the only obvious change was python versions, but there are some utility scripts that changed as well. Is there a test which confirms namespace functionality?

Here is the error I get in the AppDaemon Log:

2023-01-09 12:34:29.411468 WARNING AppDaemon: ------------------------------------------------------------ 2023-01-09 12:34:30.440091 WARNING AppDaemon: ------------------------------------------------------------ 2023-01-09 12:34:30.440923 WARNING AppDaemon: Unexpected error during utility() 2023-01-09 12:34:30.441682 WARNING AppDaemon: ------------------------------------------------------------ 2023-01-09 12:34:30.442793 WARNING AppDaemon: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/appdaemon/utility_loop.py", line 173, in loop self.AD.state.save_hybrid_namespaces() File "/usr/lib/python3.10/site-packages/appdaemon/state.py", line 680, in save_hybrid_namespaces self.state[ns].sync() KeyError: 'mynamespace'

Justihar commented 1 year ago

You may want to take a look at this issue. https://github.com/AppDaemon/appdaemon/issues/1617

randomletters commented 1 year ago

Thank you. That helped.

The solution unfortunately involves deleting the stored data, but it allows the code to function.

Steps to fix:

Update appdaemon Goto terminal Goto appdaemon/namespaces Remove mynamespace.db Restart appdaemon

frenck commented 1 year ago

Closing this issue, as it seems it is a result of how AppDaemon is made and upgrades in Python versions. That is not something we can address from an add-on perspective.

../Frenck