HABApp 23.09.0

Good news everyone! I’ve just release a new version:

HABApp 23.09.0

This is a huge release which completely reworks the connection logic for both openHAB and mqtt.
Other notable changes:

  • Switched version number scheme to CalVer (Calendar Versioning): YEAR.MONTH.COUNTER
  • Fail fast when a value instead of a callback is passed to the event listener / scheduler
  • Completely removed types and type hints from traceback
  • Completely reworked connection logic for openHAB and mqtt
  • Added support for transformations from openHAB
  • Updated dependencies:
    • Improved performance
    • Support for docker secrets and environment variables in the config file
  • Support sending scheduler datetimes to an item
  • Search in the docs finally works again
  • Updated dependencies
  • Docs work again

Environment variables in config


Transformations

from HABApp.openhab import transformations

TEST_MAP = transformations.map['test.map']  # load the transformation, can be used anywhere
print(TEST_MAP['test_key'])                 # It's a normal dict with keys as str and values as str

# if all keys or values are numbers they are automatically casted to an int
NUMBERS = transformations.map['numbers.map']
print(NUMBERS[1])   # Note that the key is an int

Sending scheduler datetimes to an item:

job = self.run.on_sunrise(self.my_function)
job.to_item('item_name')  # can be openHAB item or HABApp internal item
4 Likes

Thanks for your work :metal:
I will update my test-system this evening :slight_smile:

1 Like

There doesn’t seem to be a corresponding image on hub.docker.com :

https://hub.docker.com/r/spacemanspiff2007/habapp/tags

Unfortunately CI was broken. You can use master to get 23.09.0.
The next release will appear again as expected.

1 Like

Good news everyone! I’ve just release a new version:

HABApp 23.09.1

This is a small update that includes warnings for broken links between items and things and a fix for CI.

1 Like

Thank you, 23.09.1 did work and is visible on docker hub now.

@Spaceman_Spiff - Thank you! I’ve got it loaded on my test system. On the road right now but working as I can during time off. I had to take about a month off so I may not be totally up to speed on the state of HABApp affairs, but noticed that there is now Transformation support, which is great. Guessing that Actions are not yet available, or did I miss that update? Your work is incredible.

Its great to have search available in the docs! Also, what does this mean: Support sending scheduler datetimes to an item

I must be really missing something because I am not aware of scheduler datetimes?

If you use the scheduler and want the next execution date in an item there is now an easy way for it.
This code snipped will run the my_function every day on sunrise and additionally post the next time of execution to an item.

# Scheduler as usual
job = self.run.on_sunrise(self.my_function)

# This is new
job.to_item('item_name')  # can be openHAB item or HABApp internal item
2 Likes

Very nice. I need to figure out how I’d use that in my current setup.

On the last flight I was on (somewhere over the Mediterranean or Sinai) I got a custom logger working that I will post code example for soon. I know there have been some questions about making one of those, and I’d like to know if I did it correctly.

1 Like

I have a rule in place that prevents from moving the shutters up when they would close anyway in 30 mins. I’ve implement it a long time ago but this new function makes it much easier.

1 Like

Just an hour ago stopped my 1.1.2 docker container and started the new 23.09.1 image.
Amazingly everything is working perfectly as before.
Have to spend some time to see what’s everything new in this release.
Nice job done @Spaceman_Spiff

Good news everyone! I’ve just release a new version:

HABApp 23.09.2

This is a small update that includes a fix of the Thing model (big thanks thanks to JHK) and a fix for mqtt issues (big thanks to dobernhard)

2 Likes

Very nice. Would you care to show it as an example as I am about to take the switch from DSL to HABApp and my first target is a cool automation of my window blinds…

Regards.
Hakan

Hi Sebastian,

One question.
Ich found this link to a widget for controlling a rollershuter card

There they use a rule to control When the shutter has to move down.
The rule looks to act exactly to The determined time hh:mm

Is there something possible with habap?
So a rule that runs every minute, an hits then the chooses time?
I know that I can run a rule every minute. But will this then hit the time?

i also was searching for a solution but i did not want a rule that triggers regularly and always check if the condition mets.
so i realized it in a different way, with the (habapp) self.run.on_every_day(time...
i only use the basic_ui, but i can set different times for each shutter, and depending if it is a holiday or a workday, looks like

for example the item i defined for a workday looks like:

Number iBuero_Fenster_Ro_opentime_work "Werktag auf[JS(numberToClock.js):%s]" <office>

(i do not mind but the only disatvantage could be that i only have one arrow to increase or decrease the time and so i set the steps to 15 minutes)

in habapp i have a rule that triggers when the time changes, if the listener already exists it will be cancelled and a new one will be created:

    def create_listener_morning(self):
        '''
        Erstellt den Trigger zum Öffnen am Morgen, immer passend ob Werktag oder Feiertag
        '''
        if self.listener_morning is not None:   # (ist nur beim 1. Aufruf noch None)
            self.listener_morning.cancel()

        open_at = 'opentime_work' if SwitchItem.get_item('iHeuteFeiertag').is_off() \
                                  else 'opentime_holiday'
        numeric_time = NumberItem.get_item(self.get_item_name(open_at)).value
        hour = int(numeric_time / 60)
        minute = int(numeric_time % 60)
        self.listener_morning = self.run.on_every_day(time(hour=hour, minute=minute),
                                                      self.morning_open)
        self.log.debug(f'Open {self.shutter_name} at {hour}:{minute}')

so i only have one trigger with the exact time to open the corresponding shutter

2 Likes

Ok, that would be also enough for me.
But never used these with listeners.

So I need to read about this things.
So your rule just watch the time items. If they change they trigger this python function, creates a new listener, and then if the time is reached the action happens?

yes, thats how i realized it for me to open my shutters in the morning. i didnt want to trigger a rule in timegaps 24/7 and always check if the time is reached to do the action. my rule only triggers to the desired time and then runs the action. the listener is only needed to be able to cancel, for exampke the desired time was 8:00 and you change your item to 8:30. without cancelling you would create a second listener and the action would run at 8:30 but also still at 8:00