Need help with a "Date Is" funciton


#1

1) Give a description of the problem
I’m trying to make a piston run on a particular, single day, with a start time and an end time. My energy suppliers have “energy saving days”. They only last for a day and the saving time, when we are to reduce consumption is from 1p to 7p, typically. The problem is I can’t figure out how to get it to run just on the day specified. Not the day before or after. My only choices are:
IS AFTER (this doesn’t work because I want it to run for just one day and not any days after)
IS BEFORE (this doesn’t work because I want it to run the next day not the preceding day)
IS ANY (this doesn’t work because I want it to run for just one day, not on any old day)
IS BETWEEN (this doesn’t work because I only need a single day. I did try making both the between dates the same but that seemed to make it run like IS ANY. I also only want to program it for a single day, not give it a day before and after, that seems silly)
IS NOT BETWEEN (opposite behavior from what I want.)
HAPPENS DAILY AT (I want to set a date, not a time. I tried it and it seem to only run at midnight, not at the times I specified.)

It seems strange that there is no IS or IS EQUAL TO as a selection.

TO SUM UP: How do I make a piston run only on an given single date.

2) What is the expected behavior?
Piston will only run on the single specified day. Not the days before and after and don’t want to program 2 different days to get it to run on the day I want.

3) What is happening/not happening?
It does run when I need it to, but it is also running on days, before and after, that I don’t.

4) Post a Green Snapshot of the pistonimage


Also note that the pistons called out “nest away” and “nest home” are used to catpure and reset the nest to the same settings before and after the event. I am just re-using it here but it is usually run when everyone leaves or returns to the house.

5) Attach logs after turning logging level to Full
Don’t know how much it helps but here are the most current.
7/20/2019, 1:35:18 PM +764ms
+0ms ╔Starting piston… (v0.3.10e.20190628)
+929ms ║╔Subscribing to devices…
+996ms ║║Subscribing to HVAC Override.switch…
+1013ms ║║Subscribing to Door To Garage.temperature…
+1029ms ║║Subscribing to Nest Thermostat - Home (Nest).temperature…
+1225ms ║╚Finished subscribing (317ms)
+1841ms ║Setting up scheduled job for Sat, Jul 20 2019 @ 7:01:00 PM EDT (in 19539.396s), with 3 more jobs pending
+1858ms ╚Piston successfully started (1857ms)
7/20/2019, 1:08:30 PM +191ms
+2ms ╔Received event [Door To Garage].temperature = 86 with a delay of 138ms
+158ms ║Runtime (49879 bytes) successfully initialized in 72ms (v0.3.10e.20190628) (156ms)
+159ms ║╔Execution stage started
+257ms ║║Executed virtual command executePiston (9ms)
+447ms ║║Executed [Nest Thermostat - Home (Nest)].ecobtn (184ms)
+511ms ║╚Execution stage complete. (353ms)
+513ms ║Setting up scheduled job for Sat, Jul 20 2019 @ 7:01:00 PM EDT (in 21149.297s), with 3 more jobs pending
+525ms ╚Event processed successfully (524ms)
7/20/2019, 12:55:43 PM +139ms
+1ms ╔Received event [Zena Marie].time/recovery = 1563641743139 with a delay of 0ms
+174ms ║Runtime (49886 bytes) successfully initialized in 75ms (v0.3.10e.20190628) (172ms)
+174ms ║╔Execution stage started
+176ms ║╚Execution stage complete. (2ms)
+179ms ║Setting up scheduled job for Sat, Jul 20 2019 @ 7:01:00 PM EDT (in 21916.683s), with 5 more jobs pending
+194ms ╚Event processed successfully (193ms)
7/20/2019, 12:55:04 PM +161ms
+1ms ╔Received event [Zena Marie].time = 1563641704386 with a delay of -225ms
+397ms ║Runtime (49881 bytes) successfully initialized in 170ms (v0.3.10e.20190628) (396ms)
+398ms ║╔Execution stage started
+619ms ║║Executed virtual command executePiston (8ms)
+1152ms ║║Executed [Nest Thermostat - Home (Nest)].ecobtn (527ms)
+1228ms ║╚Execution stage complete. (829ms)
+1230ms ║Setting up scheduled job for Sat, Jul 20 2019 @ 7:01:00 PM EDT (in 21954.609s), with 5 more jobs pending
+1239ms ╚Event processed successfully (1239ms)
7/20/2019, 12:54:59 PM +129ms
+0ms ╔Received event [Zena Marie].time = 1563641700000 with a delay of -872ms
+169ms ║Runtime (49889 bytes) successfully initialized in 76ms (v0.3.10e.20190628) (168ms)
+170ms ║╔Execution stage started
+252ms ║║Executed [HVAC Override].on (37ms)
+255ms ║║Executed virtual command [HVAC Override].wait (0ms)
+256ms ║║Requesting a wake up for Sat, Jul 20 2019 @ 12:55:04 PM EDT (in 5.0s)
+986ms ║║Executed virtual command executePiston (10ms)
+1572ms ║║Executed [Nest Thermostat - Home (Nest)].ecobtn (579ms)
+1760ms ║║Executed virtual command executePiston (7ms)
+2046ms ║║Executed [Nest Thermostat - Home (Nest)].ecobtn (283ms)
+2116ms ║╚Execution stage complete. (1946ms)
+2120ms ║Setting up scheduled job for Sat, Jul 20 2019 @ 12:55:04 PM EDT (in 3.138s), with 10 more jobs pending
+2129ms ╚Event processed successfully (2129ms)Preformatted text


#2

Do you mean something like this?

Webcore%20Particular%20Day


#3

Whoa momma… 15 triggers… Ouch!!

Each line with a lightning bolt will trigger this piston, no matter what time or day it is. Each time, it will run thru the code, top to bottom, and execute any code allowed by your conditions.


Anyways, if you want a trigger, @Pantheon’s advice is solid.
(and will actually convert those triggers back into conditions)

If you want to use a condition, then try this:

temp

The system variable {$day} is the day of the month…
Additionally, you can also use {$month} if you wish…


#4

Thanks, guys! Your help lead me to the answer. Here is what I ended up with.


#5

Not bad at all…


I might be tempted to reduce much of the sextuplicate code,

temp

but the functionality looks solid to me, nonetheless. :+1:


#6

For future reference:

Besides reducing the redundancy, you can also reduce the three lines into one doing something like this:

temp


Here is line 24 up close:

temp


Since all six variables have to be checked either way, I am not sure if there is any processing improvements with this last tweak, but it definitely takes up less usable space for the piston. This means that the piston can grow more complex before hitting it’s maximum size. (it’s nearly there now)


#7

Thanks!

Right now it seems to be running ok. No unexpected overrides and isn’t running the last if, endlessly.

I will try you suggestions this weekend.

Thanks, again!