Teemu R. 8501390c61
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
Add a note to emeter guide being kasa-only (#1512)
Related to #1511
2025-02-25 22:44:44 +00:00

1.1 KiB

Get Energy Consumption and Usage Statistics

:::{note} The documentation on this page applies only to KASA-branded devices. :::

:::{note} In order to use the helper methods to calculate the statistics correctly, your devices need to have correct time set. The devices use NTP (123/UDP) and public servers from NTP Pool Project to synchronize their time. :::

Energy Consumption

The availability of energy consumption sensors depend on the device. While most of the bulbs support it, only specific switches (e.g., HS110) or strips (e.g., HS300) support it. You can use {attr}~Device.has_emeter to check for the availability.

Usage statistics

You can use {attr}~Device.on_since to query for the time the device has been turned on. Some devices also support reporting the usage statistics on daily or monthly basis. You can access this information using through the usage module ({class}kasa.modules.Usage):

dev = SmartPlug("127.0.0.1")
usage = dev.modules["usage"]
print(f"Minutes on this month: {usage.usage_this_month}")
print(f"Minutes on today: {usage.usage_today}")