Only when and if and


#1

1) Give a description of the problem
I want to replace ecobee’s smart away home with this code due to the 2 hour activation time.

2) What is the expected behaviour?
when both sensors see unoccupied, I want the ecobee to be in away mode and home when any of two sensors detects motion during certain period.

3) What is happening/not happening?
test result says false all the time when the conditions are met. I am having hard time understanding the difference between trigger and conditions so I want to use only when after evaulating the if statement instead of and. please explain the difference and if I used the time variable correctly. Also,I want to know how to use only when if it can make the piston? more efficient.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
10/16/2019, 1:00:19 PM +71ms
+1ms ╔Received event [Home].test = 1571256019071 with a delay of 0ms
+78ms ║RunTime Analysis CS > 21ms > PS > 40ms > PE > 17ms > CE
+81ms ║Runtime (38543 bytes) successfully initialized in 40ms (v0.3.110.20191009) (79ms)
+82ms ║╔Execution stage started
+103ms ║║Comparison (enum) inactive is (string) inactive = true (2ms)
+106ms ║║Comparison (enum) inactive is (string) inactive = true (2ms)
+108ms ║║Condition #2 evaluated true (22ms)
+121ms ║║Comparison (time) 46819181 is_between (time) 28800000 … (time) 64800000 = true (9ms)
+123ms ║║Time restriction check passed
+125ms ║║Condition #14 evaluated true (15ms)
+128ms ║║Cancelling statement #14’s schedules…
+134ms ║║Requesting time schedule wake up at Wed, Oct 16 2019 @ 6:00:00 PM PDT
+140ms ║║Condition group #1 evaluated true (state did not change) (54ms)
+142ms ║║Cancelling statement #5’s schedules…
+146ms ║║Skipping task 6 because of mode restrictions
+158ms ║║Comparison (enum) inactive is (string) active = false (1ms)
+161ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+162ms ║║Condition #10 evaluated false (13ms)
+164ms ║║Condition group #9 evaluated false (state did not change) (16ms)
+193ms ║╚Execution stage complete. (111ms)
+198ms ║Setting up scheduled job for Wed, Oct 16 2019 @ 6:00:00 PM PDT (in 17980.732s), with 1 more job pending
+211ms ╚Event processed successfully (211ms)
10/16/2019, 1:00:05 PM +442ms
+0ms ╔Received event [Home].test = 1571256005438 with a delay of 2ms
+240ms ║Setting up scheduled job for Wed, Oct 16 2019 @ 6:00:00 PM PDT (in 17994.319s), with 1 more job pending
+252ms ╚Event processed successfully (253ms)


#2

Because you have no triggers, all your conditions are treated as triggers. Have you tried without the ‘only when’ stipulations? Not sure how you set Home/Away but if it changes to ‘Away’ as soon as you leave, it may never execute the ‘away’ on your eco bee and vice versa.

You might have to wrap a trigger around this logic with if any motion sensor CHANGES to inactive, then check if both are inactive.


#3

The problem with all triggers is that, as soon as any of them change status, the piston starts again at the beginning. What you really want is something more like

If All of Motion Sensor 1's and Thermostat 1's motion change to inactive
  then
  if time is between 8 am and 6 pm
  then
    with...
  end if;
end if;

Note that the first if is a trigger, which means it triggers execution at the beginning of the piston. The second if is just a condition.


#4

when I create
with thermostat
do
away() (only while home)

if statement is true but the piston doesn’t execute away() when I pick home in only while. If I leave only while blank, the piston works.


#5

I’m not sure why you’d have to do it, but you could replace the with…only when with
if thermostat mode is home
do away()
end if;
(I’m not sure if “mode” is right. It’s whatever it is that gets changed from home to away.)


#6

there is not much motion at night. Sometimes we don’t move for couple hours and I don’t want to use wait because the Ecobee sensor refresh rate is already about 30-45 mins for occupied to unoccupied. So If I leave the house, it will take about 30-45 plus the wait time I set. what I want is to replace the smart away because of the activation time (2-3hours). So I want the piston to be disabled in night mode and it kicks in as soon as the sensor sends unoccupied signal during daytime.

I don’t know why the rate is so slow for occupied to unoccupied because it changes the state from unoccupied to occupied immediately. So I want the piston to run only when the mode is home or away.

I will try with only when. Thank you so much


#7

So I found the variables needed for webcore in smartthing IDE
image
because on the webcore there are so many similar variables so I didn’t know what to use. so I picked one of variables states sleep in smartthings device info and found a list of matching variables in webcore

I think I can use any variables showed on smartthing device info

image

this is what i tried and worked!
Now i dont need to use time restriction any more. It can just follow my schedule programmed in ecobee.


#8

Been looking for the current program info for my Ecobee in IDE but have not been able to find it, where did you find that if I may ask?

Also what Ecobee thermostat are you using?


#9

I have a smartthings. My Ecobee is connected to the smartthings.

I found that from smartthings my hub portal.


#10

Looks like you are running a custom device handler for it? That might be the difference. I am running the Ecobee integration.


#11

If vs Only when

Instead of having two ifs for home and away, why can’t I use two only whens
For example,

Only when
time is between from 6 pm and 10 pm
with
light
do
turn on light

Only when
time is not between from 6 pm and 10 pm
with
light
do
turn off light

is it related to optimization?


#12

I installed ecobee suite 1.7.7? It is a free version