[APP][Pro] Better Logic Library - Just some better logic, variable and library management

If numeric value of a logic or a device updates, then send to InfluxDB , tis is what InfluxDB app does for all numeric values including Logics and numeric values from devices (like temp, hum, etc). But not for BLL variables (yet).

Yeah, but InfluxDB currently has listeners for all capability values from all devices.
There is (currently) no direct way for InfluxDB to listen to BLL variable changes.

The only thing InfluxDB could read is the FlowTokens BLL generates, but the Homey SDK has no “if flowtoken changes” methods.
Building a every-second-check on all flowtokens, would kill Homey. (and still be not accurate enough in some cases).

I have already thougth of this, because i need the same implementation for the AVDs: Autoupdate on BLL-variable/or Chronograph-timers change.
In which i myself have the same issue: how to receive certain changes from BLL/Chronograph, without killing the API (chronograph would also update a lott, minimum of 1 every second a for each timer/transition/stopwatch that is running).

N.b. And yes, i could send a api call to the InlfuxDB (if an API call was implemented).
But, i would also than need to do this for DC, Chronograph, etc.
And that will mean: BLL would grow and grow, even if people are not using any of the other apps that BLL would push notifications to.
For BLL, it needs to be the other way around: Apps need to listen.
Also, send multiple API calls to different client-apps each time a variable is changed, that would create slowness for each variable changed. Better to have Apps listen to one push from BLL.

This is why protocols like MQTT exist, but since that might be OTT you can also look at Server Side Events, where BLL would run an SSE server that clients apps can subscribe to for updates.

1 Like

Thanks Robert, seems like a good alternative indeed!
Altho my first thought right now is, i hope the memory buildup in api.realtime can be solved.

Well, good news so far @M_a_r_c_o.
I have just update the BLL and BLL-npm package (on my dev environment) and created a way that apps can listen to variable updates.

On Docker (so, not really Homey), Memory grows a bitt when i use my heavy test, but after a (short) while drops back, and it doesn’t keep growing if i keep running it, it just grows a few MB and later drops.
So, just some working memory.

Now, my test is updating 6 variables at once, and doing that 80*3=180 in a row, thus: 1080 variable updates in a few seconds.
Without memory build (on Docker).
What i mean by that, there is no memory buildup in the Client App (in this case i am testing right now with Simple Log).

So, ill try to implement this in the Device Capabilities App.
If that works as it should, it could potentially be implemented in the InfluxDB.


Perfect, thanks! I keep my fingers crossed tha it will work out!

1 Like

@M_a_r_c_o Well, it’s looking good so far :slight_smile:

I have just implemented Reflection in AVD:

I have set the 6 performance variables and run my 1080 update flow.
The memory of DC increases a little (few MB on hp2023, so less than 10%) and drops back.
When BLL is uninstalled, DC doesn’t grow at all (ofc, but just FYI).

I have placed the basis in the BLL NPM package and will leave a request for @balmli for the InfluxDB with the needed code and example.

1 Like

Okay, @Peter_Kawa, and others, coming soon (ready in develop):

BLL has a new build-in function: time

time(format, timeMs?, timeSec?)

This function will return the given time (from ms or seconds) in the requested format.
Handy to convert (milli)seconds into timestamps!

(It took 11 days.)


Very usefull for the new feature coming to the Advanced Virtual Devices from the Device Capabilties app.

Reflection of values in AVDs

1 Like

All in test now:

Hi all,

I want to extract only the first word from a string-tag inside an advanced flow. And I’m sure it should be possible with one of the cards. But I’m can’t find some examples how to use the BLL functions.

I want to do something like this:

to extract only the first name from a tag. But I have no idea how to use it or if I am on the right track.

Well, remove the var tag line, and place tag as argument to the function (between its “()”). Thus: function(tag)…
Then, you can use the Execute BLL expression as Tag, write Voornaam([[token]]), and run the card.

Thanks Arie. Took a bit of trial and error but I got it working. Turned out I also needed to put the tag between quotes. :sweat_smile:


Oeps, indeed, sorry m8.

Wondering if someone can help me with what I think should be a fairly simple question but I just can’t quite work it out. I am using OpenWeather to get forecasts for several days ahead, with each daily forecast being its own device in that app. One of the properties of the device is the forecast date/time which displays in Homey in the form “03/25/2023 12:00”. I would like to extract the name of the day (i.e. “Saturday”) from this date/time stamp. It looks like BLL should be the answer but I can’t work out how to do it.

I can see that if I wanted today’s date as day name I would use {[date(“dddd”)]} in a card accepting BLL expressions. Also it looks like I should be able to pass a specific date to that something like {[date(“dddd”,”tag-containing-datetimestamp”)]} but that isn’t working. I’m wondering whether maybe it’s expecting just a date rather than a date and time, or maybe there’s some other formatting I need to do somewhere along the line?

This is what my flow looks like so far:

I also previously tried this:

Ignore me, as expected it’s far simpler. Didn’t see I could type my own format into the “Format date as…” card.

Just in case anyone else struggles with the same thing: