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

BLL is Live!

If you are an App Developer and want to know more about how to include this into your App or how to let your App support BLL coding, goto the [APP][Pro] Better Logic Library - For Developers Forum Topic.

Part of: Better Logic Library - Just some better logic, variable and library management

Homey’s first real Library: Better Logic Library!

The Better Logic App has a new addition: A library and library management for other apps to consume.

This Topic describes how users can use these functionalities.

BLL Coding

Within all flowcards that supports BLL coding, you can add any BLL expression within the next codeblock: {[ expression ]}.
You can use this f.i. within the Save Image Token flowcard from the FTP Client App
image

This image will be saved with the custom timestamp the user writes himself:
image

To be continued…

2 Likes

App Settings

Here is a description about the new App Settings in the Better Logic Library App.

Variables

Here you can add, edit and delete variables.

To add a new variable, click on Add variable to open the new variable card.
image

Coding

Here you can see how to use coding and try examples.

Click on the Example (eye) to show the usages down below, which is also shown in Locale/TimeZone by default.

Locale/TimeZone

Here you can configure the locale or language and timezone to use by default for coding.

  • Within coding you can always define a locale or timezone.

Formats

Here you can alter the definition of any default datetime formats for the default locale.
This will be applied to every app using the BLL coding or DateTime.

Functions

Here you can add functions that you can use in expressions and BLL coding.

BLL Coding

BLL codings are expressions within text-arguments in flowcards.
In every App that supports BLL coding, for each text-argument in flowcards that goes through the BLL decoder, you can use {[ expression ]} .

Within these expressions, you can use build-in modules, functions and your own customisable functions.

Modules

  • _
    Lodash 4.17.21
  • math
    Math.js 11.3.3

Example
The last one is: {[ _.last(["1", "2"]) ]}.
Result:
The last one is: 2.

Build-in functions

date(format, date?, locale?, timeZone?)
This method will return the current date(time) in the entered format, with respect to the user defined locale (language) en timezone.
Optionally you can supply the date(time), locale and/or timeZone.

Example
Today is a {[ date("dddd") ]}
Result:
Today is a donderdag

Date codings:



Apps that support BBL coding in (certain) flowcard:

Better Logic Library

BLL coding, see the App settings to get a better view on what that is and how to use it.

FTP Client

FTP client now supports BLL coding in all it’s text-arguments, like saving an image to FTP:

Google Services

Google Services now supports BLL coding in all it’s text-arguments, like Start saying […]:

The number method

Within BLL coding or expressions you can use the number method to convert numbers into text, based on your (or another) locale/language.
It supports overloading, and can be used the following ways:

  • number(number, decimals?, locale?)
  • number(number, style?, decimals?, locale?)
  • number(number, style?, styleOption1?, decimals?, locale?)
  • number(number, style?, styleOption1?, styleOption2?, locale?)
  • number(number, style?, styleOption1?, styleOption2?, decimals?, locale?)

There are 4 styles (decimal is the default):

  • decimal
  • currency
  • percent
  • unit

Decimal

Styleoption1:

  • standaard
  • scientific
  • engineering
  • compact_short
  • compact_long

Styleoption2:

  • standaard
  • noGrouping

Currency

StyleOption1:

  • Any valid currency, like USD or EUR

StyleOption2:

  • symbol
  • narrowSymbol
  • code
  • name

Percent

Has no styleoptions

Unit

StyleOption1:

  • acre
  • bit
  • byte
  • celsius
  • centimeter
  • day
  • degree
  • fahrenheit
  • fluid-ounce
  • foot
  • gallon
  • gigabit
  • gigabyte
  • gram
  • hectare
  • hour
  • inch
  • kilobit
  • kilobyte
  • kilogram
  • kilometer
  • liter
  • megabit
  • megabyte
  • meter
  • mile
  • mile-scandinavian
  • milliliter
  • millimeter
  • millisecond
  • minute
  • month
  • ounce
  • percent
  • petabyte
  • pound
  • second
  • stone
  • terabit
  • terabyte
  • week
  • yard
  • year

StyleOption2:

  • long
  • short
  • narrow

Is it possible to add the “GMT +1” part separately?
F.i. Homey locale is English,
but I want to use 24h time, without changing the BLL locale to Dutch.

HH:mm:ss but what is the code for GMT+1?

Sorry Peter, it’s not yet there.
I had no time to finish the 12/24 hours different implementations.
But it will come asap :wink:

Edit:
It’s there:
KK
kk
hh
h
tt
ISO

No hurries, I was just discovering the possibilities :wink:

I know, it’s cool right :slight_smile:

But just added to test:
KK
kk
hh
h
tt
ISO

No fixed GMT+ yet, that will only appear with KK or kk when you have a locale of EN f.i…
(So for you, this will show GMT±, for me it shows CET).
Fixed GMT+ will be Z, but no luck yet to complet this part without adding external node-modules.

And i don’t want that, they are all a few MB, while my custom solution is less then 20kb.

1 Like

Example on how to use a BLL expression

In this case the date method:

image

You can also create default functions/methods in the App Settings (Test version) and use those in these expression flowcards (or BLL coding).

Hi,

Thank you for continuing development of this great app!

I upgraded from the legacy Better Logic today and there seems to be an issue with Math.JS condition card. As POC I created T1 and T2 booleans and a test flow.

If Math.js expression is true. All variants of T1 and T2 being true of false is considered false.
If Math.js expression is false. All variants of T1 and T2 being true of false is considered true.

\ Andreas

Hey, i’ll look into it as soon as i am able.
Could you please create a ticket at bitbucket for it?
QlusterIT / nl.qluster-it.BetterLogic / issues — Bitbucket

Thanks!

Thanks a bunch.
Ticket created: QlusterIT / nl.qluster-it.BetterLogic / issues / #7 - Math.js expression not validating — Bitbucket

1 Like

Not sure if this is the same issue and all mathjs calculations are effected, but my BL math.js calculations does not seems to work anymore since november 14. The calculation is quite simple, it is for calculating the costs of a dishwasher cycle

image

Checking it right now. One moment please.

@aste and @Julian
Solved in the current/latest Live version.

I updated to the latest math.js a few weeks ago.
Internally not different, but the evaluation call itself was changed.

1 Like

Thanks for the quick reply & solution!

1 Like

Works like a charm. Tnx for your quick resolution!

1 Like

There seems to be a bug in Math.js not validating Equal

something == something

is always false.

I’ve tried with and without ““ to no avail.

and an even simplier version

Bitbucket bug: QlusterIT / nl.qluster-it.BetterLogic / issues / #9 - Math.js not validating Equal — Bitbucket

1 Like

Thanks for reporting!

I’ll have a look asap, somewhere next week.