We're aware that some users are experiencing technical issues which the team are working to resolve. See the Community Noticeboard for more info. Thank you for your patience.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Tapo P110 Download Data

Options
2»

Comments

  • tux900
    tux900 Posts: 412 Forumite
    Part of the Furniture 100 Posts Name Dropper Combo Breaker
    edited 10 September 2022 at 11:45PM
    sandy700 said:

    Now to make sense of it.

    Does this help?

    #   today_runtime = Today's total plug relay on time (in minutes)
    #   month_runtime = Past 30 days total plug relay on time (in minutes)
    #   today_energy = Today's total energy consumption (in Wh, reset at midnight)
    #   month_energy = Total energy consumption for the current month (in Wh)
    #   local_time = Local time
    #   past24h = Total energy consumption for each of the last 24 hourly slots (relative to now, oldest to current hour) (in Wh, or average W over the hour which is the same)
    #   past30d = Total energy consumption for each of the last 30 days (relative to now, oldest to current day) (in Wh)
    #   past1y = Total energy consumption for each of last 12 months (relative to now, oldest to current month) (in Wh)
    #   past7d = Total energy consumption for each hour of the last 7 days (relative to now, oldest to current day and each containing the 24 hourly slots from midnight to midnight) (in Wh)
    #   current_power = Current power consumption (in Watts x 1000)

    If you get a couple of day's worth of readings it starts to make more sense what figures are going where, what's being added up to give sub-totals, the order of figures etc.
  • sandy700 said:
    BlueShrew said:
    If you (or a friend) like playing with Python code, you can actually talk to each plug device to get quite a lot of data from them. Just Google 'fishbigger p110 python' and go to the first GitHub link for example code.

    I have mine set up to poll each devices around my network and store all the data in text files. You can then do as you like in whatever tool, eg: Excel, to calculate costs, plot data, etc.
    I had a look at that site and have come up with an output on my raspberry pi like this.

    {'result': {'today_runtime': 346, 'month_runtime': 464, 'today_energy': 41, 'month_energy': 46, 'local_time': '2022-09-10 22:56:21', 'past24h': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 12, 12, 2, 0, 0, 5], 'past30d': [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, 5, 0, 0, 41], 'past1y': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46], 'past7d': [[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], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 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, 0, 0, 10, 12, 12, 2, 0, 0, 5, 0]], 'current_power': 0}, 'error_code': 0}

    Now to make sense of it.






    For the lists of data between square brackets (known as a 'json' data structure, if you want to Google it) here is my summary of what I see:

    past24h : Gives you 24 values in a list, each being the total for each of the previous 24hrs, relative to when you retrieved the data
    past30d : Gives you 30 values in a list, each being the total for the last 30 days, relative to when you retrieved the data
    past1y : Gives you 12 values in a list, each being the total for each of the last 12 months, relative to when you retrieved the data
    past7d : Returns a list of lists in the form: [ [..], [..], ..]. Each inner list represents 24Hrs of data (listing the totals for each hour of the 24Hr day). There are 7 of these 24Hrs lists, meaning the 'past7d' value contains 7x24 values, providing you with the total for each hour of a 24Hr day over the last 7 days. 

    Remember: If you run your script at two different hours of the same day, expect the numbers to shift slightly, as everything is relative to when you run the script. 
  • I can now output the data as a .csv file now to figure out how to output partial data, say, past24h on its own. 

    data = p110.getEnergyUsage()
    with open("p110.csv", "a", ) as f:
        f.write(str(data))
        f.write('\n')
        f.close()

    this forum really screws up formatting.


Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 350.9K Banking & Borrowing
  • 253.1K Reduce Debt & Boost Income
  • 453.5K Spending & Discounts
  • 243.9K Work, Benefits & Business
  • 598.8K Mortgages, Homes & Bills
  • 176.9K Life & Family
  • 257.2K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.