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

Well, see the above message (not sure about math.js card,) but the expression card would allow for questionmarks, yes.

And no, extra spaces would not mind, the bll expression card handles the input like a javascript expression (with some extra methods available).

The math.js flowcard, which was part of the original BetterLogic app, is a bit different than how the BLL expression (and coding) works.

1 Like

Thank you for this explanation.

Hi!

I’m working on a project to track the contents of my freezer using Homey Pro and the Better Logic Library (BLL). (together with chatgpt and WE can’t get it to work hahah)

  • The contents are stored in a single text variable vriezer_inhoud in JSON format.

  • Example content:

    [
      {"naam":"Spaghetti","porties":2,"gram":600,"tht":"2025-12-10"},
      {"naam":"Soep","porties":3,"gram":900,"tht":"2025-09-20"}
    ]
    
    
  • I use Telegram commands like /vriezer_overzicht, /vriezer_toevoegen, and /vriezer_verwijderen.

  • The overview should be sent back to Telegram as a nicely formatted list (bullets, with THT dates).

  • Adding and removing items should update the JSON (append, increment, filter).

Problem

  • Showing the overview works with the Format JSON as CSV card, but I want to format the output more nicely (bullets, labels, etc.).

  • Attempts with map(), concat(), and join() result in errors like ā€œReference error join is not definedā€.

  • It’s unclear which functions are available in BLL expressions and how to best format a JSON array into readable text.

  • I also need a reliable way to add or subtract portions and grams in the same JSON structure.

Questions

  • How can I format a JSON array into a readable overview (bullets, multiple fields per line) in BLL expressions?

  • Are there examples of a correct map() → string output without using the CSV workaround?

  • What is the recommended way in BLL to modify JSON (append, update, filter) and write it back to the same variable?

Any idea?

Telegram, as in the phone’s Telegram app, or one of the Homey apps?

Hi Peter,

Telegram App voor Homey | Homey this app. So use those commands /vriezer…

If answer to question is X then

Or

If message has been received AND it’s precisely /vriezer then

I want to add, remove something in freezer or check it’s contents

Chatgpt said to use bll and json. But we :grin: can’t get it to work

Ah yes, that app is a great tool to interact with flows.

So I asked Homey bot:
ā€œHow do I store AND edit JSON data in Better Logic Library string variables?ā€
The response seems pretty usable (assuming you’ll get the same reply :grimacing: ).

In the meantime, check out the app ā€œJSON Handlerā€ also built by Arie .

Ahhh didn’t know about that chat got!! Thanks will try!!

How do I use yes/no variable? I am getting a :cross_mark: of :white_check_mark:.

Put every thing between {{ }}

{{(koken actief*ReserveA)+(wasmachine*ReserveA)}}

Example:

MMM, I never used a boolean in a calculation.

1 Like

It’s a bit confusing, but in Better Logic cards, used by Brian, there’s no need for the {{ }} around calculations.

@Brian_Monninkhof I as well think you can’t use booleans in calculations. You can use those in expressions, like

1 Like

Which flowcard are you using?

Use the JSON Handler app for that.

I removed all yes/no variables, I use 1/0 instead.

Hey Brian and @Peter_Kawa ,

I just released another version of BLL.

Whenever a :cross_mark: or :white_check_mark: is send within expressions or codings, it is replaced with a true or false.

This means you can use yes/no tokens again on a HP2023.

4 Likes

Great improvement, but please be aware that this change breaks existing flows that used :cross_mark: of :white_check_mark: in codings.

Well, i don’t think there are many ways coding could really break.

If you have the x or check as string/text output through an expression, yes, that will probably be effect yes.

But unless you have as an yes/no condition 'x'=='x' i think breaking flows won’t happen that easily.

This change was on my list since hp2023, but didn’t have it implemented yet.

Hi all,

For most of you, it’s probably a piece of cake, but I simply lack the knowledge:

A card in the Tesla app generates a time (ā€˜time to destination’) as output (HH:mm). But, I don’t want the ā€˜time to destination’, I want the ā€˜arrival time’. So, somehow, I need to add the ā€˜time to destination’ to the now() time.

I checked all posts here (and to be honest, most look like food for programmers, which I’m not, so most I don’t understand and lots of respect for all Homey users knowing all this stuff) and hoped to find something similar to used. I found, but still after trying two evenings, I didn’t get it work.

So, does somebody know how to make a calculation with times and add the output (e.g. 18:45) of the Tesla app card to the actual time to generate the ā€˜time of arrival’?

Thanks in advance!

Marcel.

This example adds the variable ā€˜Tesla Time’, that contains the time to destination in HH:mm format, to the current date/time stamp (which is in milliseconds) and formats the result again as HH:mm. That is the output of the last card, which you can then use in your flow.

Thanks a lot! I understand your flow, but I couldn’t figure out myself (lack of knowledge, like ā€˜parseInt’ function…).

1 Like

did it a bit differently in a different flow to extract the time of dusk which I use in different flows: