HABApp Beta

Here we can see different scenarios:

Direct modification of the file:

2025-02-24 20:40:57.372 [DEBUG] [HABApp.file.events         ] - modified /etc/openhab/habapp/rules/startup/startup.py
2025-02-24 20:40:57.380 [DEBUG] [HABApp.Rules               ] - Removing file: rules/startup/startup.py
2025-02-24 20:40:57.386 [DEBUG] [HABApp.Rules               ] - File rules/startup/startup.py successfully unloaded!
2025-02-24 20:40:57.387 [DEBUG] [HABApp.files               ] - rules/startup/startup.py changed to REMOVED
2025-02-24 20:40:57.691 [DEBUG] [HABApp.files               ] - rules/startup/startup.py changed to DEPENDENCIES_MISSING
2025-02-24 20:40:57.692 [DEBUG] [HABApp.files               ] - rules/startup/startup.py changed to DEPENDENCIES_OK
2025-02-24 20:40:57.692 [DEBUG] [HABApp.Rules               ] - Loading file: rules/startup/startup.py
2025-02-24 20:40:57.701 [INFO ] [HABApp.Rules               ] - Added rule "StartUp" from rules/startup/startup.py
2025-02-24 20:40:57.704 [DEBUG] [HABApp.Rules               ] - File rules/startup/startup.py successfully loaded!
2025-02-24 20:40:57.705 [INFO ] [Rule.StartUp               ] - SetLoggingFilters: Setze Filter fürs Logging
2025-02-24 20:40:57.705 [INFO ] [Rule.StartUp               ] - SetLocale: Setze Zeit-/Datumsformat
2025-02-24 20:40:57.708 [DEBUG] [HABApp.files               ] - rules/startup/startup.py changed to LOADED
2025-02-24 20:41:12.708 [DEBUG] [HABApp.files               ] - Worker done!

Copying of the modified file in the folder (as I do it usually):

2025-02-24 20:56:38.181 [DEBUG] [HABApp.file.events         ] - deleted /etc/openhab/habapp/rules/startup/startup.py
2025-02-24 20:56:38.182 [DEBUG] [HABApp.file.events         ] - added /etc/openhab/habapp/rules/startup/startup.py
2025-02-24 20:56:38.184 [DEBUG] [HABApp.file.events         ] - deleted /etc/openhab/habapp/rules/startup/~gvfUdmU.tmp
2025-02-24 20:56:38.185 [DEBUG] [HABApp.file.events         ] - added /etc/openhab/habapp/rules/startup/~gvfUdmU.tmp
2025-02-24 20:56:38.196 [DEBUG] [HABApp.Rules               ] - Removing file: rules/startup/startup.py
2025-02-24 20:56:38.210 [DEBUG] [HABApp.Rules               ] - File rules/startup/startup.py successfully unloaded!
2025-02-24 20:56:38.211 [DEBUG] [HABApp.files               ] - rules/startup/startup.py changed to REMOVED
2025-02-24 20:56:38.213 [WARN ] [HABApp.Rules               ] - Rule file /etc/openhab/habapp/rules/startup/startup.py is not yet loaded and therefore can not be unloaded
2025-02-24 20:56:38.214 [DEBUG] [HABApp.files               ] - rules/startup/startup.py changed to REMOVED
2025-02-24 20:56:38.560 [DEBUG] [HABApp.files               ] - rules/startup/startup.py changed to DEPENDENCIES_MISSING
2025-02-24 20:56:38.561 [DEBUG] [HABApp.files               ] - rules/startup/startup.py changed to DEPENDENCIES_OK
2025-02-24 20:56:38.562 [DEBUG] [HABApp.Rules               ] - Loading file: rules/startup/startup.py
2025-02-24 20:56:38.572 [INFO ] [HABApp.Rules               ] - Added rule "StartUp" from rules/startup/startup.py
2025-02-24 20:56:38.575 [DEBUG] [HABApp.Rules               ] - File rules/startup/startup.py successfully loaded!
2025-02-24 20:56:38.577 [INFO ] [Rule.StartUp               ] - SetLoggingFilters: Setze Filter fürs Logging
2025-02-24 20:56:38.577 [INFO ] [Rule.StartUp               ] - SetLocale: Setze Zeit-/Datumsformat
2025-02-24 20:56:38.581 [DEBUG] [HABApp.files               ] - rules/startup/startup.py changed to LOADED
2025-02-24 20:56:53.582 [DEBUG] [HABApp.files               ] - Worker done!

Using HABApp as of 21.02.2025 (tip of the “Develop” branch, HABApp doesn't wait if openHAB was started long ago · spacemanspiff2007/HABApp@e03ce35 · GitHub ) with openHAB 5.0.0.M1 (from the docker image), I have an interesting error message in my logs:

I am controlling my somfytahoma rollershutters, and when a periodic update is pulled from the bridge, or when I send a command to one of the rollershutters, and therefore an update comes in, I see the following:

[2025-02-25 14:51:55,730] [HABApp.connection.openhab]    ERROR | ThingUpdatedEvent.payload.1.bridgeUID
[2025-02-25 14:51:55,730] [HABApp.connection.openhab]    ERROR |   Extra inputs are not permitted [type=extra_forbidden, input_value='somfytahoma:bridge:home', input_type=str]
[2025-02-25 14:51:55,730] [HABApp.connection.openhab]    ERROR |     For further information visit https://errors.pydantic.dev/2.10/v/extra_forbidden

The thing in question is textually configured:

Bridge somfytahoma:bridge:home "Somfy Tahoma Bridge"
[
    email="SOMESECRET",
    password="NOT-GONNA-TELL-YOU",
    refresh=600,
    devMode="true",
    ip="MY-GATEWAY-ADDRESS",
    pin="MY-PIN"
]

Any clue what might be happening here?

Above this error there should be the input which caused the error.
Could you provide this entry? You can also pm it to me.

Could you also show the logged event for HABApp.Files for this file?

Sent via PM just now.

These lines are logged from HABApp in the relevant time frame:

[2025-02-24 20:56:38,187] [HABApp.EventBus            ]     INFO |         HABApp.Files: <RequestFileLoadEvent filename: rules/startup/startup.py>
[2025-02-24 20:56:38,189] [HABApp.EventBus            ]     INFO |         HABApp.Files: <RequestFileLoadEvent filename: rules/startup/startup.py>
[2025-02-24 20:56:38,213] [HABApp.EventBus            ]     INFO |      HABApp.Warnings: 'Rule file /etc/openhab/habapp/rules/startup/startup.py is not yet loaded and therefore can not be unloaded'

@usambara I tried fixing the issue with DEV-3. Does it still occur with the new version?

Also with DEV-3, the warning is still there.

2025-02-28 17:06:35.369 [INFO ] [HABApp                     ] - HABApp Version 25.02.0-DEV-3
2025-02-28 17:06:35.369 [DEBUG] [HABApp.Config              ] - Added custom log level "WARN" (30)
2025-02-28 17:07:24.366 [DEBUG] [HABApp.file.events         ] - deleted /etc/openhab/habapp/rules/system/~gvf8Lqj.tmp
2025-02-28 17:07:24.367 [DEBUG] [HABApp.file.events         ] - added /etc/openhab/habapp/rules/system/~gvf8Lqj.tmp
2025-02-28 17:07:24.368 [DEBUG] [HABApp.file.events         ] - deleted /etc/openhab/habapp/rules/system/system_things_bridges_new.py
2025-02-28 17:07:24.368 [DEBUG] [HABApp.file.events         ] - added /etc/openhab/habapp/rules/system/system_things_bridges_new.py
2025-02-28 17:07:24.380 [DEBUG] [HABApp.Rules               ] - Removing file: rules/system/system_things_bridges_new.py
2025-02-28 17:07:24.404 [DEBUG] [HABApp.Rules               ] - File rules/system/system_things_bridges_new.py successfully unloaded!
2025-02-28 17:07:24.408 [DEBUG] [HABApp.files               ] - rules/system/system_things_bridges_new.py changed to REMOVED
2025-02-28 17:07:24.410 [WARN ] [HABApp.Rules               ] - Rule file /etc/openhab/habapp/rules/system/system_things_bridges_new.py is not yet loaded and therefore can not be unloaded
2025-02-28 17:07:24.411 [DEBUG] [HABApp.files               ] - rules/system/system_things_bridges_new.py changed to REMOVED
2025-02-28 17:07:24.817 [DEBUG] [HABApp.files               ] - rules/system/system_things_bridges_new.py changed to DEPENDENCIES_MISSING
2025-02-28 17:07:24.817 [DEBUG] [HABApp.files               ] - rules/system/system_things_bridges_new.py changed to DEPENDENCIES_OK
2025-02-28 17:07:24.818 [DEBUG] [HABApp.Rules               ] - Loading file: rules/system/system_things_bridges_new.py
2025-02-28 17:07:24.911 [INFO ] [HABApp.Rules               ] - Added rule "System_Things_Bridge" from rules/system/system_things_bridges_new.py
2025-02-28 17:07:24.914 [DEBUG] [HABApp.Rules               ] - File rules/system/system_things_bridges_new.py successfully loaded!
2025-02-28 17:07:24.920 [DEBUG] [HABApp.files               ] - rules/system/system_things_bridges_new.py changed to LOADED
2025-02-28 17:07:39.921 [DEBUG] [HABApp.files               ] - Worker done!

@Spaceman_Spiff Does 25.02.0 carry a fix for the issue sometimes seen with image items ?

Yes - image items do work without issue there.

I thought I could push the Dev to a quick release, but it was way more work than I anticipated. Unfortunately I am very busy until the week after next week so I have limited time to work on the dev branch, but I’ll do what I can to finish it.

1 Like

@usambara I once again tried to fix the issue. It’s hard since I can’t reproduce it. Does DEV-4 fix the issue for you?

@bastler
I fixed the threading issue with the help of @nobbi123 .
It should work now as expected for you however you need to wrap either the function definition or your lambdas with in_thread. It works without it but logs an error.
See the dev docs for an example.
If anything is unclear or if you need help please PM me.

1 Like

i installed the dev-5 today morning and my threading timer now works. thank you very much @Spaceman_Spiff and @nobbi123 for the help!

one small thing i observed i want to report:

i use config variable to load yml-files from param folder, eg

PARA_FILE = 'pirs'
YAML_FILE = f'{CONFIG.directories.param}/{PARA_FILE:s}.yml'

now with the dev-5 i had to change param to params to keep it work:

YAML_FILE = f'{CONFIG.directories.params}/{PARA_FILE:s}.yml'
1 Like

DEV-6 fixes the small delay between each file when loading rule files

1 Like

i am still on dev-5 and would like to ask if i do something wrong, but i think this behaviour has changed:

for some rules i use the automatic reload at the beginning of a file:

# HABApp:
#   reloads on:
#    - params/first_init.yml

to reload rules if i changed a yml-file. earlier the file was removed before loaded again, now it seems the file gets loaded although the “old” file still exists.

i tried with this test:

    def __init__(self):
        super().__init__()
        self.run.at(self.run.trigger.interval('PT1S', 'PT10S'), self.say_something)

    def say_something(self):
        self.log.debug("say_something!")

when i save the rule i see this in the log, correct, one entry every 10 sec:

2025-03-17 13:36:47.388 [DEBUG] [My_HABApp:first_init.py.say_something ] - say_something!
2025-03-17 13:36:37.390 [DEBUG] [My_HABApp:first_init.py.say_something ] - say_something!
2025-03-17 13:36:27.391 [DEBUG] [My_HABApp:first_init.py.say_something ] - say_something!

now i change the yml-file and save it i still have the entries from the instance before and additional the new entries:

2025-03-17 13:37:09.354 [DEBUG] [My_HABApp:first_init.py.say_something ] - say_something!
2025-03-17 13:37:07.387 [DEBUG] [My_HABApp:first_init.py.say_something ] - say_something!
2025-03-17 13:36:59.353 [DEBUG] [My_HABApp:first_init.py.say_something ] - say_something!
2025-03-17 13:36:57.387 [DEBUG] [My_HABApp:first_init.py.say_something ] - say_something!
1 Like

Thank you for observing thoroughly and bringing this to my attention.
This is a bug that I missed while reworking the file manager.
Does DEV-7 fix the issue for you?

1 Like

thank you!
it is still confusing for me:
although the folder name ist param and the config is

directories:
  logging: /var/log/openhab   # Folder where the logs will be written to
  rules: rules                # Folder from which the rule files will be loaded
  param: param                # Folder from which the parameter files will be loaded

i have to code:

# HABApp:
#   reloads on:
#    - params/first_init.yml

(with additional ‘s’) to get the rule loaded.

but in dev-6 still the old rule is not reloaded when i save the yml file.

I migrated the config key name (you should also see a log entry in stdout or in the beginning of the log).
You can change param: param to params: param in the config.yml

Could you try updating again - the fix is only in DEV-7, not in DEV-6

sorry, i wrote nonsense, i already was on dev-7 the problem still exists there.

what i do not understand, as i wrote in the config.yml i have

  param: param                # Folder from which the parameter files will be loaded

and the real folder name is also param, but why then i have to write in the code

#   reloads on:
#    - params/first_init.yml

params with additional ‘s’ to get the file loaded?

Hmm - then I have to investigate further :confused:


I added a configuration migration to the config.yml :
In the future it will be (in your case) params: param, but I wanted it to be non-breaking so param: param does also work but does emit a log or stdout entry.

The params/ you write in your file does not refer to the actual folder name but an HABApp internal name. That way the file dependency works everywhere regardless of what is configured as a params folder. E.g. you could configure params: bastler and the correct entry would still be params/... even though the file is actually in a different folder

1 Like

Sorry for the late response.
I’ve tested it again with DEV-7 and the warnings are gone! Thanks for all your work.