HABApp - Easy automation with openHAB

You can create a Switch and link it to the channel. That’s the easiest and fastest solution.
The switch will turn on and immediately off again when the event is triggered.

As an alternative you can use the scheduler with self.run.on_sunrise or self.run.on_sunset to directly run a function.
I’ve migrated all my sunrise/sunset rules away from the astro binding and into the internal scheduler because it’s much more flexible with the offset and earliest/latest option.

Giving this a try!

Just set it up and then an hour later had a vague recollection that the HABApp config file had long/lat settings in it. Thus if you decide to go this way be sure to set those values. Unsure if HABApp can get those from the OH config.

That’s not possible (yet), you have to set the values yourself (or get some really funny sunrise/sunset times).

Removing HABApp_events.log file/ how to check from openhab if habapp is operating

I recently switched to OH3 and implemented a set of rules in HABApp which work fine.
After several days, I realized that rules were not triggering anymore. Logs stopped at a certain time, even though openhab was still operating. On the other hand the habapp service was crashed. The status log showed that the file system was read-only. I then realized that zram was full: i am using a raspberry pi v4 with openhabian and zram. As my persistence is rrdj4 i am sure it was a problem related to the logs.
I had to rapidly restore the functionality of the system and i rebooted, so i am not exactly sure what was causing so many logs. I’ll check in the next days what’s going on. Meanwhile I noticed that
the HABApp_events.log is pretty big: is there a way to periodically remove it ( by modifying the logrotate system: I do not know this very much)?

A second related question is: how can I check from openhab that habapp is running, i.e. is there some smart way to implement an heartbeat? I was thinking of an openhab rule that periodically changes an item and checks if a corresponding habapp rule reacts to that item change.

Final question: would it be possible to make the habapp service continue working even if logs cannot be written?

Thank you

Just set a corresponding size in the logging configuration

Just enable the ping in the HABApp configuration

It’ll crash eventually - there is no way around it.

Good news everyone!

I just released HABApp 0.31.0!

4 Likes

you are awesome, and habapp is fantastic. Thank you!

1 Like

Copy that!
And I do not give a flyining fuck that “mee too” is not wanted on this forum.
It is very well deserved!

3 Likes

Thank you @dan12345 and @NilsOF for the very kind words!
They are specially motivating because creating the last version was very exhausting since I’m currently really lacking time.
Thanks guys!

3 Likes

I am testing HABApp and I wanted to open a https connection to openhab. But I guess that currently only mqtt has the TLS support. Is that correct?

That is currently correct.
What are your plans on how to use HABApp? Do you want to connect through a reverse proxy?

I would like to eventually replace the DSL Rules with the HABapp. Openhab is only accessible via a reverse proxy, since I have switched all my HTTP connections to HTTPS.

Sounds good.
If you run HABApp on the same machine as openhab it should still be available without https.
For testing from another machine it is indeed needed.

Hi @Spaceman_Spiff,

i have added a PR to enable ssl connections to openhab, since i’m also running my test instance behind an (ssl-enabled) reverse proxy - would you mind verifying?

Cheers,
Alex

I would like to create an event listener to listen to events to all events. While the docs of listen_event suggest that passing None as item name would allow to listen to events of all items there is an assert in the constructor of the EventBusListener preventing this.

Any idea how to listen to events independent of a particular item? In particular I would be interested in listening ItemAdded events from openhab.

Dominik

That was the way it was implemented before but I did not like it. I removed the implementation but it seems that I forgot to modify the docs.
Currently it’s only possible to subscribe to changes if you already know the item names which means the item has to already exist.

You can iterate over the existing items and create the according listeners for every item.

What exactly are you trying to do?

Since the upgrade to OH 3 my influxdb persistence did not work any more and I had implemented it with a few lines of code in HABApp. Currently I iterate at startup over all items to create listeners. However, this way I miss Items that got created after HABApp was started and I need to rember to refresh that rule. An alternative would of course would also to check for new items.
Funfact: Since I updated yesterday to OH 3.2 M4 the OH persistence is working again.

An alternative would be to cache the name and listener in a dict and periodically iterate over all items again and add the missing listeners. But that’s just a workaround.
I’ll create something for the listeners in the next releases.

But I’m happy you were able to come up with a quick and easy workaround in HABApp!

Hi All,

again i think that i do not see the forest because there are so many trees.

Please assume that my house has a bunch of windows and i like to get a notification if a windows i open for more than 15 minutes. WIndows (the state) are defined as a gourp of window contacts with an or function, because sole window have more than one wing. If there is only wing thant a windows is represented just as an contact.

So far i managed to get a notification after 15 minutes with the countdown job and distinguish between a contact group and a contact to set the listeners.

Now i am at the point the creat the different window watchers.

One way is to create a parameter file with all the windows an iterate through the entries an create a watcher. I have done that for my thermostates.

for thermostat in HABApp.Parameter('thermostats', 'thermostats').value:
    Thermostat(thermostat)

Works like a charm. My question is now could i do a simlilar thing with a group like this?

for thermostat in get_item('myGroup).members:
    Thermostat(thermostat)

Did’nt get it in my mind at the moment and what ist the best solution.

One benefit from the parameter file i see is that i could trigger to reload the rule if the file changes

An new question to understand the count down better.

1.) countdown(time) creates a countdown job that runs time seconds if the job ist started with reset()

2.) get_next_run() return the timestamp the countdown is down to zero. it return Null if the countdown is not started with reset

3.) cacel() cancels the countdown and the countdown could not be restartet with reset() after a cancel and the job is deffered

Are these statements are correct?

So there is no way to stop, reset and restart the countdown. That means that if for any reason the count down needs to be stopped the way ist to call canel und create a new countdown job afterwards.