Skip to content

Add support for UWG5#686

Merged
robbinjanssen merged 5 commits into
robbinjanssen:mainfrom
hawknewton:wg5
Apr 28, 2026
Merged

Add support for UWG5#686
robbinjanssen merged 5 commits into
robbinjanssen:mainfrom
hawknewton:wg5

Conversation

@hawknewton
Copy link
Copy Markdown
Contributor

Summary

Add WG5-series thermostat support and refactor the API abstraction layer.

WG5 support

Supported features:

  • OAuth2 login against identity.ojmicroline.com
  • Get thermostats (buildings → tree → control → detail → schedule)
  • Energy usage
  • Regulation modes: schedule, manual, comfort (timed hold), frost protection (standby), vacation (building-level away mode)

New Thermostat fields (all optional, WG5-only): building_id, zone_uuid, is_in_standby, schedule_id, schedule_name.

Architectural changes

The OJMicrolineAPI Protocol has been redesigned from a data-oriented contract (paths, body builders, response parsers) to a behavior-oriented contract. This is a breaking change for any custom OJMicrolineAPI implementations.

Why

The old Protocol assumed all APIs follow the same request pattern: POST to a login path, GET from a thermostats path with a session ID, parse the response. WG5 doesn't work that way — it uses OAuth2 Bearer tokens instead of session IDs, requires multiple chained requests per thermostat (control → detail → schedule), and manages building-level away mode as a separate resource. The old abstraction couldn't accommodate this without forcing WG5 into a session-shaped hole.

By moving the full request lifecycle into the API implementations, each API owns its auth and request flow end-to-end. WD5 and WG4 keep their session-based pattern via SessionOJMicrolineAPI, while WG5 implements the Protocol directly with its own OAuth2 flow.

What changed

  • Old Protocol: login_path, login_body(), get_thermostats_path, parse_thermostats_response(), etc.
  • New Protocol: login(), get_thermostats(), get_energy_usage(), set_regulation_mode()

SessionOJMicrolineAPI — new base class that extracts the session-based login/request logic previously in OJMicroline. WD5API and WG4API extend this, preserving their existing behavior. Session state (_session_id, _session_calls_left) now lives on the API object rather than on OJMicroline.

OJMicroline — now a thin wrapper that delegates to the API object and manages the HTTP session/timeout. Its public interface (login, get_thermostats, get_energy_usage, set_regulation_mode, close) is unchanged.

_request — now accepts a headers parameter, enabling WG5's Bearer token auth alongside the existing session-based auth.

Test plan

  • 52 unit tests pass with 97% coverage
  • All pre-commit hooks pass (ruff, mypy, pylint, pytest)
  • Integration-tested against real WG5 hardware

🤖 Generated with Claude Code

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (61491c2) to head (5d7980d).
⚠️ Report is 533 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #686    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files            9        10     +1     
  Lines          354       521   +167     
  Branches        55        67    +12     
==========================================
+ Hits           354       521   +167     

☔ View full report in Codecov by Sentry.
📢 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.

@robbinjanssen robbinjanssen added the new-feature New features or options. label Apr 22, 2026
@robbinjanssen
Copy link
Copy Markdown
Owner

I will try testing this version with my own thermostat within the next few days, see if everything still works.

@robbinjanssen
Copy link
Copy Markdown
Owner

I can confirm that testing this with my thermostat still works, will merge this :)

@robbinjanssen robbinjanssen merged commit 45cae1b into robbinjanssen:main Apr 28, 2026
15 of 16 checks passed
@robbinjanssen
Copy link
Copy Markdown
Owner

Released as v3.4.0, thanks!

@github-actions github-actions Bot locked and limited conversation to collaborators Apr 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

new-feature New features or options.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants