Hey webcore users, having some trouble with an automation. It is really really simple. Motion detection does trigger a log item and run the piston. However, the light never turns on. Anything obvious I should be checking?
/**************************************************************/
/* KitchenLightMotion - ON at night */
/**************************************************************/
/* Build : 8 */
/* UI version : v0.3.114.20220203 */
/**************************************************************/
execute
if
Any of Dining Room Light's, Kitchen Island Lights', or Kitchen Main Lights' motion is active
and
Time is between 40 minutes to sunset and 30 minutes past sunrise
then
with
Kitchen Island Lights
do
Set level to 18%;
Turn on;
end with;
end if;
end execute;
I couldn't figure out how to remove the trigger lightning bolt from TIME. However I realized that once I changed to "changes to" in the first clause, it went away automatically! I'll see if it works tonight, thanks!
If it’s still not working change “time is between sunset and sunrise” to “time is not between sunrise and sunset”.
It helps to check the current values of your system variables. Sunset and sunrise are both today. So I believe the way you have it, it’s checking between today’s sunset and today’s sunrise. I can’t recall if this never matches true or if it only matches during the day - I believe the former.
You can also change it to “time is between sunset and nextsunrise” I believe.
Edit: and yes, I believe you need to enter this line as a condition not a trigger as @Pantheon suggests.
I have used this thought process for years since learning it from WCmore back in my SmartThings days. It might require a little thought to write code that way. In essence, it removes the time/date change at midnight that might cause some problems with execution timing.
I think it goes beyond the break at midnight. Webcore handles sunset and sunrise as points in time (epoch time), not times of day (5:45am). So in essence, I believe the OP is trying to match a time range that starts later than it ends… from today’s sunset to today’s sunrise. IIRC, this will not work in WC… but if it does happen to work, it’ll only match during the day.
Initially, I had a little difficulty mentally getting the "not" part. But after using it a few times, a light bulb in my brain turned on, and I now understand its application. I use this method often.
There are many different ways to write your piston. My BASIC approach would be as follows:
If Any motion sensors change to active <- Trigger
Then
If Time is not between sunrise and sunset <- Condition
Then
with Light
Do
Set level to 18%
Turn On
end WITH
end IF
end IF
This piston might progress to accommodate other factors:
How long should the lights stay on after motion changes to inactive?
What happens to the lights (on/off) if a person stays in the area for several minutes?
What happens if someone walks out of the room and then walks back in?
What other conditions might result in turning the lights on or off?
So BASIC pistons can grow, gaining a life of their own. Just food for thought
I like this style, so I changed it to it, and still nothing - is there a way to see what webcore is evaluating each statement to? Or a way for me to say "print(we got to section 2)" in logs so that I can tell if it's getting into each IF statement appropriately?
The only thing I can think of is that the "time" is a string and the "sunrise/sunset" are "datetime" type in the variables page. Am I using some incorrect "time" variable?
Edit to add:
And, if I use the {$now} variable which is a "datetime" type, I don't get the option in webcore to add an offset to sunset/sunrise times which is pretty annoying! But I also tried this and it doesn't work either (and it is now past sunset):