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

P110 Energy Monitoring support #64

Closed
petretiandrea opened this issue Aug 21, 2021 · 19 comments
Closed

P110 Energy Monitoring support #64

petretiandrea opened this issue Aug 21, 2021 · 19 comments
Labels
enhancement New feature or request
Milestone

Comments

@petretiandrea
Copy link
Owner

Request for energy monitoring support over P110 devices

  • I have found get_energy_usage method, but need to be checked if it's working
  • plugp100 2.1.10b0 contains a new method get_energy_usage() useful to establish if works.
@petretiandrea
Copy link
Owner Author

@gshoebridge update your plugp100 to the experimental version using:
pip install plugp100==2.1.10b0

use and run these snippet and report here the output:

import asyncio

from plugp100 import TapoApiClient


async def main():
    # create generic tapo api
    sw = TapoApiClient("<ip>", "<email>", "<passwd>")
    await sw.login()
    print(await sw.get_state_as_dict())
    print(await sw.get_energy_usage())

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.run_until_complete(asyncio.sleep(0.1))
loop.close()

Thanks

@gshoebridge
Copy link

Happy to help - I'll get onto PC a little later today and

@gshoebridge
Copy link

All done

743e03c849dfa98b94c9394174d8f2544cc6b4d1
{'device_id': '80222EF474BEC01D849DB7F9B01DB7041E800077', 'fw_ver': '1.0.2 Build 210224 Rel.200046', 'hw_ver': '1.0', 'type': 'SMART.TAPOPLUG', 'model': 'P110', 'mac': 'C0-06-C3-E4-AB-5C', 'hw_id': '56DD079101D61D400A11C4A3D41C51DA', 'fw_id': '00000000000000000000000000000000', 'oem_id': 'AE7B616A7168B34151ABBCF86C88DF34', 'overheated': False, 'ip': '192.168.0.59', 'time_diff': 0, 'ssid': 'U0tZNVlSR0s=', 'rssi': -51, 'signal_level': 2, 'latitude': 513553, 'longitude': -18955, 'lang': 'en_US', 'avatar': 'plug', 'region': 'Europe/London', 'specs': '', 'nickname': 'UG93ZXIgRGVzaw==', 'has_set_location_info': True, 'device_on': True, 'ontime': 73274, 'default_states': {'type': 'last_states', 'state': {}}}
{'today_runtime': 740, 'month_runtime': 18675, 'today_energy': 337, 'month_energy': 16210, 'local_time': '2021-08-21 12:23:45', 'past24h': [29, 73, 62, 78, 61, 28, 28, 27, 29, 29, 29, 29, 27, 26, 26, 27, 26, 26, 27, 27, 29, 27, 28, 12], 'past30d': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 311, 914, 1127, 1690, 1559, 1631, 1683, 1478, 1484, 1347, 837, 833, 979, 337], 'past1y': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16210], 'past7d': [[61, 61, 61, 57, 62, 61, 61, 62, 63, 62, 63, 63, 62, 63, 62, 62, 62, 62, 63, 61, 61, 61, 61, 61], [61, 62, 61, 62, 61, 62, 61, 63, 69, 32, 32, 58, 32, 27, 73, 92, 75, 75, 74, 71, 70, 71, 69, 71], [70, 70, 70, 70, 70, 70, 70, 71, 71, 78, 72, 64, 69, 44, 58, 82, 30, 49, 38, 33, 25, 24, 25, 24], [25, 25, 24, 22, 24, 25, 30, 25, 26, 60, 48, 61, 38, 52, 43, 53, 53, 50, 31, 25, 24, 24, 24, 25], [25, 25, 25, 24, 25, 24, 26, 27, 28, 54, 56, 45, 39, 42, 55, 66, 40, 46, 28, 28, 26, 26, 27, 26], [26, 27, 26, 27, 26, 29, 27, 27, 31, 76, 52, 69, 63, 29, 73, 62, 78, 61, 28, 28, 27, 29, 29, 29], [29, 27, 26, 26, 27, 26, 26, 27, 27, 29, 27, 28, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], 'current_power': 40320}
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x10a934250>

Guy

@petretiandrea
Copy link
Owner Author

Thanks a lot. Can you attach a screenshot of energy monitoring from Tapo App? In this way I can understand how these values are used

@gshoebridge
Copy link

There you go sir

image

@petretiandrea petretiandrea added the enhancement New feature or request label Aug 26, 2021
@petretiandrea petretiandrea added this to the Release 1.1.5 milestone Aug 26, 2021
@petretiandrea
Copy link
Owner Author

A new beta version is released (1.1.5-RC1). To install it, reinstall the repository from HACS and check show beta version and select the right version. When install process ends, restart and try to associate your P110. Give me feedback here :)

@gshoebridge
Copy link

Had 1x issue with 1xP100 not loading
Restarting.
Logger: homeassistant.config_entries
Source: helpers/entity_component.py:181
First occurred: 15:59:46 (1 occurrences)
Last logged: 15:59:46

Error unloading entry Power Desk for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 432, in async_unload
result = await component.async_unload_entry(hass, self) # type: ignore
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 96, in async_unload_entry
return await component.async_unload_entry(entry)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 181, in async_unload_entry
raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!

The following integrations and platforms could not be set up:

tapo.sensor
Please check your config and logs.

Logger: homeassistant.setup
Source: setup.py:311
First occurred: 16:04:52 (1 occurrences)
Last logged: 16:04:52

Unable to prepare setup for platform tapo.sensor: Platform not found (cannot import name 'STATE_CLASS_TOTAL_INCREASING' from 'homeassistant.components.sensor' (/usr/src/homeassistant/homeassistant/components/sensor/init.py)).

Just going to try adding power desk (Tapo P110)

@gshoebridge
Copy link

Logger: custom_components.tapo
Source: helpers/update_coordinator.py:219
Integration: Tapo Controller (documentation, issues)
First occurred: 16:11:02 (3 occurrences)
Last logged: 16:14:59

Error fetching tapo data:

@petretiandrea
Copy link
Owner Author

Update Home Assistant to the latest version

@gshoebridge
Copy link

Already there 2021.8.8

:)

@hankanman
Copy link

hankanman commented Sep 1, 2021

@gshoebridge @petretiandrea the platform STATE_CLASS_TOTAL_INCREASING was committed only a few days ago, will be available in HA 2021.9.0 later today on full release: home-assistant/core@7dd169b#diff-12949adc26a35f4bf5628940f9ffd274c30435abc9af1b60e5bd39bf76be198f

@gshoebridge
Copy link

Hi @petretiandrea
The P110 is working great however the power usage information is way out. It is showing as a true entity, working and integrating into the energy module in HA.
I am seeing 55W most times through the day but the power usage in HA is showing as 600+kwh for the day so far.
I would sugest you may be looking at a different (or composite) calculation.
Screenshot :
image

:)

@gshoebridge
Copy link

7ED25CD0-E3EF-4111-A551-B93FEF46546D_1_105_c

@gshoebridge
Copy link

Data run today from your updated script

743e03c849dfa98b94c9394174d8f2544cc6b4d1
{'device_id': '80222EF474BEC01D849DB7F9B01DB7041E800077', 'fw_ver': '1.0.7 Build 210629 Rel.174901', 'hw_ver': '1.0', 'type': 'SMART.TAPOPLUG', 'model': 'P110', 'mac': 'C0-06-C3-E4-AB-5C', 'hw_id': '56DD079101D61D400A11C4A3D41C51DA', 'fw_id': '00000000000000000000000000000000', 'oem_id': 'AE7B616A7168B34151ABBCF86C88DF34', 'overheated': False, 'ip': '192.168.0.59', 'time_diff': 0, 'ssid': 'U0tZNVlSR0s=', 'rssi': -44, 'signal_level': 3, 'latitude': 513553, 'longitude': -18955, 'lang': 'en_US', 'avatar': 'plug', 'region': 'Europe/London', 'specs': '', 'nickname': 'UG93ZXIgRGVzaw==', 'has_set_location_info': True, 'device_on': True, 'on_time': 31570, 'default_states': {'type': 'last_states', 'state': {}}}
{'today_runtime': 1018, 'month_runtime': 31986, 'today_energy': 610, 'month_energy': 24609, 'local_time': '2021-09-03 17:17:26', 'past24h': [22, 18, 19, 18, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 7, 51, 59, 69, 62, 53, 53, 82, 82, 18], 'past30d': [0, 0, 0, 311, 914, 1127, 1690, 1559, 1631, 1683, 1478, 1484, 1347, 837, 833, 979, 681, 644, 1174, 1612, 1034, 843, 857, 348, 0, 0, 0, 266, 667, 610], 'past1y': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23066, 1543], 'past7d': [[26, 26, 25, 26, 25, 25, 26, 26, 28, 27, 29, 27, 23, 9, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 22, 8, 57, 50, 27, 23, 9, 29, 7, 7, 6, 8], [7, 7, 7, 8, 7, 7, 7, 8, 22, 51, 62, 44, 60, 67, 64, 61, 60, 23, 22, 18, 19, 18, 9, 9], [9, 9, 9, 9, 9, 9, 10, 10, 7, 51, 59, 69, 62, 53, 53, 82, 82, 18, 0, 0, 0, 0, 0, 0]], 'current_power': 40274}
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x10ffbdfd0>
guyshoebridge@Mac-mini ~ %

@petretiandrea
Copy link
Owner Author

Yes you're right, I'm using today_energy which (I think) should be divided by a 1000 factor. I'll release another beta

@petretiandrea
Copy link
Owner Author

petretiandrea commented Sep 11, 2021

A new beta version is released (1.1.5-RC2), try it :) @gshoebridge

@BunpGhost
Copy link

Is it possible to get the "current_power" as an entity?

@petretiandrea
Copy link
Owner Author

Release into 1.2.0 try it :)

@freedomdigital
Copy link

Release into 1.2.0 try it :)

I have P110 working great (on/off) but there are no energy monitoring!
What I am doing wrong ?
TAPO Conroller v1.2.1
HA 2021.12.3

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

No branches or pull requests

5 participants