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

Consumption dates delayed #147

Open
speedstercamaro opened this issue Nov 17, 2024 · 4 comments
Open

Consumption dates delayed #147

speedstercamaro opened this issue Nov 17, 2024 · 4 comments

Comments

@speedstercamaro
Copy link

Looks like on the graphs and in the download CSV file the consumption is delayed by 4 days. The consumption lines up with dates 7, 8, 9, 10, 11, 12 and 13. But instead it shows on 11, 12, 13, 14, 15, 16 and 17. image

@tnmendes
Copy link
Owner

tnmendes commented Dec 9, 2024

Hey @speedstercamaro,

Thank you for sharing this information, 4 days difference is a lot. I need to investigate, I need some extra steps/fields when i do the KP125M requests.

@speedstercamaro
Copy link
Author

Hi @tnmendes so I did another experiment looks like my first note of being 4 days behind just happened to match what my usage was 14 days prior. I used my plug for 24hrs on 12/15/24 then had it off for a while. My usage for 12/15/24 then appeared on the graph and data on 12/29/24. So it actually looks like it is two weeks delayed.

@tnmendes
Copy link
Owner

Hey,

In the last few days, I have been finishing developing a new version of Watt (which is already available 6.0.0).
I will try again to investigate how Tp-link is performing when making requests.

I don't have device KP125M (is not available in Europe, but I think it should work like other devices that I have)
This is the request that tp-link are making:

POST: https://euw1-app-server.iot.i.tplinknbu.com/v1/things/*deviceID*/usage
{ "method": "get_energy_data", "params": { "end_timestamp": 1736812800, "interval": 1440, "start_timestamp": 1730422800 } }

Response:
{ "energy_data": { "local_time": "2025-01-13 01:03:20", "data": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "start_timestamp": 1730422800, "end_timestamp": 1736812800, "interval": 1440 } }

start_timestamp 1730422800 = Friday, November 1, 2024 1:00:00 [GMT+00:00] -> 2 months ago
end_timestamp 1736812800 = Tuesday, January 14, 2025 0:00:00 [GMT+00:00]

(the value "12" is the consumption of yesterday January 12, and the consumption "1" is from today Jan 13)

I notice that they are using the region field when making the request start_timestamp and end_timestamp example:
Tp-link is using the field "region": "Europe/Lisbon", but Watt is just calculating the time "UTC"

Probably gonna need to make extra requests for each device to the region field, so then I can calculate the correct start and end time.

GET https://euw1-app-server.iot.i.tplinknbu.com/v1/things/*DeviceID*/settings
{ "nickname": "TWljcm93YXZl", "avatarUrl": "plug", "commonDevice": true, "region": "Europe/Lisbon", "lang": "en_US", "timeDiff": 0, "longitude": -86XXX, "latitude": 41XXX, "defaultStates": { "type": "last_states" }, "specs": "" }

@speedstercamaro
Copy link
Author

May be that was from last month? Now I'm not sure since I haven't had that plug turned on all of January. Last time I had that plug on was 12/15/24
image
image

Not sure what usage it is pulling. I haven't checked my other plugs just this one since it is off and on like that and easy to notice. My other plugs are on all the time.

If you need me to do more tests or troubleshooting let me know to help

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

No branches or pull requests

2 participants