Add On/Off and Away mode support to template platform

Implemented support for On/Off and Away modes in the template water heater
platform, including optimistic control and lambda-based state reporting.

Refactored the base 'WaterHeaterCall' to replace the 'state_' bitmask with
'optional<bool>' for 'on' and 'away' fields. This change was necessary to
enable partial (delta) updates. The previous bitmask implementation did not
distinguish between a field being "set to false" and "not set at all,"
causing unintended state resets (e.g., turning the device off when only
adjusting temperature).
This commit is contained in:
tronikos
2026-02-07 01:35:37 -08:00
parent eb7aa3420f
commit 52af92d4b5
9 changed files with 144 additions and 24 deletions
@@ -414,6 +414,8 @@ water_heater:
current_temperature: !lambda "return 42.0f;"
target_temperature: !lambda "return 60.0f;"
mode: !lambda "return water_heater::WATER_HEATER_MODE_ECO;"
on: !lambda "return true;"
away: !lambda "return false;"
supported_modes:
- "OFF"
- ECO
@@ -424,6 +426,14 @@ water_heater:
- PERFORMANCE
set_action:
- logger.log: "set_action"
- water_heater.template.publish:
id: template_water_heater
on: false
away: true
- water_heater.template.publish:
id: template_water_heater
on: !lambda "return true;"
away: !lambda "return false;"
datetime:
- platform: template