Skip to content

docs: add standalone example login script - #171

Merged
KJonline merged 1 commit into
Pyhass:devfrom
matt-thepie:feat/example-login-script
Oct 20, 2026
Merged

KJonline merged 1 commit into
Pyhass:devfrom
matt-thepie:feat/example-login-script

Conversation

@matt-thepie

Copy link
Copy Markdown
Contributor

Summary

Adds examples/example_login.py, a standalone script showing the full login flow against the real Hive API. Several issues ask for exactly this, and the docs examples at pyhass.github.io still reference deviceLogin and Hive.Auth, which no longer exist.

  • First run: password + SMS, registers the machine as a trusted device, saves the device credentials to hive_device.json (owner-only permissions, gitignored). The password is never stored.
  • Later runs: device_login() with the saved credentials, no SMS prompt.
  • Both paths then start_session() and print every discovered device.
  • README gains a short pointer to the example.

Verification

Run twice against a live account on the current dev branch (with the SSO parser fix from #169 applied locally, since the Hive SSO page changed on 2026-10-20):

  • First run prompted for the SMS code, saved hive_device.json, and listed 73 devices across binary_sensor, climate, parent, sensor and switch.
  • Second run printed "Logging in with the saved device credentials (no SMS)", did not prompt for SMS, and listed the identical 73 devices.

Also: full pytest tests/ passes (1061 tests, coverage unchanged); ruff, mypy and pylint (10/10) pass on the example.

Note: the example depends on #169 to work against the live service today; without it auth.login() raises HiveUnknownConfiguration: SSO login page returned no data.

Closes #68, closes #57, closes #63, closes #65, closes #109

🤖 Generated with Claude Code

Adds examples/example_login.py: password + SMS on the first run, with the machine registered as a trusted device and credentials saved to hive_device.json (owner-only, gitignored); later runs use device_login and skip SMS. Verified live: second run skipped SMS and listed the same 73 devices.

Closes Pyhass#68, closes Pyhass#57, closes Pyhass#63, closes Pyhass#65, closes Pyhass#109

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.96%. Comparing base (2979710) to head (d55daaf).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #171   +/-   ##
=======================================
  Coverage   99.96%   99.96%           
=======================================
  Files          30       30           
  Lines        2643     2643           
  Branches      310      310           
=======================================
  Hits         2642     2642           
  Partials        1        1           
Flag Coverage Δ
unittests 99.96% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@KJonline
KJonline merged commit b9dd532 into Pyhass:dev Oct 20, 2026
13 checks passed
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.

[BUG] [FEATURE] Example login script Issue getting device password Issue with refreshtoken Auth & Docs

2 participants