Under cabinet light on dimmed at sunset, on 100% anytime motion

I’m trying to recreate something I had setup in webcore. My kitchen cabinets should come on at sunset to 20% dim, I use a separate scene at bedtime to turn them off. The tricky part is having them also come on 100% during motion any time of the day and return to their previous state after the motion. In webcore I was able to get the current state of the light and store it as a variable and then after motion stopped set it back to the original state. Is that possible with the Rule Engine? I unfortunately neglected to grab screenshots of it in webcore before I lost access to it. Any help would be appreciated.

I posted a reply here and while I was typing thought about it and wanted to give better advice… Only to conclude it wasn’t possible.

I figured you could trigger the rule by your motion sensor, first save the current dim level to a variable. But when I select device attribute, the level is not part of the options… I wonder why? @josh

As @Sgt.Flippy_PJ alluded to, you can use the Set Variable action to snapshot the dim level of a device to a variable and then later use that variable when calling the setLevel() command on your device to adjust the dim level to your saved value.

Keep in mind that many devices will turn on whenever you set their dim level, so in your “return to snapshot” flow, you may want to set the device to the snapshotted level and then turn the device off after that to avoid the light coming back on.

Also note that you can either do this in two separate rules, or you could set the trigger as motion active and motion inactive, then in your flow you could use an IF Condition using the Event Value Context Variable ($context.event.value) to determine if it’s a active or inactive event from the motion sensor.

If you go with the combined approach, you might have to use a nested IF condition for the timing of things. Note that if you get too deeply nested, sometimes it’s easier to shrink your browser size to the approximate width of a mobile phone so all the IF conditions stack on top of each other so they don’t get squished as you start nesting deeply.

The data type of the Variable has to match. For numeric attributes, you’ll need to use a numeric variable.

Aah, my quick and dirty try mixed a text variable with a numeric. Makes sense, thanks!

1 Like

Sorry for not responding sooner, thanks for the suggestions. I’ll try giving this a shot. I’d want the state of the light to go back to whatever it was prior so if it’s after sunset it would likely be 20% and stay on, if it was off would that give me a level of 0 and return it to off if that’s what it was prior to the motion?

That depends on the device. Many devices will report the level as 0 when the device is off, but some report the last known level.

Depending on your use-case, you could add logic to ignore 0 level values if you wanted and retain the last known value.