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

**URL:** <https://community.homey.app/t/app-pro-better-logic-library-for-users/71876>\
**Category:** Apps\
**Tags:** app, tools, homey-pro, logic, bll\
**Created:** [November 7, 2022, 10:13pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876 "2022-11-07T22:13:40Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![aste](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/aste/32/9729_2.png) [@aste](https://community.homey.app/u/aste)\
**Post date:** [December 11, 2022, 5:04pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/22 "2022-12-11T17:04:42Z")

</div>

Yes, I do if you have a single condition. But I have 4 of these with an OR in between together with a few other conditions. I think you can have 3 groups of OR conditions. The forth one calls for another solution. Is it possible to have a logic card doing this?  
Zon=a flow tag  
“Zon” == “Köket” or “Zon” == “Hallen” or “Zon” == “Lekrummet” or “Zon” == “Toaletten”  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/4/14ae64c7ac4ed8f72120879c7e96104905034d6d.png)

---

<div class="post-metadata">

**Author:** ![OH2TH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/oh2th/32/111414_2.png) [@OH2TH](https://community.homey.app/u/OH2TH)\
**Post date:** [January 13, 2023, 3:38pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/23 "2023-01-13T15:38:57Z")

</div>

I’m trying to figure out if I can use BLL in advanced flows to calculate what time I should start a task, where I know how many minutes it takes to complete the task and when it should be ready.

Say I want a to start a task $tasktime minutes before 18:00. Somehow can’t get my head over how to do this.

The result should be something I can use to compare to for a trigger.  
For example every five minutes I can run a logic test see if it is now within $tasktime minutes before 18:00 and start the task.

In Homeyscript it would be

```auto
const endDate = new Date();
endDate.toLocaleTimeString();

endDate.setHours(18, 00);

var startDate = new Date(endDate);

var durationInMinutes = 20;

startDate.setMinutes(endDate.getMinutes() - durationInMinutes);
startDate.toLocaleTimeString();

console.log(startDate);

```

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 13, 2023, 4:04pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/24 "2023-01-13T16:04:08Z")

</div>

I made a time calculate flow using this app.  
It might get you going:

> [@The Flow Exchange(r) - Exchange Your Flows with Others!](https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981/72):
>
> Time Calculator With the re-invented Better Logic Library app, we can calculate with time a bit easier without Homeyscript. Apps used: [Better Logic Library](https://homey.app/a/net.i-dev.betterlogic)Other things people need to do to get it working correct? Any questions can be asked in this topic: [https://community.homey.app/t/app-pro-better-logic-library-for-users/71876](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876) TEF: [tef:FLOWS:"H4sIAAAAAAACA7VayXIbyRH9FUbHHGYiVHLtC472ZQ7jk3wjGYxasiiEsd…

You can import this flow right away using the [Device Capabilities](https://homey.app/a/nl.qluster-it.DeviceCapabilities/) app from Arie

 ![Screenshot from 2023-01-13 17-10-41](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/3/b3784ce43bdb57899bccfcf1ca60740abeae175d.png)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 13, 2023, 7:07pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/25 "2023-01-13T19:07:07Z")

</div>

[https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981/73?u=peter\_kawa](https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981/73)

That’s just a Device Capabilities app’s virtual button. Ignore it’s name, I use it for example flows and forgot to rename it.  
**Edit** : adjusted in screenshots and TEF

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [January 14, 2023, 6:06am UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/26 "2023-01-14T06:06:49Z")

</div>

although again it’s a very nice flow from @Peter_Kawa , perhaps here is a somewhat simpler solution.  
Only issue is, it works with UTC (since Homey base time is always set to UTC/GMT).

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/6/4676b9e3b17704abe9b76a5a1778d15642b52b84.png)

`new Date().setHours(18,0,0,0) - Date.now() < 5*60*1000;`

This Condition Expression card will return true when the time is less then 5 minutes before 18u00utc.

---

<div class="post-metadata">

**Author:** ![OH2TH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/oh2th/32/111414_2.png) [@OH2TH](https://community.homey.app/u/OH2TH)\
**Post date:** [January 14, 2023, 7:51am UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/27 "2023-01-14T07:51:05Z")

</div>

Oh, that is a nice one. And easy.

I can always use local offset variable for setHours to cover timezone and DST.  
Can I actually get those with BLL expression? I.e. as a local time offset?

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [January 14, 2023, 9:46am UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/28 "2023-01-14T09:46:11Z")

</div>

> [@OH2TH](#):
>
> Can I actually get those with BLL expression? I.e. as a local time offset?

Well, you can kind off, but not in the easy ‘formatting’ way: because i didn’t find a all-around solutions independend of locale and timezone.

`date('DATETIME', null, 'en')`

You will get a tag, you can use the last number if it’s like this.

But if you get this, you will probably get the same result as me:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/1/11df2740627cddbdeebcd4af819fc87f8be90860.png)

**So, the complete solution would be:**  
`new Date().setHours(18-Number.parseInt(_.last(date('DATETIME', null, 'en'))),0,0,0) - Date.now() < 15*60*1000;`  
(this is true when less then 15 minutes from your local 18u.

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/7/077c2e2d283bd0244488320f8c3bcc24e5eb7d7d.png)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 14, 2023, 1:15pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/29 "2023-01-14T13:15:55Z")

</div>

> [@Arie\_J\_Godschalk](#):
>
> perhaps here is a somewhat simpler solution.

Thanks for the heads up, Arie!  
But from an average Homey user’s point of view, I could in no way ever come up with the code for ‘if BLL expression is true’ with  
`new Date().setHours(18,0,0,0) - Date.now() < 5*60*1000;`  
You have to be quite into javascript imho 😉  
But when I look at the code, it looks quite logical and simple to use 👍

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 14, 2023, 1:40pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/30 "2023-01-14T13:40:23Z")

</div>

> [@Arie\_J\_Godschalk](#):
>
> **So, the complete solution would be:**  
> `new Date().setHours(18-Number.parseInt(_.last(date('DATETIME', null, 'en'))),0,0,0) - Date.now() < 15*60*1000;`  
> (this is true when less then 15 minutes from your local 18u.

This is guru level 🤪  
I only missed the minutes part of the targeted time, a first wild guess seems to work for 'is true when less than 15 minutes before 18.30h:  
`new Date().setHours(18-Number.parseInt(_.last(date('DATETIME', null, 'en'))),30,0,0) - Date.now() < 15*60*1000;`

---

<div class="post-metadata">

**Author:** ![OH2TH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/oh2th/32/111414_2.png) [@OH2TH](https://community.homey.app/u/OH2TH)\
**Post date:** [January 14, 2023, 2:55pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/31 "2023-01-14T14:55:22Z")

</div>

Exactly what I was looking for. As a proof of concept this is what I got done with it:

> [@The Flow Exchange(r) - Exchange Your Flows with Others!](https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981/74):
>
> Run NN minutes ahead of a given local clock time. After some discussion in [https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/23?u=oh2th](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/23) we got this flow working for the original problem. [Screenshot 2023-01-14 at 17.15.38] Apps used: [Better Logic Library](https://homey.app/a/net.i-dev.betterlogic) Builtin: Date & Time Builtin: Logic Builtin: Timeline Thanks for the help, still need to fine tune that. [tef:FLOWS:"H4sIAAAAAAACA9VY227bRhD9FYINYDvQGnvjXtS+tE2AFEj70OQtMYS9zFpEaNKlKDtG4n/vkKJsSVUSpkACBHqQSFGzZ86ZPT…

---

<div class="post-metadata">

**Author:** ![Fleer](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fleer/32/13311_2.png) [@Fleer](https://community.homey.app/u/Fleer)\
**Post date:** [March 17, 2023, 9:06am UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/32 "2023-03-17T09:06:27Z")

</div>

Hi guys,

I am getting a value (“10.01”) as a string from MQTT. How can I convert the format to a number

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 17, 2023, 9:18am UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/33 "2023-03-17T09:18:22Z")

</div>

Use a BLL expression as tag Flowcard with:

```auto
Number.parseFloat("[[tag]]")

```

That should be it. The Number tag will contain it’s value.

---

<div class="post-metadata">

**Author:** ![Rrrr](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rrrr/32/629_2.png) [@Rrrr](https://community.homey.app/u/Rrrr)\
**Post date:** [March 24, 2023, 12:59pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/34 "2023-03-24T12:59:19Z")

</div>

Hi, I read that BLL supports arrays.  
I am interested to see an example.

I want to store the rainfall for each day of the past week and then sum up the rainfall for the past X days to see if I should re-enable the garden watering.

I would also like to track some other value daily for the past month.

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 25, 2023, 3:04pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/35 "2023-03-25T15:04:57Z")

</div>

> [@Rrrr](#):
>
> Hi, I read that BLL supports arrays.

Hey @Rrrr ,

Wel, yeah, not specificly, but generally, BLL supports Arrays.  
because i don’t exactly know how users will want to use this, i haven’t implemented special array functions or anything, but you can do that yourself quite easily.

For instance, here a small array functionality.

- Create a BLL function (in the BLL settings → Functions called `pushAsString` and place this in it’s body:

```auto
function(arr, value) {
  arr.push(value);
  return JSON.stringify(arr);
}

```

- Add a flowcard Set variable to text: Set ArrayTest to `[]`
- Add a flowcard Set variable to bll expression: Set ArrayTest to `pushAsString([[ArrayTest-token]], 1);`
- Add a flowcard Set variable to bll expression: Set ArrayTest to `pushAsString([[ArrayTest-token]], 2);`
- Add a flowcard Execute BLL expression as Tag: `_sum([[ArrayTest-token]])`

This wil result in a token with `3`.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/1/b12bd3ee1ef5b3daed3acc2828d8425f0543bef8.png)

### Flow:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/d/9dba68423a57ac2a8531a074d49adb1d5a46e964.png)

TEF:

```auto
[tef:FLOWS:"H4sIAAAAAAACA+2UTY+bMBCG/0rkU1fCkcE2xvS03eveuqdGERqbIUEiBIFJE6X57x3IdtVIkVartrde+JiZd2beB+EzCyw/sxbDsuYlHpYOQ8C+2W9qPyXCqcNheoD2xPIVVcIOWc4e+x5OLzgEdllfItZS6MusXDxP0sVz7XroT+xCSZiFNZVIgVnltOLe0kXZ0nOHWnKJsbHOSClAs2u3qfdinkKBeRXtwFaOJKbyFVeQGm59mXENxscSpMpKOdUdWS4iRtumdNtTq+1+h6ccui6/bzOad3unKh8wFEPo63ZTHKCvwTVISqLHwId637LZ6Jm9JfM7sKIZKIWunei9xMH3dTd3yNlTjxBw0eL3xWsF8TtAM06a1XrGqTKRlR6AjMeCK5Vk3GqBvNI2iWWZJNZVNxzi7K+CwCP6MWDhmgKPXY/DcHX/YRS/fN2h0uNuf6BIBc2AEWtgCE9baDdYUlUiEsmF5Il+iVWubS7NMk6zb9PYMZDR0I9IoH7bLmfdOGwfh6/zgE+r1Tsmf7ztuV5Hi/jh80y+sj7OMAHuTKq5MpXkTtqKC6UqLXUJiXE35KX4T/6PyCev5H0ijU0N8Co29O+7FLiFUtCHEJlAUaZK4g15lf578kWAzV36N/aL5TDuPub7gTxf6Fz9CWI6jV+dBQAA":/tef]

```

---

<div class="post-metadata">

**Author:** ![Pat\_M](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pat_m/32/56295_2.png) [@Pat\_M](https://community.homey.app/u/Pat_M)\
**Post date:** [April 1, 2023, 2:24pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/36 "2023-04-01T14:24:51Z")

</div>

Hi,

Is there any way to retrieve the Last set" value for a variable in Better Logic? Background: I store temperature data in Better Logic variables. I’m trying to calculate the average/min/max for the temps as long as they are not invalid/too old etc. Instead of storing a temperature (as now) in A) a temp variable and B) a corresponding date variable it would be fantastic if I could access the “Last Set” attribute when determining if the temp is valid or stale.

Many thanks!

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [April 2, 2023, 6:58pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/37 "2023-04-02T18:58:47Z")

</div>

Not yet i think, but that can be created.  
Can you create a ticket for it?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [April 3, 2023, 1:32am UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/38 "2023-04-03T01:32:16Z")

</div>

If I understand your question correct:  
Via a little d-tour it’s available in an [Advanced virtual device](https://community.homey.app/t/share-your-device-advanced-virtual-devices-from-device-capabilities/68676), when you use a textfield, and let Better Logic reflect the ‘Last Set’ property of a var:

 ![Screenshot from 2023-04-03 03-28-18](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/c/5caa0f6872e529e665c8973d89729f5ace5930b4.png)

Then the tag (when the Create Tag box = ticked) with the timestamp is available in flows.

---

<div class="post-metadata">

**Author:** ![Rrrr](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rrrr/32/629_2.png) [@Rrrr](https://community.homey.app/u/Rrrr)\
**Post date:** [April 3, 2023, 6:05am UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/39 "2023-04-03T06:05:44Z")

</div>

Thank you. I like your example. To use an array I would need to replace values in the array ( in my example the array position reflects the day (x=1-7) and the value is the rainfall of day x) or make a calculation of a subset in the array (eg. Total rainfall in the last x days). Is there a way to reference array positions and get the value of those?

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [April 3, 2023, 4:39pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/40 "2023-04-03T16:39:33Z")

</div>

Yeah, place [0] after the token, which would make it technicly:  
[5,6,2,5][0].

This would give you a 5.

---

<div class="post-metadata">

**Author:** ![Pat\_M](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pat_m/32/56295_2.png) [@Pat\_M](https://community.homey.app/u/Pat_M)\
**Post date:** [April 3, 2023, 4:59pm UTC](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876/41 "2023-04-03T16:59:06Z")

</div>

Hi Arie,

I have created a ticket here: [QlusterIT / nl.qluster-it.BetterLogic / issues — Bitbucket](https://bitbucket.org/QlusterIT/nl.qluster-it.BetterLogic/issues) about Last Set value. It would be fantastic if you could implement this as it would be almost like a SQL table with a name, value and updated-field (compared to Homey’s native variables). 👏

[Previous page](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876.md?page=1)

[Next page](https://community.homey.app/t/app-pro-better-logic-library-for-users/71876.md?page=3)
