Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95414

Problem with templating in automation action

$
0
0

@Greytooth wrote:

I’m trying to make some automations for a utility meter. I use different input_numers to keep values persistent and at certain times I want to reset the different input_numbers. My idea was to use an automation that triggers once a day and then use templating to reset certain values once a day, once a month and once a year. But my automation doesn’t work, the values doesn’t reset.

This is the code for my automation:

- alias: Energy - Reset input_numbers 
  initial_state: on
  trigger:
    platform: time
    at: "0:00:03"
  action:
    - service: input_number.set_value
      data_template:
        entity_id: >-
          {% if now().month == 1 and now().day == 1 %}
            - input_number.energy_daily
            - input_number.energy_monthly
            - input_number.energy_yearly
          {% elif now().day == 1 %}
            - input_number.energy_daily
            - input_number.energy_monthly
          {% else %}
            - input_number.energy_daily
          {% endif %}
        value: '0'

Can someone please tell me what is wrong with my code?

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95414

Trending Articles