Vacation light help


#10

You should be getting a much much smaller number (in the 500 range)… the ‘/60000’ should be converting milliseconds (your long number) to minutes… it does when I try that expression???


#11

if i change the Expression from “Minutes” to “Milliseconds” i get a value of 1044
using (($sunset/60000)+30)-($midnight/60000)

Would it work with that? still sounds rather high.


#12

Here’s what I’m getting precisely…


#13

Hmmm… When I tested it yesterday I’m sure it wasn’t doing that… but now it is!!

I think it might be a bug of sorts… changing the attribute between minutes and ms shouldn’t change the calculated value of the expression… but it does!!

@ady624 @ipaterson

Any thoughts?


#14

Ooo you brought the big boys in Robin, hopefully they’ll give us a resolution.


#15

That is currently a known display bug… the value that will be used when the piston runs is what you would expect but the evaluation is displayed incorrectly. The original discussion has a few more examples but there is not a clear-cut way to fix this yet.

Ady and I thought about perhaps having the expression display divided by the appropriate number to show correct units but that has a slew of potential issues. It seems like it will be necessary to pass along some new parameter to identify that the value will be displayed or request the evaluation with a different data type to avoid conversion. This is the third time I’ve seen a post reporting this issue so it might be worth more of my time to find a fix.


#16

Thanks @ipaterson, the good news is i haven’t broken webCoRE, the bad news is this piston isn’t working. All i’m trying to do is randomly turn on a light between Sunset+30 and midnight, for a random amount of time, say 2-5 minutes.
Can you have a look at my piston please and see what i’m doing wrong? Robin suggested to calculate the minutes of Sunset+30 to midnight which sounds good but something in my setup clearly isn’t working.

(($sunset/60000)+30)-($midnight/60000)
any reason why this isn’t working? or can you suggest a better way please.

Here is a copy of the piston with the logs.

Logs
04/01/2018, 06:00:19 +331ms
+8ms ╔Starting piston… (v0.2.101.20171227)
+588ms ║╔Subscribing to devices…
+885ms ║║Subscribing to Z Garden Orange…
+886ms ║╚Finished subscribing (310ms)
+1044ms ║Comparison (time) 25220359 is_before (time) 1515020400000 = false (9ms)
+1106ms ║Setting up scheduled job for Thu, Jan 4 2018 @ 5:25:00 PM CET (in 37479.568s)
+1121ms ╚Piston successfully started (1116ms)
03/01/2018, 16:23:59 +118ms
+1ms ╔Received event [Home].time = 1514996640000 with a delay of -882ms
+160ms ║RunTime Analysis CS > 34ms > PS > 93ms > PE > 33ms > CE
+163ms ║Runtime (39496 bytes) successfully initialized in 93ms (v0.2.101.20171227) (161ms)
+164ms ║╔Execution stage started
+210ms ║║Comparison (time) 62639316 is_before (time) 1514934000000 = false (9ms)
+212ms ║║Condition #9 evaluated false (13ms)
+213ms ║║Condition group #2 evaluated false (state did not change) (15ms)
+216ms ║╚Execution stage complete. (52ms)
+218ms ║Setting up scheduled job for Thu, Jan 4 2018 @ 5:24:00 PM CET (in 86400.665s)
+226ms ╚Event processed successfully (226ms)


#17

This works. Import or modify yours accordingly.


#18

Hi bobbles, yes I tried that one and it didn’t work for me, also 4 variations of it! Nothing happened. And it’s not exactly what i’m looking for, i prefer Robins idea because that fits exactly what i need, i’m hoping andy or ipaterson can help me with this wait randomly from 0 to (($sunset/60000)+30)-($midnight/60000) minutes.

it’s really quite frustrating, not being able to simply randomly turn a light on once, between sunset+30 and midnight for 2-5 minutes. There are no examples of anyone else doing this, at this point i’d even consider Paypalling someone to do this, I’ve been on this nearly a week now.


#19

Will post something for you to try.


#20

How about this. Haven’t tried it but I think it should work.


#21

That looks good, fingers crossed! I’ve already added it, hopefully tomorrow i’ll be able to delete the 7 other pistons i’ve got to try and get this going! i appreciate your effort.


#22

The only thing I can see wrong is that it will not run the first time until the variable has been set to false at midnight.
You could put in another set var so that you have 2 of them.
Say sunset and midnight set the variables.
This way you guarantee it to run on the day.
image


#23

i’ve just manually set the boolean variable to “false”, so it should start correctly first time. something else, i’m not sure if its significant or not, on the list of pistons, i have a countdown timer on the right of 10.40.30 (hrs/mins/secs) but sunset is closer to 4 hours away from me, does that matter? my other failing vacation light pistons have at least 04.04.50… correct to when sunset starts.


#24

Its probably set up a schedule for 10hrs time.
This is when the piston will fire and turn the light on I would think.


#25

Time is before midnight will never evaluate to true, you would need to use Time is before 1 second to midnight or similar to compare to 11:59:59 rather than 00:00:00


#26

i adjusted the piston you gave me bobbles to include before 2358 instead of midnight.

but it’s still giving me a countdown timer of 10 hours, which is midnight for me, when the piston would end. thinking it was when it would randomly turn on would of been too clever!.

so i varied another piston to be rather than “while time is between sunset and 2358”,
to “executes at sunset plus 30”, and “if time is before 2358” on this one i’m getting a countdown timer of 4 hours which is close to sunset for me.

hopefully something will fire as expected. i have other versions of these pistons with and without the boolean variables to give greater chance of success.


#27

OK…here’s my stab at this… Take a look and see, but I believe this will pass the test.

I’m going outside the lines a little bit…that’s for sure. So I take the value for $sunset and convert that into a 24 hour clock value and then stuff it into an Integer…which I then subtract from 2400 to get the number of minutes between sunset and midnight. Then now that we know the number of minutes, it’s just a simple matter of waiting a random amount of time with that value being the upper limit. If you want to wait 30 minutes after sunset, I’d advise adjusting the lower limit of the Wait. Basically you want the piston to fire every day AT sunset.


#28

Awesome Mike, this looks very cute, and how i would of imagined it looking if i had the necessary amount of grey matter to work with. I’ll be back…


#29

@Alwas
As I was near to sunset here in the UK I thought I would give @Mike1616 version a go as it is certainly a lot cleaner than the way I suggested.
Seems like its working like a charm. :smile:
image