Skip to content

Power readings, and plugctl wait for a power level - #11

Merged
virzak merged 1 commit into
masterfrom
feature/power-wait
Nov 29, 2026
Merged

virzak merged 1 commit into
masterfrom
feature/power-wait

Conversation

@virzak

@virzak virzak commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

On devices with a power meter, a job can now tell whether the load came back up after a cycle.

  • state shows the draw in watts (power_w in --json) on devices with a meter: Kasa KP115, KP125 and HS110 plugs, and Kasa bulbs.
  • plugctl wait <plug> --above 2W | --below 1W [--for 5s] [--timeout 60s] reads the meter every second until the level holds for --for without a break, so a spike at power-on does not count. On timeout it exits 1 with the last reading; a device without a meter fails at once.
  • Library: Plug::power (defaults to no meter), Connected::power and wait_power, PowerCondition, PowerWait, and Error::NoPowerMeter / PowerTimeout. Kasa handles both power_mw and the first HS110's power in watts.

Tested: unit tests for both reply formats, no meter, a hold broken by a dip, and the timeout. On a KL125 switched on: state shows 10.8 W, wait --above 2W --for 5s succeeds after about 6 s, and wait --below 1W fails with the last reading 10.8 W. Switched off, wait --below 1W --for 2s succeeds at 0.0 W. An HS103 says it has no power meter. Not tested: a plug's meter (none here).

@virzak
virzak force-pushed the feature/power-wait branch from 7e3738b to 6f15f02 Compare November 29, 2026 21:28
@virzak
virzak changed the base branch from feature/plug-lock to master November 29, 2026 21:28
@virzak
virzak force-pushed the feature/power-wait branch from 6f15f02 to 88b0060 Compare November 29, 2026 21:34
@virzak
virzak merged commit d68d69a into master Nov 29, 2026
3 checks passed
@virzak
virzak deleted the feature/power-wait branch November 29, 2026 21:59
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.

1 participant