[APP][Pro] Better Logic Library - For Users

Yes, you can pick any textfield as status indicator.

But no, unfortunately i cannot control colors of text.

As Arie already mentioned, different colors are not possible, but it’s possible to use Emojis: :white_check_mark: / :x: / :warning:

1 Like

I already do :red_square::black_small_square::orange_square:

1 Like

Arie, I already get stuck at the first bullet…

How to create a BLL function?
Do I have to place the code as text into the card?

Thanks
Fred

No.

Goto the BLL app settings :wink:

1 Like

OK. I see Functions > Add function over there. Is that what you mean?

I like the high degree of configurability of this app! You may expect some questions when I start to discover the functionality :wink:

1 Like

Yes! :grinning:

Edit: i have updated the post you referenced.

1 Like

I see quite some ways to control the datetime format.

For my project I want to add the time of receipt of an MQTT message to my data. I now do that in a human readable format, but I also want to do it as “epoch” / (micro)seconds since 1/1/70. Does BLL offer a way to do that?

BTW: now the current datetime is automatically generated by the Google Sheets card that I use for exporting my data. I will need to get the current datetime in a different way before I do the conversion to epoch.

EDIT: I found this discussion, this will give me the thing I look for when I let it return unixTimestamp

In BLL, just use now.

In which card?

Just try a few?

What do you want?
The time in a variable or tag?

What do you want to do with the timestamp or tick?

If you want a tag for instance, use the Execute BLL expression as Tag and fill it with now.

1 Like

I want it as variable. Or better: as something that I can export to a Google Sheets workbook. I succeeded now to do this with a BLL card that can execute code.

1 Like

Hiyas @Arie_J_Godschalk and others,

can you tell me if there is a BLL string operator for “contains”?
or possibly even better, is there a repository with all functions and syntax?

Yes, check the app settings. Goto the link for Lodash. There you will find an operator for contains.
Altho i think "blabla".contains("b") might already work or "blabla".indexOf("b")>-1

Heeey, wonderful, thank you @Arie_J_Godschalk.
I couldn’t find a contain command but that “indexOf” is working. Here is an example that checks if bot Pref2 and Pref3 are not in text1. For those that need one :slight_smile:
image
This is a BLL logic evaluation card, btw.

1 Like

Woah, wouldn’t have found that in the Lodash list. Look at this:


It’s listed as an array command (that is what I knew it for) - no mention of the string usage. Comparing string contents isn’t that something completely different than returning an array index?

@Philippe_Mucher
_.includes('abcd', 'bc'); // => true

2 Likes

Ow yeah! Did not see that one. Thank you, @Arie_J_Godschalk !!

1 Like

When someone is going to sleep, Homey provides the name of that specific person in the Name tag (Naam in my Dutch version). This tag contains the full name (first name and surname). I am trying to extract the first name from that tag via an expression in the BLL execute expression card. However I do not seem to get the expression right.

Note that I have very little knowledge of javascript, so I am learning as I go and trying to combine the various pieces of the puzzle.

To get the first name part I assume I need to use the substring method. And the indexOf method to determine the position in the string where the first name ends.

I tried the following, but I get an error:


As far as I can tell I have included all the necessary parentheses and I assume the expression itself is not correct. Problably the way I am refering to the tag/get the substring of the tag.

I also tried refering to the tag using:
tag(Naam).substring(1, tag(Naam).indexOf(" ")-1)

But that results in the same error.

I hope someone can point me in the right direction.