mirror of
https://github.com/esphome/esphome.git
synced 2026-10-01 17:00:21 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user