Okay, lets go back and look at what you have (not all of this is your fault nor is it particularly problematic, I’m just pointing stuff out, you are clearly happy with it so just dont change a thing).
The below is your current solution : -
- alias: Turn US Lights on Between 11:00 and 19:00
hide_entity: true
trigger:
- platform: homeassistant
event: start
- platform: time
at: '11:00:00'
- platform: time
at: '19:01:00'
action:
- service_template: >
{% if now().hour > 18 or now().hour < 11 %}
switch.turn_off
{% else %}
switch.turn_on
{% endif %}
entity_id: switch.lights_us
From the above : -
- homeassistant.start is an event so it happens when it happens you can’t change that
- '- platform: time at: ‘19:01:00’ # this is evaluated every second, and you have 2 of them so 172,800 evaluations per day
- hide_entity: true # what does this do ? States UI has been deprecated
- {% if now().hour > 18 or now().hour < 11 %} # This is a kludge, it does not match your triggers and as a consequence you will have to think hard about what new triggers are and how to match them in the action section
Instead I’d use trigger template and sensor.time (look it up) it only changes 1/minute so results in 60 times LESS evaluations, also its easier to read/change and match (only 2,880 evaluations)
So my solution would be : -
- alias: Turn US Lights on Between 11:00 and 19:07
trigger:
- platform: homeassistant
event: start
- platform: template
value_template: "{{ states('sensor.time') == '11:00' }}"
- platform: template
value_template: "{{ states('sensor.time') == '19:07' }}"
action:
- service_template: >
{% if '11:00' <= states('sensor.time') < '19:07' %}
switch.turn_on
{% else %}
switch.turn_off
{% endif %}
entity_id: switch.lights_us
Uses the same values in both, easy to maintain, more efficient
Note: 1 adjusted the off time to 19:07 to make sure you saw it was not whole hour dependent.
But as I said, you are happy, don’t change a thing
Note 2: sensor.time is part of the sensor time_date integration, to use it you need (in your configuration) : -
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'date_time_iso'
- 'time_date'
- 'time_utc'
- 'beat'
Well, you need the first 2, ditch the rest if you like
Edit: NOTE that you can only have ONE sensor: heading in your config (unless you use packages)
You ‘could’ change the on and off times using input_datetime’s (has date false) which would mean you don’t need to change code or reload
Edit Again : I’d only really use platform time trigger, if I need a switch/light to come on at (say) ‘17:23:48’ and who needs that kind of ‘to the second’ accuracy ?