Skip to content

Add support for get_energy_data#23

Merged
almottier merged 2 commits intoalmottier:mainfrom
maresmar:main
Feb 24, 2024
Merged

Add support for get_energy_data#23
almottier merged 2 commits intoalmottier:mainfrom
maresmar:main

Conversation

@maresmar
Copy link
Copy Markdown

This pull request adds support for get_energy_data calls. It allow you to query for a historical data about power consumption. You could specify time window and interval. I tested my PR on Tapo P110 with firmware 1.3.0:

>>> from PyP100 import PyP110
>>> dev = PyP110.P110("10.0.0.1", "abc", "cdf")
>>> dev.getEnergyData(1706825847, 1708643847, MeasureInterval.DAYS) # Show power consumption per day sice 1st Feb 24
{'local_time': '2024-02-23 00:18:54', 'data': [806, 820, 925, 892, 852, 854, 839, 836, 842, 831, 841, 821, 809, 822, 800, 805, 793, 794, 0, 0, 0, 344, 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], 'start_timestamp': 1706825847, 'end_timestamp': 1708643847, 'interval': 1440}

This PR was based on code and comments from fishbigger#87, it will probably resolve #17

@almottier
Copy link
Copy Markdown
Owner

Hello,
thanks a lot for your contribution! I am not able to test it because I only have P100 here.
Could you add it to the documentation in the README.md under Energy Monitoring - P110?

@maresmar
Copy link
Copy Markdown
Author

Hi, I added a few lines to the README.md. I haven't been able to experiment with the current implementation in a long term yet, so I summed up an observation from others.

@almottier almottier merged commit 118f7bb into almottier:main Feb 24, 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.

P110 - full energy kWh information (not day or month)

2 participants