Homey has quite a steep learning curve. The scarce documentation doesn’t help either, and on top of that you usually need apps written by the community that follow different, inconsistent design concepts.
In short: you are not the problem.
But Homey still has a good concept. It gives you a reasonably stable basis to build on. I have tried various smart home systems and Homey is IMO the best, even if it has some weaknesses.
In a Math.js-expressie card I found this.
Expressie waarde (Tekst) > 00 and Expressie waarde (Tekst) < 06 is waar.
For a part of my need a can work with it.
Now I was thinking of the possibility to use “or” in the same way like
Expressie waarde (Tekst) = 04 or
Expressie waarde (Tekst) = 10 or
Expressie waarde (Tekst) = 16 or
Expressie waarde (Tekst) = 22 is waar
But no.
SyntaxError: Invalid left hand side of assignment operator = (char 5)
The value of the tag Expressie waarde (Tekst) is 22.
Do I have to do it in a other way or is it not working at all.
I just remembered the app Temporary variables which also can do some limited calculations. I checked now and it has no problems with negative numbers, i.e. the following example calculates just fine:
Ignore the zeros, I added them so that the “1-” is displayed in front of the variable and it’s clear that there are no spaces. Maybe @spkesDE has some ideas how to solve that?
So the question is pretty much if you @spkesDE have any idea what can be done to improve the handling of variables within BLL as your app doesn’t have that problem.
Wasn’t there recently a finding that there should be better always a blank before and after the minus? Am not sure whether you did that. Difficult to see.
It is called ternary operator. variable = (condition) ? expression1 : expression2
In the BLL field you delete the “variable =“ part and you can use something like (5 > 1) ? 61: 90;
If you have to do date and time calculations, you might use EPOCH format, the time in milliseconds since 1-1-1970. Then the functions Date.now() and Date(<EPOCHnumber>) come in handy in any field that supports expressions or BLL expressions for BLL variables and fields in AVD’s.
The first one returns the epoch number of the current date & time, whilst the second reverse the operations. Pitty that one cannot use text formatting in the reverse operation, at least I did not find it yet.
I was trying some like Date(1718960326112, “dd-mm-yy HH:mm:ss”).
I will try your suggestions. Thanks
PS: I think there is a difference when you write “date” or “Date”, probably because they are different function from different libraries/packages. In this case BLL library and JavaScript.
Yes, the Date is the default Javascript object, while the date is the BLL Custom date-formating function.
See the BLL settingscreen for more info about the date (and other) method(s).
To be clear, to convert a millisecond to a Javascript Date object, you use the Date(1718960326112)
However, formating it into a certain text-format, you use the BLL date method: date('dd-MM-yy HH:mm:ss')
Using the date with only the format definition, will make the function use Date.now() as input.
However, the optional second parameter/argument to the date method can be any of the input:
A valid Date object, like Date(1718960326112) or Date.now() date('dd-MM-yy HH:mm:ss', Date(1718960326112))
A number, as in milliseconds date('dd-MM-yy HH:mm:ss', 1718960326112)
A text containing a ISO date, like 2022-11-10T19:17:01.439Z date('dd-MM-yy HH:mm:ss', '2022-11-10T19:17:01.439Z')
A text containing a default date makeup (Thus only English format right now)