HABApp 1.0 Beta Test

I was able to build the docker image only when changing the Dockerfile not using the “slim” base image.

@Spaceman_Spiff it would be good if there would be an official beta image on docker hub.

I am not sure if I’m getting the right version here:

 _   _    _    ____    _
 | | | |  / \  | __ )  / \   _ __  _ __
 | |_| | / _ \ |  _ \ / _ \ | '_ \| '_ \
 |  _  |/ ___ \| |_) / ___ \| |_) | |_) |
 |_| |_/_/   \_|____/_/   \_| .__/| .__/
                            |_|   |_|
                                        0.31.3 Dev
Debug information
--------------------------------------------------------------------------------
HABApp  : 0.31.3 Dev
Platform: Linux-5.10.103-v7l+-armv7l-with-glibc2.28
Machine : armv7l
Python  : 3.9.13 (main, Jul 12 2022, 21:32:33) [GCC 8.3.0]
Installed Packages
--------------------------------------------------------------------------------
aiohttp             : 3.8.1
aiohttp-sse-client  : 0.2.1
aiosignal           : 1.2.0
astral              : 2.2
asttokens           : 2.0.5
async-timeout       : 4.0.2
attrs               : 21.4.0
bidict              : 0.22.0
charset-normalizer  : 2.1.0
eascheduler         : 0.1.5
easyconfig          : 0.2.4
executing           : 0.8.3
frozenlist          : 1.3.0
habapp              : 0.31.3.dev0
idna                : 3.3
immutables          : 0.18
multidict           : 6.0.2
paho-mqtt           : 1.6.1
pendulum            : 2.1.2
pip                 : 22.0.4
pure-eval           : 0.2.2
pydantic            : 1.9.1
python-dateutil     : 2.8.2
pytz                : 2022.1
pytzdata            : 2020.1
ruamel.yaml         : 0.17.21
ruamel.yaml.clib    : 0.2.6
setuptools          : 58.1.0
six                 : 1.16.0
stack-data          : 0.3.0
typing-extensions   : 4.3.0
ujson               : 5.4.0
voluptuous          : 0.13.1
watchdog            : 2.1.9
wheel               : 0.37.1
yarl                : 1.7.2
+ set -euo pipefail
+ NEW_USER_ID=9001
+ NEW_GROUP_ID=9001
+ echo 'Starting with habapp user id: 9001 and group id: 9001'
+ id -u habapp
Starting with habapp user id: 9001 and group id: 9001
+ chown -R habapp:habapp /habapp/config
+ sync
+ exec gosu habapp tini -- python -m HABApp --config ./config --debug-info

That looks like the correct one. I’ll plan on releasing the beta next week (if there are no blockers).
Note: --debug-info will only print the debug information and then exit.

I realise that I’m late into the game but I just updated to OH 3.3 and HABApp 0.31.3 Dev.

After changing the event filter most things are up and running but my light control no longer work.
I have Hue lights but skipped the Hue binding some time ago and call GitHub - home-assistant-libs/aiohue: Python3 asyncio package to talk to Philips Hue from HABApp rules instead.

When starting HABApp I create all OpenHAB items in HABApp with self.oh.create_item() which has worked very well until now, With HABApp 0.31.3 Dev I get following warnings:

/etc/openhab/habapp/rules/HueLights3.py:449: RuntimeWarning:coroutine 'async_create_item' was never awaited
Coroutine created at (most recent call last)
  File "/opt/habapp/bin/habapp", line 33, in <module>
    sys.exit(load_entry_point('HABApp==0.31.3.dev0', 'console_scripts', 'habapp')())
  File "/opt/habapp/lib/python3.9/site-packages/HABApp/__main__.py", line 39, in main
    HABApp.core.const.loop.run_forever()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 596, in run_forever
    self._run_once()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 1882, in _run_once
    handle._run()
  File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/opt/habapp/lib/python3.9/site-packages/HABApp/core/internals/wrapped_function/wrapped_async.py", line 30, in async_run
    await self.func(*args, **kwargs)
  File "/etc/openhab/habapp/rules/HueLights3.py", line 727, in connect
    HueLightOH( 'BR_Ceiling'         , 'Ambience', 'caacceba-f762-4059-85a9-76bdd470442f' ), # 26
  File "/etc/openhab/habapp/rules/HueLights3.py", line 447, in __init__
    self.oh.create_item( 'String', 'Indicator' )
  File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/func_sync.py", line 95, in create_item
    async_create_item(

I don’t understand how these calls suddenly are asynchronous but will do some more troubleshooting.

Has anything been changed in in OpenHAB or HABApp that can give this behaviour?

There were some internal changes. Do you have a small working example to reproduce the issue?

I will try to make a small rule to reproduce.

Continue here? or should I create an issue on GitHub?

Wherever you like

OK, so this was interesting! (and explains why I have a love&hate-relationship with exceptions…)

In my case it turns out that I actually do call self.oh.create_item from an async context but since I use try..except the error message gets a bit obscured. See below.

I will have to find a way to make these calls synchronous and perhaps use a busy wait instead of an async sleep between calls. Since the error message in example 1 is clear, I just have to update my code!

Conclusion: No bug in OH or HABApp!


Example 1 - No Try/Except

Code:

import HABApp

import logging

class NoTry_CreateItem(HABApp.Rule):

    def __init__(self):

        super().__init__()
        self.run.soon(self.notry_create_item)

    async def notry_create_item(self):
        self.oh.create_item( 'String', 'NoTry_CreateItemTest_Item' )

log = logging.getLogger('HABApp')

NoTry_CreateItem()

Log:

2022-07-25 12:32:25.693 [INFO ] [HABApp.Rules                        ] - Added rule "NoTry_CreateItem" from rules/notry_create_item.py
2022-07-25 12:32:25.811 [ERROR] [HABApp.Worker                       ] - Error in NoTry_CreateItem.notry_create_item: Function "create_item" may not be called from an async context!
2022-07-25 12:32:25.812 [ERROR] [HABApp.Worker                       ] - File "/etc/openhab/habapp/rules/notry_create_item.py", line 13 in notry_create_item
2022-07-25 12:32:25.813 [ERROR] [HABApp.Worker                       ] - --------------------------------------------------------------------------------
2022-07-25 12:32:25.813 [ERROR] [HABApp.Worker                       ] -      12 | async def notry_create_item(self):
2022-07-25 12:32:25.814 [ERROR] [HABApp.Worker                       ] - -->  13 |     self.oh.create_item( 'String', 'NoTry_CreateItemTest_Item' )

Example 2 - Try/Except

Code:

import HABApp

import logging

class Try_CreateItem(HABApp.Rule):

    def __init__(self):

        super().__init__()
        self.run.soon(self.try_create_item)

    async def try_create_item(self):
        try:
            self.oh.create_item( 'String', 'Try_CreateItemTest_Item' )
        except:
            pass

log = logging.getLogger('HABApp')

Try_CreateItem()

Log:

2022-07-25 12:32:39.331 [INFO ] [HABApp.Rules                        ] - Added rule "Try_CreateItem" from rules/try_create_item.py
2022-07-25 12:32:39.341 [WARN ] [HABApp.Rule                         ] - /etc/openhab/habapp/rules/try_create_item.py:16: RuntimeWarning:coroutine 'async_create_item' was never awaited
Coroutine created at (most recent call last)
  File "/opt/habapp/bin/habapp", line 33, in <module>
    sys.exit(load_entry_point('HABApp==0.31.3.dev0', 'console_scripts', 'habapp')())
  File "/opt/habapp/lib/python3.9/site-packages/HABApp/__main__.py", line 39, in main
    HABApp.core.const.loop.run_forever()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 596, in run_forever
    self._run_once()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 1882, in _run_once
    handle._run()
  File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/opt/habapp/lib/python3.9/site-packages/HABApp/core/internals/wrapped_function/wrapped_async.py", line 30, in async_run
    await self.func(*args, **kwargs)
  File "/etc/openhab/habapp/rules/try_create_item.py", line 14, in try_create_item
    self.oh.create_item( 'String', 'Try_CreateItemTest_Item' )
  File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/func_sync.py", line 95, in create_item
    async_create_item(

Since you are an advanced user you can just use the async_interface of the openhab connection.
There is no guarantee that the API will be kept stable, though.

Also you don’t have to catch the exception. It will not break anything and HABApp will work as usual. It’ll just generate the log output.

Refactoring was surprisingly easy and I just separated creation of OH items (sync) and connection to Hue lights (async). I don’t know why I didn’t implement it that way in the first place but that’s what happens with my combination of “trial&error-programming” and “google-research”…

Anyway, thanks for helping and a big thank you for the fantastic work you put into HABApp!
If it wasn’t for HABApp I would probably have used Home Assistant instead.

Since I use aiohue, pyatv and some more python libs that are used by the HA community, it would be nice to use the HA plugins directly by some wrapper in HABApp. I haven’t looked into if that would even be possible though…

2 Likes

HABApp is released!

4 Likes

Possibly another issue (running 1.0.0).

I replaced my self.register_on_unload(self.cleanup) with def on_rule_removed(self) and I get:

2022-07-25 15:10:46.965 [ERROR] [HABApp.Rule                         ] - Error "'NoneType' object has no attribute 'rule_name'" in unload_rule:
2022-07-25 15:10:46.966 [ERROR] [HABApp.Rule                         ] - File "/opt/habapp/lib/python3.9/site-packages/HABApp/rule_ctx/rule_ctx.py", line 52 in unload_rule
2022-07-25 15:10:46.966 [ERROR] [HABApp.Rule                         ] - --------------------------------------------------------------------------------
2022-07-25 15:10:46.967 [ERROR] [HABApp.Rule                         ] -      32 | def unload_rule(self):
2022-07-25 15:10:46.967 [ERROR] [HABApp.Rule                         ] -       (...)
2022-07-25 15:10:46.967 [ERROR] [HABApp.Rule                         ] -      48 |         self.rule = None
2022-07-25 15:10:46.968 [ERROR] [HABApp.Rule                         ] -      49 |         rule._habapp_rule_ctx = None
2022-07-25 15:10:46.968 [ERROR] [HABApp.Rule                         ] -      51 |         # user implementation
2022-07-25 15:10:46.969 [ERROR] [HABApp.Rule                         ] - -->  52 |         rule.on_rule_removed()
2022-07-25 15:10:46.969 [ERROR] [HABApp.Rule                         ] -    ------------------------------------------------------------

Can you post your cleanup code? You are probably accessing properties which have already been set to None

OK, this a mini example of what I try to do.

I open connections to pyatv, aiohue, … and receives data from them. If I don’t close the open streams, I will get multiple streams since each reload of a rule opens a new connection.

Code:

import HABApp

async def connect():
    return 'connect to SSE stream'

async def disconnect():
    return 'disconnect from SSE stream'

class CleanupTest(HABApp.Rule):

    def __init__(self):
        super().__init__()
        self.resource = None
        self.run.soon(self.connect)

    def on_rule_removed(self):
        self.run.soon(self.disconnect)

    async def connect(self):
        self.resource = await connect()

    async def disconnect(self):
        if self.resource is not None:
            self.resource = await disconnect()

CleanupTest()


Log:

2022-07-27 11:06:02.883 [ERROR] [HABApp.Rule                         ] - Error "'NoneType' object has no attribute 'rule_name'" in unload_rule:
2022-07-27 11:06:02.886 [ERROR] [HABApp.Rule                         ] - Error while formatting traceback: Expected one value, found 0
2022-07-27 11:06:02.887 [ERROR] [HABApp.Rule                         ] - Traceback (most recent call last):
2022-07-27 11:06:02.888 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/rule_ctx/rule_ctx.py", line 52, in unload_rule
2022-07-27 11:06:02.888 [ERROR] [HABApp.Rule                         ] -     rule.on_rule_removed()
2022-07-27 11:06:02.889 [ERROR] [HABApp.Rule                         ] -   File "/etc/openhab/habapp/rules/CleanupTest.py", line 17, in on_rule_removed
2022-07-27 11:06:02.892 [ERROR] [HABApp.Rule                         ] -     self.run.soon(self.disconnect)
2022-07-27 11:06:02.893 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/rule/scheduler/habappschedulerview.py", line 80, in soon
2022-07-27 11:06:02.893 [ERROR] [HABApp.Rule                         ] -     return self.at(None, callback, *args, **kwargs)
2022-07-27 11:06:02.894 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/rule/scheduler/habappschedulerview.py", line 25, in at
2022-07-27 11:06:02.894 [ERROR] [HABApp.Rule                         ] -     callback = wrap_func(callback, context=self._habapp_rule_ctx)
2022-07-27 11:06:02.895 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/core/internals/wrapped_function/wrapper.py", line 21, in wrap_func
2022-07-27 11:06:02.896 [ERROR] [HABApp.Rule                         ] -     return WrappedAsyncFunction(func, name=name, logger=logger, context=context)
2022-07-27 11:06:02.897 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/core/internals/wrapped_function/wrapped_async.py", line 17, in __init__
2022-07-27 11:06:02.897 [ERROR] [HABApp.Rule                         ] -     super(WrappedAsyncFunction, self).__init__(name=name, func=func, logger=logger, context=context)
2022-07-27 11:06:02.898 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/core/internals/wrapped_function/base.py", line 25, in __init__
2022-07-27 11:06:02.898 [ERROR] [HABApp.Rule                         ] -     name = self._habapp_ctx.get_callback_name(func)
2022-07-27 11:06:02.899 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/rule_ctx/rule_ctx.py", line 22, in get_callback_name
2022-07-27 11:06:02.911 [ERROR] [HABApp.Rule                         ] -     return f'{self.rule.rule_name}.{callback.__name__}' if self.rule.rule_name else None
2022-07-27 11:06:02.912 [ERROR] [HABApp.Rule                         ] - AttributeError: 'NoneType' object has no attribute 'rule_name'
2022-07-27 11:06:02.913 [ERROR] [HABApp.Rule                         ] - 
2022-07-27 11:06:02.913 [ERROR] [HABApp.Rule                         ] - During handling of the above exception, another exception occurred:
2022-07-27 11:06:02.914 [ERROR] [HABApp.Rule                         ] - 
2022-07-27 11:06:02.917 [ERROR] [HABApp.Rule                         ] - Traceback (most recent call last):
2022-07-27 11:06:02.918 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/core/lib/exceptions/format.py", line 46, in format_exception
2022-07-27 11:06:02.918 [ERROR] [HABApp.Rule                         ] -     added = format_frame_info(tb, frame_info, is_last=i == last_frame)
2022-07-27 11:06:02.919 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/core/lib/exceptions/format_frame.py", line 46, in format_frame_info
2022-07-27 11:06:02.920 [ERROR] [HABApp.Rule                         ] -     if frame_info.lines:
2022-07-27 11:06:02.922 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
2022-07-27 11:06:02.923 [ERROR] [HABApp.Rule                         ] -     value = obj.__dict__[self.func.__name__] = self.func(obj)
2022-07-27 11:06:02.923 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/stack_data/core.py", line 698, in lines
2022-07-27 11:06:02.926 [ERROR] [HABApp.Rule                         ] -     pieces = self.included_pieces
2022-07-27 11:06:02.926 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
2022-07-27 11:06:02.927 [ERROR] [HABApp.Rule                         ] -     value = obj.__dict__[self.func.__name__] = self.func(obj)
2022-07-27 11:06:02.928 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/stack_data/core.py", line 649, in included_pieces
2022-07-27 11:06:02.928 [ERROR] [HABApp.Rule                         ] -     pos = scope_pieces.index(self.executing_piece)
2022-07-27 11:06:02.929 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
2022-07-27 11:06:02.929 [ERROR] [HABApp.Rule                         ] -     value = obj.__dict__[self.func.__name__] = self.func(obj)
2022-07-27 11:06:02.930 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/stack_data/core.py", line 628, in executing_piece
2022-07-27 11:06:02.931 [ERROR] [HABApp.Rule                         ] -     return only(
2022-07-27 11:06:02.931 [ERROR] [HABApp.Rule                         ] -   File "/opt/habapp/lib/python3.9/site-packages/executing/executing.py", line 164, in only
2022-07-27 11:06:02.932 [ERROR] [HABApp.Rule                         ] -     raise NotOneValueFound('Expected one value, found 0')
2022-07-27 11:06:02.933 [ERROR] [HABApp.Rule                         ] - executing.executing.NotOneValueFound: Expected one value, found 0
2022-07-27 11:06:02.933 [ERROR] [HABApp.Rule                         ] - 
2022-07-27 11:06:02.935 [ERROR] [HABApp.Rule                         ] - --------------------------------------------------------------------------------
2022-07-27 11:06:02.935 [ERROR] [HABApp.Rule                         ] - Partial Traceback:
2022-07-27 11:06:02.936 [ERROR] [HABApp.Rule                         ] - --------------------------------------------------------------------------------
2022-07-27 11:06:02.937 [ERROR] [HABApp.Rule                         ] - File "/opt/habapp/lib/python3.9/site-packages/HABApp/rule_ctx/rule_ctx.py", line 52 in unload_rule
2022-07-27 11:06:02.937 [ERROR] [HABApp.Rule                         ] - --------------------------------------------------------------------------------
2022-07-27 11:06:02.938 [ERROR] [HABApp.Rule                         ] -      32 | def unload_rule(self):
2022-07-27 11:06:02.938 [ERROR] [HABApp.Rule                         ] -       (...)
2022-07-27 11:06:02.939 [ERROR] [HABApp.Rule                         ] -      48 |         self.rule = None
2022-07-27 11:06:02.940 [ERROR] [HABApp.Rule                         ] -      49 |         rule._habapp_rule_ctx = None
2022-07-27 11:06:02.940 [ERROR] [HABApp.Rule                         ] -      51 |         # user implementation
2022-07-27 11:06:02.941 [ERROR] [HABApp.Rule                         ] - -->  52 |         rule.on_rule_removed()
2022-07-27 11:06:02.941 [ERROR] [HABApp.Rule                         ] -    ------------------------------------------------------------
2022-07-27 11:06:02.942 [ERROR] [HABApp.Rule                         ] -      rule = <CleanupTest>
2022-07-27 11:06:02.942 [ERROR] [HABApp.Rule                         ] -      rule._habapp_rule_ctx = None
2022-07-27 11:06:02.943 [ERROR] [HABApp.Rule                         ] -      rule.run = <HABApp.rule.scheduler.habappschedulerview.HABAppSchedulerView object at 0xa7e3d118>
2022-07-27 11:06:02.944 [ERROR] [HABApp.Rule                         ] -      rule.run._habapp_ctx = None
2022-07-27 11:06:02.945 [ERROR] [HABApp.Rule                         ] -      rule.run._scheduler = <HABApp.rule.scheduler.scheduler.HABAppScheduler object at 0xa7e3d580>
2022-07-27 11:06:02.945 [ERROR] [HABApp.Rule                         ] -      self = <HABApp.rule_ctx.rule_ctx.HABAppRuleContext object at 0xa7e3d358>
2022-07-27 11:06:02.946 [ERROR] [HABApp.Rule                         ] -      self.objs = None
2022-07-27 11:06:02.946 [ERROR] [HABApp.Rule                         ] -      self.rule = None
2022-07-27 11:06:02.947 [ERROR] [HABApp.Rule                         ] -      log = <Logger HABApp.Rule (INFO)>
2022-07-27 11:06:02.948 [ERROR] [HABApp.Rule                         ] -    ------------------------------------------------------------
2022-07-27 11:06:02.948 [ERROR] [HABApp.Rule                         ] - 
2022-07-27 11:06:03.068 [INFO ] [HABApp.Rules                        ] - Added rule "CleanupTest" from rules/CleanupTest.py

You can not use the scheduler any more because it has been unloaded.
Currently there is no elegant way to use an async on_rule_removed to clean up async resources.
As a temporary workaround you can use HABApp.core.asyncio.create_task to schedule the execution but it will not provide trace backs in case of error. You can use the HABApp.core.wrapper.log_exception decorator to achieve that.
Maybe I’ll have to think of something in future versions.

Well, it make sense that on_rule_removed is called after things are tore down, but it would be nice to also have a on_rule_about_to_be_removed that would be called much earlier. Some type of “last order before the kitchen is closed…”

Hm - I think it would be better to modify it so it works for async functions.
Because if you schedule a task in on_rule_about_to_be_removed 0.2 secs in the future it will be canceled silently. I’d rather have one call that has to do the cleanup and when it’s done the rule is unloaded.

HABApp.core.asyncio.create_task( self.cleanup() ) seems to solve my use cases.

Thank you!

Yes, but that’s only a workaround and imho should be supported out of the box. :slight_smile:
Also use the decorator so you catch possible errors.

Hi,

I have installed Habapp 1.0.4 after my previous installation broke after openhab update.
I am getting a lot of errors after I touch any rule file:

2022-08-22 04:54:41.415 [ERROR] [HABApp.Worker                       ] - Error in _process_event: 'NoneType' object has no attribute 'name'
2022-08-22 04:54:41.416 [ERROR] [HABApp.Worker                       ] - File "/opt/habapp/lib/python3.10/site-packages/HABApp/core/files/manager/listen_events.py", line 16 in _process_event
2022-08-22 04:54:41.416 [ERROR] [HABApp.Worker                       ] - --------------------------------------------------------------------------------
2022-08-22 04:54:41.416 [ERROR] [HABApp.Worker                       ] -      14 | async def _process_event(event: Union[RequestFileUnloadEvent, RequestFileLoadEvent]):
2022-08-22 04:54:41.416 [ERROR] [HABApp.Worker                       ] -      15 |     name = event.name
2022-08-22 04:54:41.417 [ERROR] [HABApp.Worker                       ] - -->  16 |     await HABApp.core.files.manager.process_file(name, HABApp.core.files.folders.get_path(name))
2022-08-22 04:54:41.417 [ERROR] [HABApp.Worker                       ] -    ------------------------------------------------------------
2022-08-22 04:54:41.417 [ERROR] [HABApp.Worker                       ] -      event = <RequestFileUnloadEvent filename: rules/(A Document Being Saved By Xcode)/Themostats.py>
2022-08-22 04:54:41.417 [ERROR] [HABApp.Worker                       ] -      event.name = 'rules/(A Document Being Saved By Xcode)/Themostats.py'
2022-08-22 04:54:41.417 [ERROR] [HABApp.Worker                       ] -      name = 'rules/(A Document Being Saved By Xcode)/Themostats.py'
2022-08-22 04:54:41.417 [ERROR] [HABApp.Worker                       ] -      RequestFileUnloadEvent, RequestFileLoadEvent = (<class 'HABApp.core.events.habapp_events.RequestFileUnloadEvent'>, <class 'HABApp.core.events.habapp_events.RequestFileLoadEvent'>)
2022-08-22 04:54:41.418 [ERROR] [HABApp.Worker                       ] -    ------------------------------------------------------------
2022-08-22 04:54:41.418 [ERROR] [HABApp.Worker                       ] - 
2022-08-22 04:54:41.418 [ERROR] [HABApp.Worker                       ] - File "/opt/habapp/lib/python3.10/site-packages/HABApp/core/files/manager/worker.py", line 29 in process_file
2022-08-22 04:54:41.418 [ERROR] [HABApp.Worker                       ] - --------------------------------------------------------------------------------
2022-08-22 04:54:41.418 [ERROR] [HABApp.Worker                       ] -      21 | async def process_file(name: str, file: Path):
2022-08-22 04:54:41.418 [ERROR] [HABApp.Worker                       ] -       (...)
2022-08-22 04:54:41.419 [ERROR] [HABApp.Worker                       ] -      26 |         existing = FILES.pop(name, None)
2022-08-22 04:54:41.419 [ERROR] [HABApp.Worker                       ] -      27 |         if existing is not None:
2022-08-22 04:54:41.419 [ERROR] [HABApp.Worker                       ] -      28 |             await existing.unload()
2022-08-22 04:54:41.419 [ERROR] [HABApp.Worker                       ] - -->  29 |         log.debug(f'Removed {existing.name}')
2022-08-22 04:54:41.419 [ERROR] [HABApp.Worker                       ] -      30 |         return None
2022-08-22 04:54:41.420 [ERROR] [HABApp.Worker                       ] -    ------------------------------------------------------------
2022-08-22 04:54:41.420 [ERROR] [HABApp.Worker                       ] -      existing = None
2022-08-22 04:54:41.420 [ERROR] [HABApp.Worker                       ] -      file = PosixPath('/etc/openhab/habapp/rules/(A Document Being Saved By Xcode)/Themostats.py')
2022-08-22 04:54:41.420 [ERROR] [HABApp.Worker                       ] -      FILES = {'rules/Gates.py': <HABAppRuleFile rules/Gates.py state: FAILED>, 'rules/Themostats.py': <HABAppRuleFile rules/Themostats.py state: LOADED>}
2022-08-22 04:54:41.420 [ERROR] [HABApp.Worker                       ] -      log = <Logger HABApp.files (INFO)>
2022-08-22 04:54:41.420 [ERROR] [HABApp.Worker                       ] -      name = 'rules/(A Document Being Saved By Xcode)/Themostats.py'
2022-08-22 04:54:41.421 [ERROR] [HABApp.Worker                       ] -      TASK = None
2022-08-22 04:54:41.421 [ERROR] [HABApp.Worker                       ] -      existing is not None = False
2022-08-22 04:54:41.421 [ERROR] [HABApp.Worker                       ] -    ------------------------------------------------------------
2022-08-22 04:54:41.421 [ERROR] [HABApp.Worker                       ] - 
2022-08-22 04:54:41.421 [ERROR] [HABApp.Worker                       ] - --------------------------------------------------------------------------------
2022-08-22 04:54:41.421 [ERROR] [HABApp.Worker                       ] - Traceback (most recent call last):
2022-08-22 04:54:41.422 [ERROR] [HABApp.Worker                       ] -   File "/opt/habapp/lib/python3.10/site-packages/HABApp/core/internals/wrapped_function/wrapped_async.py", line 30, in async_run
2022-08-22 04:54:41.422 [ERROR] [HABApp.Worker                       ] -     await self.func(*args, **kwargs)
2022-08-22 04:54:41.422 [ERROR] [HABApp.Worker                       ] -   File "/opt/habapp/lib/python3.10/site-packages/HABApp/core/files/manager/listen_events.py", line 16, in _process_event
2022-08-22 04:54:41.422 [ERROR] [HABApp.Worker                       ] -     await HABApp.core.files.manager.process_file(name, HABApp.core.files.folders.get_path(name))
2022-08-22 04:54:41.422 [ERROR] [HABApp.Worker                       ] -   File "/opt/habapp/lib/python3.10/site-packages/HABApp/core/files/manager/worker.py", line 29, in process_file
2022-08-22 04:54:41.422 [ERROR] [HABApp.Worker                       ] -     log.debug(f'Removed {existing.name}')
2022-08-22 04:54:41.422 [ERROR] [HABApp.Worker                       ] - AttributeError: 'NoneType' object has no attribute 'name'

I will be very glad for any help :slight_smile:

Cheers,
Marcin

Do you see any other errors before that one? Imho this should be a follow up issue.
I’ve pushed a fix to the dev branch nonetheless.