HABApp Beta

I’ve spent a huge amount of time of the last months rewriting some of the core connection logic of HABApp.
I think it’s finally done and since this is a major rewrite (github shows 192 changed files so far) I’d like to get some early feedback on the new version.
Currently I am not aware of any breaking changes.

Additionally the new version provides

  • improved tracebacks
  • support for env variables in the config
  • support for map transformation from openHAB
  • better performance
  • fixed some bugs, introduced new ones - the usual

To update to the most recent version you have to uninstall HABApp first and then reinstall.

pip uninstall habapp
pip install git+https://github.com/spacemanspiff2007/HABApp.git@Develop

I’ll ping a couple of users which were interested in a beta test but of course every one is invited!
Thank you for your feedback and tests in advance!

@Dominik_Bernhardt @yfaway @dan12345 @alfista2600 @bastler @nobbi123

5 Likes

Cool! Happy to test, just have to try to remember how to download and build into a docker container… if you have something handy let me know! Back-to-school is a crazy time of year for my small business so limited in time.

1 Like

Imho the most easy way would be to just download the whole HABApp repository and then run the included dockerfile. That way your container should start the DEV version (you can recognize it through the version number through the startup).

@bastler
I’ve added a convenience method to all jobs which allows to easily send the datetime to the item without further hassle:

job = self.run.every(None, 0.5, called)
job.to_item(self.item)

If someone has a better name than to_item I’d be happy to hear it.

1 Like

thank you very much, I appreciate it :slightly_smiling_face: :+1:
i just upgraded, additional info: dont know if my way is too complicated but i always do it this way and never had problems:

sudo systemctl stop habapp
cd /opt/habapp
source bin/activate

python3 -m pip uninstall habapp

python3 -m pip install git+https://github.com/spacemanspiff2007/HABApp.git@Develop

sudo systemctl start habapp

i even had no issues before so for me still everything seems to work perfect.

the new map transformation i just tried, nice! so now i can change some code:

my_map = transformations.map['feiertage.map']
self.log.info(f'### name is             {self.openhab.get_item("iHeuteTagName").state}')
self.log.info(f'### old transform was   {str(self.openhab.get_item("iHeuteTagName").transformed_state)}')
self.log.info(f'### transforme now is   {my_map[OpenhabItem.get_item("iHeuteTagName").value]}')

this results in:

2023-08-24 19:39:54,031 [INFO ] [My_HABApp] - ### name is             thursday
2023-08-24 19:39:54,041 [INFO ] [My_HABApp] - ### old transform was   Donnerstag
2023-08-24 19:39:54,042 [INFO ] [My_HABApp] - ### transforme now is   Donnerstag

and even the search in the documentation seem to work again - great!

1 Like

Sounds interesting. Happy to Test but I’m currently on vacation until mid September :grinning:

I updated my test environment and everything is running, till now :slight_smile:
Thanks for your hard work :+1:

BUT: I found a breaking change: HABApp.openhab.interface was renamed to HABApp.openhab.interface_sync

In my eyes this is an interface change and means version should be 2.0.0

Hello Seb,

Thanks for the work. I just tried to run my system, and I am seeing a few breaking changes:

  1. HABApp.openhab.interface is gone and replaced by HABApp.openhab.interface_sync and HABApp.openhab.interface.async.
  2. HABApp.openhab.interface_sync.get_item() signature changes to no longer takes a list of metadata fields to fetch.
  3. HABApp.openhab.interface_sync.get_item() behavior changed to return null on invalid item name.
  4. The metadata in ItemResp no longer has the channel info.

The first 3 changes are very reasonable. I like the fact that we no longer have to specify the metaitem names to fetch. However, could you tell me how could I fetch the channel value of an item?

I will let you know if I see any additional behavior changes.

Thanks,

@Dominik_Bernhardt - looks like your vacation is cancelled :wink: :wink:

Thanks everyone for the feedback so far!

Hmm, HABApp.openhab.interface was never part of the official API so I am very astonished that it’s used so much. Using self.oh or self.openhab in a rule will work as before.
But it sure makes sense to add it to the changelog.

I have to think about that again. Maybe an exception is better

I am not sure what you mean - could you provide an example?

Seb, that’s the OpenHab channel that links the item to the thing. E.g.:

Switch FF_Office_LightSwitch "Office Light" (gWallSwitch, gLightSwitch, gFirstFloorLightSwitch)
  [shared-motion-sensor]                                                        
  { channel="zwave:device:7fb4270383:node8:switch_binary",                      
    durationInMinutes="15" }

Here is my previous code:

item_def = HABApp.openhab.interface.get_item(item.name, "channel")
metadata = item_def.metadata
value = metadata.get("channel")

With the new code, I believe channel is no longer considered a meta field. Would it be available somewhere else?

Is that with the same openHAB version? I’m not aware of any changes in that code part so that’s very unexpected.
I double checked with my OH4.0 installation - it doesn’t report channel in the metadata in the API explorer.

You are correct Seb. I just check the prod version of HABApp and it behaves the same, empty string. So it might have worked before a long time ago, or perhaps I just overlooked. It is an area that is infrequently used in my code bases.

Thanks,

Hi @Spaceman_Spiff:

I wanted to use my “free sunday” to test the OH4 version but run into the problem that - even though curl works

curl -X GET --header "Accept: application/json" "http://localhost:8080/rest/systeminfo" -u <user>:<passwd>
{"systemInfo":{"configFolder":"/etc/openhab","userdataFolder":"/var/lib/openhab","logFolder":"/var/log/openhab","javaVersion":"17.0.7","javaVendor":"Raspbian","osName":"Linux","osVersion":"6.1.21-v8+","osArchitecture":"arm","availableProcessors":4,"freeMemory":69168752,"totalMemory":330977280,"startLevel":20}}

habApp (v 1.1.2) does not start anymore.

2023-08-27 14:28:50.656 [INFO ] [HABApp                              ] - HABApp Version 1.1.2
2023-08-27 14:28:50.697 [INFO ] [HABApp.Config                       ] - Manual thing configuration disabled! Folder /etc/openhab/habapp/config does not exist!
2023-08-27 14:28:50.712 [INFO ] [HABApp.mqtt.connection              ] - Connecting to 192.168.178.37:1883
2023-08-27 14:28:50.723 [INFO ] [HABApp.mqtt.connection              ] - Connection Accepted.
2023-08-27 14:28:50.821 [INFO ] [HABApp.openhab.connection           ] - Connected to OpenHAB version 4.0.2 (Release Build)
2023-08-27 14:28:50.828 [INFO ] [HABApp.openhab.connection           ] - Waiting for openHAB startup to be complete

and there it stops. UserName and Password are set in config.yml.

So I tries to use your dev-Version but get stuck with an error here as well:

openhabian@openhabianpi:~ $ sudo systemctl stop habapp.service
openhabian@openhabianpi:~ $ sudo systemctl stop openhab.service
openhabian@openhabianpi:~ $ cd /opt/habapp/
openhabian@openhabianpi:/opt/habapp $ source bin/activate
(habapp) openhabian@openhabianpi:/opt/habapp $ python3 -m pip uninstall habapp
Found existing installation: HABApp 1.1.2
Uninstalling HABApp-1.1.2:
  Would remove:
    /opt/habapp/bin/habapp
    /opt/habapp/lib/python3.9/site-packages/HABApp-1.1.2.dist-info/*
    /opt/habapp/lib/python3.9/site-packages/HABApp/*
Proceed (Y/n)? Y
  Successfully uninstalled HABApp-1.1.2
ERROR: Exception:
Traceback (most recent call last):
  File "/opt/habapp/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
  File "/opt/habapp/lib/python3.9/site-packages/pip/_internal/commands/uninstall.py", line 110, in run
    uninstall_pathset.commit()
  File "/opt/habapp/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 432, in commit
    self._moved_paths.commit()
  File "/opt/habapp/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 278, in commit
    save_dir.cleanup()
  File "/opt/habapp/lib/python3.9/site-packages/pip/_internal/utils/temp_dir.py", line 173, in cleanup
    rmtree(self._path)
  File "/opt/habapp/lib/python3.9/site-packages/pip/_vendor/tenacity/__init__.py", line 291, in wrapped_f
    return self(f, *args, **kw)
  File "/opt/habapp/lib/python3.9/site-packages/pip/_vendor/tenacity/__init__.py", line 381, in __call__
    do = self.iter(retry_state=retry_state)
  File "/opt/habapp/lib/python3.9/site-packages/pip/_vendor/tenacity/__init__.py", line 327, in iter
    raise retry_exc.reraise()
  File "/opt/habapp/lib/python3.9/site-packages/pip/_vendor/tenacity/__init__.py", line 160, in reraise
    raise self.last_attempt.result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 433, in result
    return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/opt/habapp/lib/python3.9/site-packages/pip/_vendor/tenacity/__init__.py", line 384, in __call__
    result = fn(*args, **kwargs)
  File "/opt/habapp/lib/python3.9/site-packages/pip/_internal/utils/misc.py", line 130, in rmtree
    shutil.rmtree(dir, ignore_errors=ignore_errors, onerror=rmtree_errorhandler)
  File "/usr/lib/python3.9/shutil.py", line 718, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/lib/python3.9/shutil.py", line 675, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/usr/lib/python3.9/shutil.py", line 673, in _rmtree_safe_fd
    os.unlink(entry.name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'WHEEL'

I installed habApp via openhabian-config on Raspbian GNU/Linux 11

Thanks

"startLevel":20

Your openHAB instance is not yet started - you have to wait some more. Once it’s fully online HABApp will connect as expected. Hence

2023-08-27 14:28:50.828 [INFO ] [HABApp.openhab.connection           ] - Waiting for openHAB startup to be complete

If it never advances startlevel 20 it’s another underlying problem. Even with incorrect thing configurations you should always reach startlevel 70.


The other issue seems to be a permission error. Maybe try with sudo? I’m not sure about it.

I also would assume that in case the intallation is done using “sudo opnehabian-config” then the directories would be owned by root instead of user openhabian and thus removal also needs to be done using root privileges.

1 Like

Oh - OK I will give it a try.
It feels like I had OH4 running for >5min already - playing around a bit in the UI already.

But I will let it run for some more minutes now.

Thanks.

@Wolfgang_S,

I will try this out - but let me figure out the root cause for the other problem first.

i use the squeezebox-binding for having music in some rooms and actually i cannot get it work. i am not sure if it is since i updated habapp because nearly same time i switched the logitech music-server from another rpi to the same on wich openhabian is running.
i have an item

String iSbPlayer_Favorit "Senderliste[%s]" <none> {
    channel="squeezebox:squeezeboxplayer:squeezeboxServer:squeezeboxPlayer:playFavorite"
}

where all my favourite radiochannels are stored in the state description. this always worked for me but now i see in the log the state description is always None

2023-08-28 11:59:06,434 [INFO ] [My_HABApp] - ### ItemResp(type='String', name='iSbPlayer_Favorit', label='Senderliste', category='none', tags=[], groups=[], link='http://localhost:8080/rest/items/iSbPlayer_Favorit', state='6', transformed_state=None, state_description=None, unit=None, command_description=[], metadata={}, editable=False, members=[], group_type=None, group_function=None)

although if i check with rest-api (api explorer in main-ui) i see there should be a state description, the response body shows:

{
  "link": "http://openhabian:8080/rest/items/iSbPlayer_Favorit",
  "state": "6",
  "stateDescription": {
    "pattern": "%s",
    "readOnly": false,
    "options": [
      {
        "value": "0",
        "label": "DASDING 98.9 (Euro-Hits)"
      },
      {
        "value": "1",
        "label": "SWR3 95.5 (Top 40/Pop)"
      },
      {
        "value": "2",
        "label": "RT1 SÜDSCHWABEN 93.9 (Deutsche Musik)"
      },
      {
        "value": "3",
        "label": "Ostseewelle HIT-RADIO Mecklenburg-Vorpommern (Adult Contemporary)"
      },
      {
        "value": "4",
        "label": "fantasy lounge (Electro)"
      },
      {
        "value": "5",
        "label": "1LIVE diggi (Top 40/Pop)"
      },
      {
        "value": "6",
        "label": "MDR JUMP 90.4 (Adult Contemporary)"
      },
      {
        "value": "7",
        "label": "MDR SPUTNIK 104.4 (Top 40/Pop)"
      },
      {
        "value": "8",
        "label": "Bayern 3 98.4 (Hot AC)"
      },
      {
        "value": "9",
        "label": "ANTENNE BAYERN Classic Rock Live (Deutschland)"
      },
      {
        "value": "10",
        "label": "ROCK ANTENNE 94.5 (Rock)"
      },
      {
        "value": "11",
        "label": "Bayern 1 91.3 (Hit-Klassiker)"
      },
      {
        "value": "12",
        "label": "RnB Radio (Deutschland)"
      },
      {
        "value": "13",
        "label": "Antenne Bayern"
      },
      {
        "value": "14",
        "label": "bigFM"
      }
    ]
  },
  "commandDescription": {
    "commandOptions": [
      {
        "command": "0",
        "label": "DASDING 98.9 (Euro-Hits)"
      },
      {
        "command": "1",
        "label": "SWR3 95.5 (Top 40/Pop)"
      },
      {
        "command": "2",
        "label": "RT1 SÜDSCHWABEN 93.9 (Deutsche Musik)"
      },
      {
        "command": "3",
        "label": "Ostseewelle HIT-RADIO Mecklenburg-Vorpommern (Adult Contemporary)"
      },
      {
        "command": "4",
        "label": "fantasy lounge (Electro)"
      },
      {
        "command": "5",
        "label": "1LIVE diggi (Top 40/Pop)"
      },
      {
        "command": "6",
        "label": "MDR JUMP 90.4 (Adult Contemporary)"
      },
      {
        "command": "7",
        "label": "MDR SPUTNIK 104.4 (Top 40/Pop)"
      },
      {
        "command": "8",
        "label": "Bayern 3 98.4 (Hot AC)"
      },
      {
        "command": "9",
        "label": "ANTENNE BAYERN Classic Rock Live (Deutschland)"
      },
      {
        "command": "10",
        "label": "ROCK ANTENNE 94.5 (Rock)"
      },
      {
        "command": "11",
        "label": "Bayern 1 91.3 (Hit-Klassiker)"
      },
      {
        "command": "12",
        "label": "RnB Radio (Deutschland)"
      },
      {
        "command": "13",
        "label": "Antenne Bayern"
      },
      {
        "command": "14",
        "label": "bigFM"
      }
    ]
  },
  "editable": false,
  "type": "String",
  "name": "iSbPlayer_Favorit",
  "label": "Senderliste",
  "category": "none",
  "tags": [],
  "groupNames": []
}

the only difference i see is that in habapp the wording is "state_description" but in rest-api it is "stateDescription"

does anybody use the state description and can tell me how i can use the informations from it?

That wasn’t my experience, but I could have done something wrong. Do I need to switch the branch to development before running the build command? I moved my retail store’s install to docker from openhabian.

It was a bug introduced in 1.2-DEV1. There is a new DEV2 that should work as expected. Can you confirm?

Yes - you need to switch to the dev branch before running the build command. Otherwise you will build the latest release.

@Schrott.Micha : Have you figured it out?

1 Like