NO MOTION event missing in device? What to do next?


(Paul) #1

I have been told that the Philio PSM02 does not send a NO MOTION event, only MOTION events when the PIR is triggered.

Are there any other devices with this behavior?

Is it possible to change the status and tile back to no motion? With the current behavior, MOTION events are ignored and not recorded in the ACTIVITY FEED.


(Paul) #2

I have made progress. I add an “motion” / “inactive” after each "motion / “active”.

This works most of the time, but sometimes ST seems to change the order of the events, e.g. First “inactive” followed by “active”.

What I would like to implement is to create a "motion / “inactive” five minutes after receiving a “motion” / “active” event. If I receive a “motion” / “active” within the five minute interval, I want to restart the timer (e.g. not create a new event.

Anyone has any ideas on how to program this in the device type?


(Geko) #3

There is a runIn() API to schedule execution after a certain delay, but it’s been broken for some time. Don’t know if it was fixed in the latest backend update. I use the following:

private def myRunIn(delay_s, func) {
    if (delay_s > 0) {
        def tms = now() + (delay_s * 1000)
        def date = new Date(tms)
        runOnce(date, func)
    }
}

(Paul) #4

Thanks @geko

Any suggestions on how to avoid scheduling multiple request?

Is there something like a persistent variable and say something like if (scheduled < now() ) { scheduled = now() + delay_s * 1000 etc?


(Geko) #5

Yes, you can save your state in ‘state’ map:

state.whatever = "blah"

(Paul) #6

@geko are the state with the context of the device type? E.g. If I have multiple instances of a device type, would a state variable reach across those multiple instances or be private to that instance of the device type?


(Geko) #7

It’s per-instance. There’s no global state, afaik.