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

Add getEnergyData() Re: #86 #87

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

IJMacD
Copy link

@IJMacD IJMacD commented Oct 31, 2022

Authored by @bacheshrew in #86 (comment)

Pull request suggested in #86 (comment)

@fishbigger
Copy link
Owner

Hi,
This looks great. Do you know what units the inputs should be so it can be added to the documentation?

@IJMacD
Copy link
Author

IJMacD commented Nov 4, 2022

Hey,

it should be called like this:

startTs = 1667556000 # Unix Timestamp 2022-11-04T10:00:00+0000
endTs   = 1667642400 # Unix Timestamp 2022-11-05T10:00:00+0000
interval = 60        # One of: { 60, 1440, 43200 } for hourly, daily, or monthly precision

p110.getEnergyData(startTs, endTs, interval)

It's important to note though, the timestamps do need to be provided and in the correct order but they are somewhat ignored by the plug.
The data returned will always be at the start of a local day (00:00) regardless what time of day the timestamp referred to.
e.g. if you provide the timestamps above and your local timezone is UTC+0 then results will be returned from midnight rather than 10 am.

Example output:

{
  "result": {
    "local_time": "2022-11-04 10:59:57", 
    "data": [1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 
    "start_timestamp": 1667520000,
    "end_timestamp": 1667606400, 
    "interval": 60
  }, 
  "error_code": 0
}

@Elanis
Copy link

Elanis commented May 27, 2023

It works indeed, but their API is really chaotic:

  • Hours are completly ignored, it always start at midnight of the timestamp_start (as you said)
  • When querying daily data, initial date is ignored, it uses 1st of the specified month
  • When querying monthly data, initial date is ignored as well, it uses January of the specified year
  • Timestamp end is often ignored (it's padded with zeros in the end)

Dropping this comment here, since I just spent a whole morning figuring out how data are returned ...

maresmar added a commit to maresmar/TapoP100 that referenced this pull request Feb 22, 2024
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

Successfully merging this pull request may close these issues.

None yet

3 participants