请正确格式化代码,看看
我不知道为什么你想结合这些,但我认为它应该这样工作。可能有一个更优雅的解决方案。
- id: ‘1574429754473’ alias: "Turn on Water Heater at 15:30 and off at 19:00" description: "Turn on Water Heater at 15:30 and off at 19:00" trigger: - platform: time at: "15:30" - platform: time at: "19:00" action: service_template: > {% if {{now().strftime('%H:M') > strptime('18:59:00', '%T')}} %} switch.turn_off {% else %} switch.turn_on {% endif %} entity_id: switch.water_heater
这将在15:30和19:30触发自动化。然后,它检查当前时间是否在过去18:59。如果它评估为true,则开关关闭,否则它会打开。