and/if with times

Moderator: leecollings

Post Reply
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

and/if with times

Post by desertdog »

I tried to write this blockly script where my curtain will open every morning at sunrise, except when the sunrise is before 7:00. In that case they open at 7:00.
Image

Unfortunately, this gives the following error, so it seems you can not compare time like this:
2020-04-02 07:35:00.216 Error: EventSystem: Lua script error (Blockly), Name: Curtains_2 => [string "result = 0; weekday = os.date('*t')['wday']; ..."]:1: ')' expected near 'comparevariable'
Is there any way to make this work?
Ernstl
Posts: 33
Joined: Thursday 08 December 2016 22:44
Target OS: NAS (Synology & others)
Domoticz version: 2020.2 b
Location: Germany, NRW
Contact:

Re: and/if with times

Post by Ernstl »

You Need a Time-Pice (Blue) After the „and“ in the else if line, Not a logic pice (Green).
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: and/if with times

Post by desertdog »

Ernstl wrote: Thursday 02 April 2020 8:14 You Need a Time-Pice (Blue) After the „and“ in the else if line, Not a logic pice (Green).
You mean the "Sunrise < 07:00" part, right? The problem is that there is no time-piece to do this.
Ernstl
Posts: 33
Joined: Thursday 08 December 2016 22:44
Target OS: NAS (Synology & others)
Domoticz version: 2020.2 b
Location: Germany, NRW
Contact:

Re: and/if with times

Post by Ernstl »

Okay, you´re right.
I Think it is not possible to compare to time-points.
Just try:
else if Time=07:00 and Time>=Sunrise
User avatar
Thuis
Posts: 251
Joined: Tuesday 11 September 2018 11:36
Target OS: Linux
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: and/if with times

Post by Thuis »

Hello i am only trying to help, i have done it like this :
Image

Strange one must think it would be a time between AND another time. But with OR it seems to work.
I Love Domoticz ! And the community around it :-)
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: and/if with times

Post by desertdog »

Thuis wrote: Thursday 02 April 2020 13:27 Hello i am only trying to help, i have done it like this :
Image

Strange one must think it would be a time between AND another time. But with OR it seems to work.
Since time is only within one day

Code: Select all

<= 06:00 OR => 22:00
should work the same
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: and/if with times

Post by desertdog »

Ernstl wrote: Thursday 02 April 2020 10:37 Okay, you´re right.
I Think it is not possible to compare to time-points.
Just try:
else if Time=07:00 and Time>=Sunrise
Yes works!
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: and/if with times

Post by AllesVanZelf »

Why not just:

If [Time] => 7:00 AND [Time] >= [Sunrise]
Do [Curtains] = [Open]

Personally I would limit the time to let say 10:00 to prevent opening off the curtains in the evening.

If [Time] => 7:00 AND [Time] >= [Sunrise] AND [Time] =< 10:00
Do [Curtains] = [Open]
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
User avatar
Thuis
Posts: 251
Joined: Tuesday 11 September 2018 11:36
Target OS: Linux
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: and/if with times

Post by Thuis »

Just use OR instead of AND is my finding

between 6:00 or 7:00 not between 6:00 and 7:00 for blockly.

Otherwise it only works on 6:00 and on 7:00 not at 6:01 until 6:59.
Or you want to open the curtains only when sunrise matches the time of 7:00

but that is just me.
I Love Domoticz ! And the community around it :-)
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: and/if with times

Post by desertdog »

Thuis wrote: Thursday 02 April 2020 18:54 Just use OR instead of AND is my finding

between 6:00 or 7:00 not between 6:00 and 7:00 for blockly.

Otherwise it only works on 6:00 and on 7:00 not at 6:01 until 6:59.
Or you want to open the curtains only when sunrise matches the time of 7:00

but that is just me.
There are two lines, the first one:
time = sunrise AND time > 07:00: so that will open the curtain when the sunrise is after 7:00, eg: 7:01, 7:45, etc
second one:
time = 07:00 AND time >= sunrise: will open the curtains at 07:00 when the sunrise is before 07:00
User avatar
Thuis
Posts: 251
Joined: Tuesday 11 September 2018 11:36
Target OS: Linux
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: and/if with times

Post by Thuis »

That is good Thanks :-)
I Love Domoticz ! And the community around it :-)
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: and/if with times

Post by AllesVanZelf »

desertdog wrote: Thursday 02 April 2020 19:04 There are two lines, the first one:
time = sunrise AND time > 07:00: so that will open the curtain when the sunrise is after 7:00, eg: 7:01, 7:45, etc
second one:
time = 07:00 AND time >= sunrise: will open the curtains at 07:00 when the sunrise is before 07:00
You are complicationg things. Please have a look at my post above. It will work in just one line.
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: and/if with times

Post by desertdog »

Your line works but will keep triggering the whole day. If I decide to close the curtains somewhere during the day they will open again since it > 07:00
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: and/if with times

Post by AllesVanZelf »

desertdog wrote: Thursday 02 April 2020 20:29 Your line works but will keep triggering the whole day. If I decide to close the curtains somewhere during the day they will open again since it > 07:00
If you add this: AND [Time] =< 10:00
How would it be possible that it is triggered all day? I do not understand that.
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: and/if with times

Post by desertdog »

It still opens my curtains again when I decide to watch tv with close curtains at 9:30.
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: and/if with times

Post by AllesVanZelf »

That is what you want isn't it? 9:30 is later then 7:00. Maybe we are missing some information. Is this tv part of the script like the script of Thuis?
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: and/if with times

Post by desertdog »

No, I want to open the curtain when it's sunset, if the sunset is 7:00 or later.
If the sunset is earlier than 7:00, the curtains have top open at 7:00.

So say the sunrise was at 6:43 and the curtains have opened at 7:00 as programmed. If for whatever reason (sunlight on my tv, too bright for my hangover, vacuuming the curtains) I decide to close the curtains again at 7:15, I don't want a script to re-open it immediately.
There is another reason I only want the script to open at only 1 specific time, being 7:00 or sunrise. This means in case of an error there is a maximum of two triggers instead of every minute until that between the time you suggest. The curtains are controlled by a motor that doesn't give feedback but stops when there is too much resistance. If for some reason this script keeps firing every minute opening the curtains while already open, it might lose the resistance and keeps on opening. which may lead to overheating
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests