Energy Tariff Automation

I have following automation to switch between peak & offpeak tariff.

alias: “Energy: Peak and Offpeak Tariffs”
description: “”
trigger:

  • platform: time
    at: input_datetime.peak_energy_start
    variables:
    tariff: peak
  • platform: time
    at: input_datetime.peak_energy_end
    variables:
    tariff: offpeak
    action:
  • service: select.select_option
    target:
    entity_id: select.energy_grid_import
    data:
    option: “{{ tariff }}”
    mode: single

But this doesn’t run or change the tariff to peak.

Following are my helpers