The room_1_motion_last times when the motion was last switched ON or OFF. This is usually OK but it’s annoying as on initialisation for example the timers get updated to OFF without motion actually being detected but this still updateds the time.
How can I create a profile that only updates the DateTime when the thing is ON?
I know I can do this via a rules, however the profile solution is elegant and easy with many motion detectors.
In this case, a rule will be the elegant approach, and in fact I don’t think it’s possible at all in a profile. The only alternative profile I can think of would be to use a JS/SCRIPT transform but that will always have to return something so no matter what your DateTime Item’s current state will get wiped out.
To do this in a rule it’s pretty simple.
Keep up the current naming convention you show here
Put all the motion sensors in a Group
Trigger a rule when a member of the Group changes to ON
The rule is a one liner. In JS Scripting it would be something like