I don’t know if this will work as expected. At least I’m using an item to store holiday state and set the state in the script.
By the way, your first line will always return false, as there is no chance that the current day of week is Saturday and Sunday at the same time && is AND, || is OR
I vaguely remember reading a long time ago that scripts do not return values.
They are more thought to be little reusable blocks of script code, not actual functions.
The right way to do it then would be to use items, as Udo already said.
If you need functions, you can do those by using lambdas. There are examples of that to be found in the forum, I am sure.
Yes I know it is error of course
I can set a state of item in the script using sendCommand but one question is it ok that I will have something like this:
callScript(“isHoliday”) // set isHoliday inside a script
if (isHoliday.state==true) {
…
I know that changing a state can take some time and is performed asynchronously .
Can I use “return” in lambda expression? Code that calculate holiday days has many “return” and what I’ve seen in lambda expression examples there was no return - only in the last line I’ve seen value that is returned.