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

That’s a good one too, but doesn’t the {{ [formatted result] / 60 }} calculation need a round to zero digits function?
like {{ round( [formatted result] / 60 ) }}

By the way, apart from your calculation, in case of sun events however, it’s not needed: the sun event time is available as local tag:

and as app tag:

aah, good point. solved that problem way too complex, trying to find out if there is a 0 or not:

Indeed different ways to get there :grinning_face:.

Some thoughts:

  • Your first and second BLL card require a date value as input (so the numerical representation of the date/time stamp in milliseconds). I assume the Zonnenstanden-app provides this tag accordingly. I don’t think it will work if you feed it with a text based formatted time (so formatted as HH:mm, which was the case in the Tesla question)
  • What I find interesting is that the third (Logic) card apparently allows you to divide a text based value (Formatted result, in green) by 60. Normally you can only calculate with actual numbers (tags are blue). The same goes for the addition calculation. Maybe Homey converts the tag to a numeric value, as it only contains numbers, but this is something to consider.

I tried to implement (test variable, as Tesla variable is ‘null’ when it’s not driving), but get an error:

How to solve?

What happens if you change the first letter to lowercase: parseInt ?

2 Likes

Use a small p for parseInt.

Javascript is case-sensitive.

1 Like

Thanks, solved!

Thanks, solved! Didn’t know about case sensitivity.

Hi Arie,
unfortunately some bll functions will occasionally not work. Reboot of the app will fix it until next occurrence. Sadly this will control my floor heating

Lot of thanks for having a look into it.

Thanks

Could you explain: not working?

Wat is not working? Or you getting errors? Invalid values?

Just FYI: when you use {{ and }}, the text and tokens are just directly parsed into the textfield (not only logic cards, but any flowcard using a textfield).

So, if the token/tag contains a number within a text-token, it is still inserted without quotes or anything, thus, in javascript, it is considered a number and can be directly used for calculations.

Just don’t put quotes around the tokens :wink:

1 Like

Thanks Arie for the clarification. Learned something new! I think it’s my lack of JavaScript knowledge :blush:. I am used the having to specifically define the data type of variables and not being able to combine variables with non-matching data types (like strings and integers in numeric calculations).

I’m trying to get my head around the functionality of your screenshot:
The first card returns the temperature without decimals, the devide part is superfluous when you multiply the result with the same value again.

The second card returns the “temperature without decimals” as temperature with 2 decimals.

What do you expect to change with the value from the temperature tag?
Just out of curiosity :wink:

Thanks for taking the time.
My floor heating system (Controme Smart Heating OS) is taking external temperature only if they are valid, based on the following rule:

Due to internal filters, Smart-Heat-OS only accepts temperatures (or humidity levels) that are divisible by 0.125. In addition, the API is limited to two decimal places, i.e., when transferring values with three decimal places, please remove the last digit (e.g., 22.0, 22.12, 22.5, 22.62, 22.75, etc.)
So the purpose of the flow is to get every temperature from my externals sensors as near as possible so that the Controme api will accept it by value and format.

Addition: Even if there is a value without decimals sometime the API is not accepting it without 2 decimals (,00). Strange thing…

I think I hear you.
So the API needs 2.00 as value and doesn’t always respond to a value 2?
That’s very well possible, but in the end it should accept integers (no decimals) imho.

round(12.12345 ,2) rounds to 12.12
but
round(12 ,2) rounds to 12, not to 12.00

So you add the 2 zeros with this card in that case?

Yes this is the purpose of the card

1 Like

Thanks! While you have a hunch about a not stable operation:
Are you aware of the “error output” of adv flow cards? These even provide for an [Error] tag, which you can use in notification cards
The divide function can be replaced by / by the way

round( divide( 
[Temperature] ,0.125 ) * 0.125 ,2)

turns into:

round( ( [Temperature] / 0.125 ) * 0.125 ,2)

I think I’ve got it.
Each temperature is converted to a multiple of 0.125. Then it is truncated after the second decimal and always passed to the API with two decimal places, even if it is a whole number.
The external room temperatures now seems to be as near as possible with the given API of my Controme.

Strange API :wink:

Thanks all for your help
I think the unstable issue was the memory leaks issue in the last firmwares, so BLL stops working.
Currently it seems stable :slight_smile:

1 Like

Maybe its me that is doing something wrong, but when I update a varible with a BLL Expression, the value within the app gets updated when viewing from inside the app setting, but the same variable that I access from a flow does not update.

After executing the flow, the vaiable mqtt gets updated to 2 when viewing from inside the app, but still shows as when viewing from the flow variable list.

Think i found the issue, I need tp stringify the results, this now work as intended.