请正确格式化您的代码,看看
我不知道您为什么要组合它们,但我认为它应该这样起作用。可能有一个更优雅的解决方案。
- 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,则关闭开关,否则将打开。