Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple timestamps appear wrong/dated #30

Open
tjmccull opened this issue Jan 25, 2023 · 5 comments
Open

Multiple timestamps appear wrong/dated #30

tjmccull opened this issue Jan 25, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@tjmccull
Copy link

Hi,

Been using this code for just over a week now and it has been working well! Thanks! That said I am observing that for multiple data points that the timestamp recorded appears wrong (to what I would expect) and in many cases very dated (ie over a year old in some cases). I suspect this may be an issue of the underlying driver but I am not sure. Disclaimer here is that I am brand new to these Edge drivers.

I presume your code is requesting (and logging) the timestamp as reported from the driver of the most recent state change reported, versus recording the timestamp of the monitoring poll.

Once data is in InfluxDB I leverage Grafana to create a custom dashboard to display the current state/trends of my sensors data. With these really old timestamps I need to set my query to go back hundreds of days which makes it really difficult to observe recent changes in the trends/data.

I have many Samsung Smartthings branded sensors (such as door, leak, motion). For the sake of this thread I will focus on the water leak sensors. In some cases the battery field timestamp is over 6 months old. I would have expected the battery to report more discrete changes in levels over time. Or the water state (wet/dry) is over 2 years old in several cases (to be fair they likely haven't detected water since I tested them at install point. Current driver is "Zigbee Water leak sensor" from SmartThings version 2023-01-24T21:01:14.51179409.

I guess my question are:

  1. Are my assumptions correct that the timestamps are linked to that last state change as reported from the driver
  2. Is there a way to log (into InfluxDB) the timestamp of the current poll (which would be the current state), and by polling every min I could gather/log the trend data.

Thanks

@tjmccull
Copy link
Author

  1. Is there a "refresh" API call that would update the timestamp?

@eargollo
Copy link
Owner

The system basically calls SmartThings and logs the last datapoint that SmartThings provides for each device, given that this datapoint is new.

I suspect that you are right on your assumptions. For some sensors, the last datapoint is of the last time the sensor was activated. For instance, I have an external thermometer that does a read every hour. The system will them log only 1 entry per hour even as it calls the sensor every 5 minutes but receives the same date of read. Also, the system records the "sensor date" as it is the read date.

It is possible to either also record the read date and time, or to add some configuration for it to replace the sensor date by the read date and, in this case, record the value at every read independently if it is a new value or just the same data from the past.

For that I would need to change the code to add a configuration per device indicating that for that device we want the system to log the read datetime instead of the "sensor date".

Would that do the trick?

@tjmccull
Copy link
Author

Appreciate the response! Yes, having the ability to have a configurable setting that would allow the system to log the value at every read and record the read datetime (vs sensor date) would solve the challenge I am trying to solve! Adding that feature would be greatly appreciated. There are likely multiple levels one could consider having this configurable option set at; such as globally, by sensor type (under the monitor: portion of the config file) or at each physical device level as you suggested. I wouldn't think a user would need the flexibility to configure this at multiple levels, so picking one that is best for you to implement would be fine. Thanks!

@eargollo eargollo added the enhancement New feature or request label Jan 26, 2023
@eargollo
Copy link
Owner

Just to give an update that I am working on it. I took an initial detour on making the code more unit testable first.

@eargollo
Copy link
Owner

eargollo commented Apr 8, 2023

Take a look at the latest release. You can add the option to use wall clock to a capability. This way it will update influx every time SmartThings is called and use the current time instead of the sensor time.

Let me know if that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants