scottbonline / sense

Sense Energy Monitor API
MIT License
174 stars 45 forks source link

daily_usage and daily_solar off by ~4 hours #16

Closed plucpel closed 6 years ago

plucpel commented 6 years ago

I run this every minute to update current power, current solar, daily solar and daily usage.

I have noticed that my daily usage (and solar) max values get reported about 4 hours past midnight (I am located on the US east coast). Is this an issue with the API ? Or could the script be modified to accommodate for time zone ?

kbickar commented 6 years ago

If you compare the current daily usage from the app compared to what the API reports, are they different?

Is the system clock set to the local timezone (datetime.now().isoformat() should return the current time)?

plucpel commented 6 years ago

API and app are the same as of now. I have not bothered yet to check at 4AM

I checked and the system time zone is set correctly. In fact, the log files show that the Sense data is 'reset' to 0 only at 4AM local time (EDT). Script is set to run every minute but log only shows when value is actually changed. From this it would seem that the live data acurate but the 'day' used for trending data is from 4AM to 4AM EDT instead of midnight to midnight EDT. (EDT being the timezone on the sense monitor)

Line 458: 2018-05-22 00:11:02.551 [vent.ItemStateChangedEvent] - daily_usage changed from 26.14312 to 26.504879 Line 2855: 2018-05-22 04:01:03.366 [vent.ItemStateChangedEvent] - daily_usage changed from 26.504879 to 0.700113

kbickar commented 6 years ago

The API requires a timestamp in the current day, but before 4 AM it shows previous day's data.

Any time after 4 AM shows all of the current day (including usage before 4AM, so I changed it to request from 12 PM rather than the actual time.

plucpel commented 6 years ago

Thanks for the quick fix !