Calculation of variables (Logic or better Logic)

@Peter_Bittner
Better logic variables have (flow) tokens.

Thanks Arie but I don’t know enough for that to help me. Are you saying I should have used the word tokens instead of tags?
Would you be able to give me an example of how to set up a better logic variable and then use it in a flow.

In app settings of BLL you can manage your BLL variables

In flowcards, when you want to choose a BLL variable, it’s similar to logics variables:
you’ll find logics variables under ‘Logic’, and Better logic variables under ‘Better Logic Library’

But search for the var name is easier I think

When you use Logics flowcards, you can’t use BLL variables and vice versa.
Logic card

Better Logic card shows my BLL variables

1 Like

Thanks very much. So this flow should work?


And I’m assuming that if you want to see the current value of a BLL variable then the only place to do this is in the BLL App?
Edit:
No I see that it won’t. I need brackets. I tried this:
Screenshot 2023-07-09 at 4.31.15 pm
but it still looks like thats wrong as the variable is being set to 0.

Use the set expression card and remove the W at the end.

So the double brackets {{}} is correct?

No, you dont need them, they will make it a Homey calculation and the calculated vvalue will be passed to the expression card. Thats not very usefull or what you want.

I am trying to set a variable to 5000+“variable_name” using the Set card but am having no luck wether I use Better Logic Library or Logic. The 5000+ just disappears and it just sets the variable to the “variable_name”.

I’m obviously doing something wrong.

Show what you are doing?

I want to set up a flow that will turn on devices (such as my car charger) once my solar panels are producing more power than needed to charge the battery or run the home. The maximum the battery will consume for charging is 5Kw, shown as -ve when charging and +ve when discharging. As electricity costs 34c/Kw from the grid and I only get 11c/Kw when exporting back to the grid then it is best to use that capacity if possible.

So I want to set up a flow so that when the Battery is being charged the maximum (-5000) and the Solar production is greater than 5000 + Home Consumption + “Some gap I can set” then turn on a device. I have included a picture of my variables and the flows I have developed to set the value of the variables. The values from the solar system update about every 4 secs.
I want to set T_nettpower to 5000 + Home Consumption + “Some gap I can set”, and then use that variable to turn on the device(s).

Screenshot 2023-08-14 at 7.08.56 am

When I get you right, you want to add the values of some tags, and a real value into a variable?
Then you need someting like this

Thanks - simple isn’t it.

I like the idea of knowing what you suggested using for the values “netto_energieverbruik” and “Power.In.Piek”. I was just going to add some overhead like 1Kw so the charger didn’t turn on and off every time there was a change in the home consumption, but you may have a better way.

Here is what I did.


1 Like

Hi, lots of discussion using the Round function. In my Homeyscript I use the abs function to make sure the variables are treated as +ve. Can you use the abs function in a logic script? I’ve tried abs and Math.abs but neither work.

Screenshot 2024-04-18 at 2.11.25 PM

Elaborate on ‘neither work’ please
This works:
Screenshot from 2024-04-18 15-56-16

Thanks Peter. I think my problem was that as soon as it ran I checked the variable and saw that it contained the formula, but when I waited a bit it turned into the expected result. Looks like it takes a little while to actually do the calculation and return the string.

Edit: Actually, I think that’s rubbish. I’m not sure what I did wrong, but it’s working now.

1 Like