Security Sensor LastTrip behavior
-
Ah, I see. Well, I know (I think I know) that I researched this behaviour thoroughly when doing the initial implementation, but still having a Vera, I may be able to check that. It' s just that I don't have any motion sensors attached to it currently. Perhas someone else can help us to check it out?
-
I would not be surprised if this was one of these "not so smart" features of the vera and in my case it is not even relevant to the z-way bridge but it can be:
Examples:
- Say I want to use a motion sensor to turn on the light and wait for a certain interval of time without any tripping before turning it off. I used this LastTrip time stamp to measure that time... bummer. The time will be off by quite a bit since it gets updated by the untrip event.
- I have Home Assistant and a tomographic presence detection system sending updates to an openLuup motion sensor. I set one to send updates every 2 seconds (because its event based logic seems to not quite work) no matter what the status is. This LastTrip variable gets updated every 2s... making it not very useful.
-
@akbooer said in Security Sensor LastTrip behavior:
Oh, wait, yes I do. Does the time toggle on trip AND untrip?
Not completely sure to understand the question.
The LastTrip variable does get updated to os.time with both trip and untrip. The code calls for an update every time a set variable call is made to the tripped variable of the security sensorID and that's the problem. It would be easy enough to create a new variable through a plugin or in the set variable function if the original behavior actually serves a purpose. For now I am trying to see if it does on my setup. It is however a misnomer for the variable since it really doesn't record the last time the sensor was tripped. It records the last time the sensor state got updated... -
So I can see now why one would want the "LastTrip" variable to record the untrip event... for door sensors where potentially someone could run a scene off of this timing. It doesn't make sense for a motion sensor since it isn't really an event per say for that type of sensor, it is a self reset of the sensor. I have now modified the code to only record the time if the "Tripped" value has changed unlike what it is doing now. Ideally I would have preferred a different behavior according to the type of security sensor.
PS: made a pull request with a proposal. For the motion sensors.
-
I have tested this for quite few days now and it all makes a lot more sense at least for the logic I used. I am even wondering why one wouldn't create another timestamp variable "LastUntrip" rather than using LastTrip for both trip and untrip. It appears indeed that having it tag both types of event was the behavior on the vera and I think i will keep my version for the motion sensors since it makes all my motion sensed lighting behave with the delay expected.
-
Since openLuup is luup on steroids, I'm officially suggesting differentiating its behavior, while retaining the luup original one for compatibility. So, something like LastTrip/Untrip in a different service definition should work better than altering it and causing troubles to other plug-ins assuming a different behavior.
-
I have an alternate suggestion. Preserve the Vera Luup behavior, and create new state variables for the alternate behavior, perhaps TripTime and UntripTime? Maybe come up with a prefix to denote openLuup-specific states, and apply this throughout?
-
The reason for my post was to try to get opinions and insights for the source and usage of this behavior.
I like the @toggledbits ' suggestion. Though the initial behavior doesn't appear to be well thought through, I think it is water under the bridge and it would be a bit too risky to deviate from it. I was going to change my PR to add functionality rather than modifying existing ones. I am thinking of adding LastTripTime and LastUntripTime? -
The reason for my post was to try to get opinions and insights for the source and usage of this behavior.
I like the @toggledbits ' suggestion. Though the initial behavior doesn't appear to be well thought through, I think it is water under the bridge and it would be a bit too risky to deviate from it. I was going to change my PR to add functionality rather than modifying existing ones. I am thinking of adding LastTripTime and LastUntripTime?@rafale77 said in Security Sensor LastTrip behavior:
Though the initial behavior doesn't appear to be well thought through
You say that almost as if it wasn't the norm...
...and that would have gotten me banned over there...
Edit: to embellish with a more useful comment... regardless of how stupid the behavior, I guarantee you, from personal experience, that someone relies on it.
-
Ahhh, now I remember one more thing which bugged me about this. It is that ALTUI displays the LastTrip value for the sensors by default and the fact that it would display a time which did not correspond to the last trip event mislead me. In openLuup, this behavior is coded in the luup.variable_set function which means that I can't just modify it for specific devices using a different device implementation file. Maintaining the original behavior and just adding an extra variable would mean that modifications of ALTUI would be needed to change what it displays... right now the variable doesn't even relate to the time the variable last changed or was last tripped. It just shows the time of the last "luup.variable_set" for the tripped variable event.
-
Ahhh, now I remember one more thing which bugged me about this. It is that ALTUI displays the LastTrip value for the sensors by default and the fact that it would display a time which did not correspond to the last trip event mislead me. In openLuup, this behavior is coded in the luup.variable_set function which means that I can't just modify it for specific devices using a different device implementation file. Maintaining the original behavior and just adding an extra variable would mean that modifications of ALTUI would be needed to change what it displays... right now the variable doesn't even relate to the time the variable last changed or was last tripped. It just shows the time of the last "luup.variable_set" for the tripped variable event.
-
You are right, I just went back to the ALTUI code and I can see that it's hard to do. I am not so verse in JS so I tried avoiding it. It makes for more changes but it is the safer route.
to answer your question, let me test further to see if we can think of even better ways to do it.