Select utility meter tariff on startup

I want to select the correct tariff on home assistant startup. So far I have this one here but I get this error:

Error while executing automation automation.change_utility_meter_tariff_on_startup_weekdays. Invalid data for call_service at pos 1: Entity ID - utility_meter.daily_energy - utility_meter.monthly_energy - utility_meter.yearly_energy
tariff: partial_peak is an invalid entity id for dictionary value @ data[‘entity_id’]

Can somebody help?

- alias: 'Change utility meter tariff on startup weekdays'
  trigger:
    - platform: homeassistant
      event: start
  condition:
  - condition: time
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
  action:
  - service: utility_meter.select_tariff
    data_template:
      entity_id: >-
        - utility_meter.daily_energy
        - utility_meter.monthly_energy
        - utility_meter.yearly_energy
        {% if now().hour < 7 %}
         tariff: offpeak
        {% elif now().hour < 14 %}
          tariff: partial_peak
        {% elif now().hour < 21 %}
          tariff: peak
        {% elif now().hour < 23 %}
          tariff: partial_peak
        {% else %}
          tariff: offpeak
        {% endif %}

I think I figured it out:

- alias: 'Change utility meter tariff on startup weekdays'
  trigger:
    - platform: homeassistant
      event: start
  condition:
  - condition: time
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
  action:
  - service: utility_meter.select_tariff
    data_template:
      entity_id:
      - utility_meter.daily_energy
      - utility_meter.monthly_energy
      - utility_meter.yearly_energy
      tariff: >-
        {% if now().hour < 7 %}
         offpeak
        {% elif now().hour < 14 %}
         partial-peak
        {% elif now().hour < 21 %}
         peak
        {% elif now().hour < 23 %}
         partial-peak
        {% else %}
         offpeak
        {% endif %}
2 Likes

since version 2022.9 the service “utility_meter.select_tariff” is depreciated in favor of “select.select_option”

here is example of how i am selecting the tariff during startup:

- alias: "Tariff on Startup"
  trigger:
    - platform: homeassistant
      event: start
  action:
    - service: select.select_option
      target:
        entity_id:
        - select.home_energy_h
        - select.home_energy_d
        - select.home_energy_m
        - select.home_energy_y
      data:
        option: >-
            {% if now().hour < 6 %}
             offpeak
            {% elif now().hour < 22 %}
             peak
            {% else %}
             offpeak
            {% endif %}