esphome可以模拟一个开关,这种就上水就带反馈了。类似
switch:
# 模拟一个开关,接入继电器A接入热水器,控制即时热水器开关,
- platform: template
name: "${device_name}_heater_switch"
id: heater_switch
icon: "mdi:patio-heater"
lambda: |-
if (id(heater_power_status).state) {
return true;
} else {
return false;
}
turn_on_action:
then:
- if:
condition:
binary_sensor.is_off: heater_power_status
then:
- switch.turn_on: relay1
- delay: 100ms
# - rtttl.play:
# rtttl: 'short:d=4,o=5,b=100:16e6'
- light.turn_on:
id: ledstrip
#transition_length: 3s
brightness: 40%
# red: 100%
# green: 10%
# blue: 43%
#effect: "strobe"
- delay: 20ms
- component.update: heater_luminance
- logger.log: "turn_on_action sensor heater_power_status"
else:
- logger.log: "Binary sensor heater_power_status on"
turn_off_action:
then:
- if:
condition:
binary_sensor.is_on: heater_power_status
then:
- switch.turn_on: relay1
# - rtttl.play:
# rtttl: 'short:d=4,o=5,b=100:16e6'
- delay: 100ms
- light.turn_off: ledstrip
- delay: 20ms
- component.update: heater_luminance
- logger.log: " turn_off_action heater_power_status"
else:
- logger.log: "Binary sensor heater_power_status is off"
# 先关闭
#- switch.turn_off: relay1
|