Skip to content

Add typed accessors for unit power and the bypass lock - #103

Open
andre-richter wants to merge 1 commit into
yozik04:masterfrom
andre-richter:unit-power-and-bypass-lock
Open

andre-richter wants to merge 1 commit into
yozik04:masterfrom
andre-richter:unit-power-and-bypass-lock

Conversation

@andre-richter

Copy link
Copy Markdown
Contributor

Switching the unit off and locking the bypass were only possible with set_values(), so callers had to know the register names and encodings. This adds typed getters and setters for both, so this domain knowledge can be removed from the Home Assistant integration going forward.

New API

Register Values
MetricData.power_on A_CYC_MODE (4610) False for 5 (off), True otherwise, None if missing
Vallox.set_power_on(on) same writes 0 (on) or 5 (off)
MetricData.bypass_locked A_CYC_BYPASS_LOCKED (20552) True for 1 (locked), False for 0, None if missing
Vallox.set_bypass_locked(locked) same writes 1 or 0

Power values other than 0 and 5: The web UI treats only C_CYC_MODE_OFF as off and every other mode as on, in all bundles in tests/data/js/ (2.0.2 to 3.1.6, Helios). power_on does the same.

Bypass lock: the getter follows the register and the manual.

Setter input: set_power_on() accepts only True or False and raises ValloxInvalidInputException otherwise, because a raw register value would be misread: set_power_on(5) would switch the unit on. set_bypass_locked() treats its argument as a flag, like set_timer_enabled(); its raw values 0 and 1 already map correctly.

Switching the unit off and locking the bypass were only possible with
set_values(), so callers had to know the register names and encodings:
A_CYC_MODE 5 means off and 0 means on, and A_CYC_BYPASS_LOCKED 1 means
the bypass is locked to the winter position.

Add the MetricData properties power_on and bypass_locked, and the
setters Vallox.set_power_on() and Vallox.set_bypass_locked(). The
getters return None when the register is missing. power_on is False
only for mode 5: the web UI also treats the other modes, such as test
and self-test, as on. set_power_on() only accepts True or False,
because a raw register value would be misread: 5 is truthy but means
off.
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