How to tell if data is valid or not

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
enco.josh
Posts: 35
Joined: 10 Mar 2014 22:10

How to tell if data is valid or not

Post by enco.josh »

With a battery operated device, how can I best determine if the data is valid or not? I can determine if the device is online or not by comparing the lastWakeup and the wakeupInterval, but is there a way to determine if the batteryLevel is valid or not? I see that there is an updateTime and an invalidateTime associated with each property of the device. What does the invalidateTime represent? I assumed it would be that time at which the value is no longer valid, but I don't think that is the case.

If I instead request the batteryLevel and a couple other properties whenever the device wakes, how much would this affect the battery life of the device?
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: How to tell if data is valid or not

Post by pofs »

Value is invalidated when Z-Way calls method (usually Get) affecting that value. So value is supposed to be invalid from the moment the request of that value is queued till server gets actual value from device. Think of invalidateTime as a moment server decides value is no longer valid. If invalidateTime > updateTime, the value is invalid and being updated.
In case device sends unsolicited report for some value, just updateTime is changed.

But the assumption that value is always valid in case of invalidateTime <= updateTime is wrong. Device might just not report if value has changed.
It is a big question how to decide if the value is actually valid. You may, for example, assume the value should be reported at least once a day, so the following condition is applied:

Code: Select all

invalidateTime < updateTime < (currentTime - 24*60*60) < lastWakeup
It checks if device has waked up at least once for a last day (to not query dead devices), but didn't update the value, and the value is still considered valid (no update in progress). So if this condition is true, you may request the value.
Post Reply