Hi. I have a simple rule that i created in Basic Rule.
I tried to use Rule Machine but after a recent update i keep getting an error and no matter the amount of googling I just cant resolve it. Anyway...
All i want is to turn on some dimmable lights at 10% between sunset and sunrise. Then when my motion sensor sees movement i want tye lights to go up to 80% brightness.
So far it works but it did not switchoff at sunrise.
I suspect it might not work correctly at sunset either.
My code os below but not sure why it does not work correctly.
When I run it, the lights light at 80% with no motion then after a few moments they go to 10%. Any motion then they go upto 80%.
So the initial brightness is an issue and the fact its not turning off.
In fairness there is no command to turn them off but i assume the fact i have selected the rule to only run between sunsetvand sunrise made me think it shoukd work.
I am a bit new to hubitat so any help would be appreciated.
Thanks
From app screen...
When GenericMotion activates ...
Dim Wiz RGBW Light on 192.168.68.102, Wiz RGBW Light on 192.168.68.128 to 80
Wait until GenericMotion stops, then ...
Dim Wiz RGBW Light on 192.168.68.102, Wiz RGBW Light on 192.168.68.128 to 5
Rule and pending actions can run ...
Only between Sunset and Sunrise
Required Expression
Time between Sunset and Sunrise
Trigger Events
Time is Sunset
Motion is active
Actions to Run
IF (motion is active) THEN
Dim: light to 80%
ELSE
Dim: light to 10%
END-IF
Wait for expression: motion inactive --> duration 0:03:00
Dim: light to 10%
Wait for expression: time between Sunrise and Sunset
Off: light
Note that I'm using Wait for expression (not Wait for events) because I want to the rule to proceed and turn off the light at Sunrise even if there isn't any motion. I don't like lights turning off on me and prefer to keep the light on at Sunrise if motion is still active or in Wait duration period then turn it off.
You posted in the Rule Machine section so this is an example for the Rule Machine app. If your intention is to stick with Basic Rule then you should go with FriedCheese's approach.
Thanks for the replies.
That works a little better.
Even with the edit the code for the motion action still seems to be running outside the sunset and sunrise period.
I turned off the lights, rebooted the Hubitat and motion turns on the the lights.
I turn off the lights and motion turns them back on outside the sunset and sunrise times. IE in the day.
Any ideas what i am doing wrong?
Thanks again.
No.
None at all. All other 'apps' are blank.
I am trying to see if I can get to the same outcome via Rule Machine but i am finding it harder to get used to and make sense of!
Except for the two simple rules...one that brings the lights on Dim at sunset -10mins and the other that turns the lights off at sunrise +10
Thanks
It's not a complicated rule. You could pause the current rule and recreate it to see if you get the same results. Also turn on the rule logging and see if that provides any clues.
I imported it into Rule Machine and I think it might be working.
I cant seem to use Rule Machine to create the rule from scratch as it errors out when i select the sunset/sunrise option. It never used but now I cant get past this when i select it.
Anyways, we will see.
One thing has struck me though....when editing and testing rules....what is the best way to do the testing? Should i reboot Hubitat each time. Or use the Run Code when there is the option to??
There should be no reason to reboot your hub when testing a rule... unless your writing a rule to do something on reboot. The Run Actions is a great test tool as it bypasses the trigger. Virtual devices are also great to temporarily add as a trigger to test a rule. Testing between two times can be helpful before finally changing to between sunset and sunrise.
This is designed to se the "DIMMER" to 10 at Sunset, then if motion is detected on "SENSOR" set the "DIMMER" to 80 for 2 minutes then return to 10 until motion is detected again. This will repeat as long as the time is between Sunset and Sunrise, at which point it will set the "DIMMER" to 0.
Replace "DIMMER" with the name of your dimmer , and replace "SENSOR" with the name of your sensor.
Note that the 2 minute time delay begins when the "SENSOR" goes from Active to Inactive, with my sensor that takes 33 seconds so the actual delay for this example is 2 minutes and 33 seconds.
Create a 'Rule Machine' Rule, and use these (3) Triggers to start your actions:
("SENSOR") Active
or
When Time is Sunset
or
When time is Sunrise
Create these (2) Conditions:
"SENSOR" motion active
Time between Sunset () and Sunrise ()
Once your Triggers and Conditions are in place use these Actions to control the dimmer:
IF (Time between Sunset and Sunrise) THEN
Dim: "DIMMER": 10
IF ("SENSOR" motion active) THEN
Dim: "DIMMER": 80
Wait for event: "SENSOR" motion inactive and stays that way for: 0:02:00
Dim: "DIMMER": 10
END-IF
ELSE
Dim "DIMMER": 0
END-IF
P.S. I didn't take the time to fully test this code so let me know if there are any issues.
Hi folks.
Importing my basic rule into Rule Machine seems to have done the trick.
I will shorten the descriptions. More than a good idea!
Just out of interest i have noticed that the motion sensor hascbeen active for more than 12 hours. Now i did move in into a cupboard while testing. If this looses connection with Hubitat whilst active i assume it will stay reprting as active on the hub.
But i have moved it around 30 mins ago and while this did trigger a motion flash of the internal led, i have not activated it since.
Does this mean the Hub has not 'polled' it yet.
If thats what it does?
Oh and hitting 'refresh' in the device detail page does not seem to do anything.
I believe this to be true. I do not believe the hub actively polls devices. I believe the devices report to the hub. One thing to try is to hit the configure button. I believe this is useful to ensure the device is setup properly to work with the current driver.