以前一直挺好的, 代码也没有改过, 只是升级了HA, 目前是用来控制暖气片的自动化不工作了
调节暖气片温度设定滑杆, 当室内温度达到设定值 关闭暖气片的电子水阀, 反之则打开, 去年冬天设置好后, 整个冬天天然气节省好多
下面是代码, 当时写的, 可能是HA升级后, 语法格式变了, 现在设置后不能自动打开开关了
input_number:
guestroom_warmer_set_temp:
name: '暖气片设定温度'
icon: mdi:thermometer-lines
initial: 16
min: 5
max: 20
step: 0.10
sensor:
- platform: template
sensors:
guestroom_warmer_set_temp_show:
friendly_name: '设定的温度'
unit_of_measurement: "°C"
value_template: '{{states.input_number.guestroom_warmer_set_temp.state|round(0.00)}}'
automation:
- id: guestroom_warmer_off_temp
alias: guestroom_warmer_off_temp
trigger:
- platform: template
value_template: "{% if states.sensor.temperature_158d00019cb884.state|round(0.00) >= states.input_number.guestroom_warmer_set_temp.state|round(0.00)%} true {% endif %}"
action:
service: switch.turn_off
entity_id: switch.guestroom_warmer
- id: guestroom_warmer_on_temp
alias: guestroom_warmer_on_temp
trigger:
- platform: template
value_template: "{% if states.sensor.temperature_158d00019cb884.state|round(0.00) < states.input_number.guestroom_warmer_set_temp.state|round(0.00)%} true {% endif %}"
action:
service: switch.turn_on
entity_id: switch.guestroom_warmer
group:
myhome:
name: 房间
view: yes
entities:
- group.guestroom
guestroom:
name: 老人房
view: no
entities:
- switch.guestroom_warmer
- input_number.guestroom_warmer_set_temp
- sensor.guestroom_warmer_set_temp_show
- sensor.temperature_158d00019cb884
- sensor.humidity_158d00019cb884
|