本帖最后由 demacia 于 2024-4-9 13:32 编辑
之前买了电水壶用MIOT AUTO接入HA后,发现自动恒温功能(即烧水或加热到指定温度后,会保持恒温温度一段时间)总是不生效,只能烧水或者加热到指定温度(官方HA WaterHeat实际也没有恒温的能力)。
https://github.com/al-one/hass-xiaomi-miot/issues/1036 参考作者去年帮忙解答问题的过程。
分享下通过脚本和自动化,实现一键加热和煮沸的(不用官方的water_heater组件去手动调温度),同时支持恒温的逻辑。本身实现的方式不够优雅,要是MIOT作者能直接实现实体就好了。
先上效果
这里的除了 保温 和 煮沸 是触发自定义脚本,其他都是MIOT自动生成的实体。
保温脚本
alias: 保温脚本
sequence:
- if:
- condition: template
value_template: >-
{{state_attr("water_heater.yunmi_v19_0b79_kettle","kettle.auto_keep_warm")}}
then:
- service: water_heater.set_temperature
target:
entity_id: water_heater.yunmi_v19_0b79_kettle
data:
temperature: >-
{{state_attr("water_heater.yunmi_v19_0b79_kettle","kettle.keep_warm_temperature")}}
operation_mode: "1"
- delay:
hours: 0
minutes: 0
seconds: 6
milliseconds: 0
- service: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.yunmi_v19_0b79_auto_keep_warm
else:
- service: water_heater.set_temperature
target:
entity_id: water_heater.yunmi_v19_0b79_kettle
data:
temperature: >-
{{state_attr("water_heater.yunmi_v19_0b79_kettle","kettle.keep_warm_temperature")}}
operation_mode: "1"
mode: single
icon: mdi:kettle
煮沸脚本(就是把加热脚本的温度从动态获取,改成固定的99摄氏度)
alias: 煮沸脚本
sequence:
- if:
- condition: template
value_template: >-
{{state_attr("water_heater.yunmi_v19_0b79_kettle","kettle.auto_keep_warm")}}
then:
- service: water_heater.set_temperature
target:
entity_id: water_heater.yunmi_v19_0b79_kettle
data:
temperature: 99
operation_mode: "1"
- service: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.yunmi_v19_0b79_auto_keep_warm
else:
- service: water_heater.set_temperature
target:
entity_id: water_heater.yunmi_v19_0b79_kettle
data:
temperature: 99
operation_mode: "1"
icon: mdi:kettle-alert
mode: single
|