Turn on spa pool at particular time

Can anyone tell me why this simple automation is not working anymore?
It was working fine up until a few weeks ago.

alias: Set Spa Pool Automation PM
id: '64827472828'
trigger:
  - platform: time
    at:
      - '16:00'
      - '18:00'
  - platform: homeassistant
    event: start
action:
  - service: >-
      switch.turn_{{'on' if (16,00) <= (now().hour,now().minute) < (18,00) else 'off'}}
    target:
      entity_id: switch.spa_pool

I have another for the morning and it is working perfect

alias: Set Spa Pool Automation AM
id: '64827472829'
trigger:
  - platform: time
    at:
      - '6:00'
      - '9:30'
  - platform: homeassistant
    event: start
action:
  - service: >-
      switch.turn_{{'on' if (6,00) <= (now().hour,now().minute) < (9,30) else 'off'}}
    target:
      entity_id: switch.spa_pool

Not working meaning it does not turn on or off?

Sorry, that is right, nothing happens at the set time, but my morning one turns on and off fine

I find it more strange that the morning works.

Anyways… {{ now().minute }} does not reurn 00 ever. So because of that I could see that as an issue.
But I guess since it works in the morning it works anyways.

Just make it simpler using:

alias: Set Spa Pool Automation PM
id: '64827472828'
trigger:
  - platform: time
    at: '16:00'
    id: on
  - platform: time
    at: '18:00'
    id: off
  - platform: homeassistant
    event: start
action:
  - service: >-
      switch.turn_{{ trigger.id }}
    target:
      entity_id: switch.spa_pool

EDIT I see now the start event wont work. Let me think

Another method of doing the if else, could be to use:

{{ 'on' if now().hour in [16,17] else 'off' }}

Not sure if this works better or worse, but it’s an option that you could try

Have you checked if the automation is triggered but the action not executed, or is the automation not even triggered in the first place?
In the automation debug view you should be able to see what now is at the time the automation is triggered.