Skip to content

Make README example work on all devices and note Python 3.12 requirement - #647

Merged
lexpostma merged 1 commit into
mainfrom
docs/readme-example-device-support
Dec 3, 2026
Merged

lexpostma merged 1 commit into
mainfrom
docs/readme-example-device-support

Conversation

@lexpostma

Copy link
Copy Markdown
Member

Fixes #591

What

  • Example: telegram() only works on the P1 Meter and system(power_on=True) only on the Energy Socket. The example called both unconditionally, so it raised UnsupportedError on every device type. Both calls are now guarded with device.supports_telegram() / device.supports_state(), with a comment explaining why.
  • Installation: states that Python 3.12+ is required. On older Python versions pip silently resolves to 6.3.0 (the last release with requires_python >=3.9), which has no HomeWizardEnergyV1 and no measurement(). That is what the reporter of problems running the example script #591 ran into on Python 3.9, and pip install --upgrade cannot get past it.

Testing

Ran the updated example unchanged against mock v1 devices serving the fixtures from tests/v1/fixtures, with 10.4.1 from PyPI. It now completes on HWE-P1, HWE-SKT, HWE-KWH1, HWE-KWH3, HWE-WTR, SDM230-wifi and SDM630-wifi. Only the P1 fetches the telegram, and only the Energy Socket sends the state update. Before this change it failed on the P1 (State is not supported) and the Energy Socket (Telegram is not supported). Not tested against real hardware.

🤖 Generated with Claude Code

The example called telegram() (P1 Meter only) and system(power_on=True)
(Energy Socket only) unconditionally, so it raised UnsupportedError on
every device type. Guard both with the device's supports_*() checks.

Also state the Python 3.12 requirement under Installation: on older
Python versions pip silently installs 6.3.0, which does not match the
example.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.33%. Comparing base (25504e4) to head (cd70939).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #647   +/-   ##
=======================================
  Coverage   99.33%   99.33%           
=======================================
  Files           9        9           
  Lines         751      751           
  Branches       79       79           
=======================================
  Hits          746      746           
  Misses          2        2           
  Partials        3        3           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lexpostma lexpostma self-assigned this Dec 1, 2026
@lexpostma
lexpostma requested a review from nvanofwegen December 1, 2026 11:48
@lexpostma
lexpostma merged commit a196d2f into main Dec 3, 2026
33 checks passed
@lexpostma
lexpostma deleted the docs/readme-example-device-support branch December 3, 2026 10:02
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.

problems running the example script

2 participants