Problem with periodic trigger

I am trying to implement an automatuion that sets an input_number (“input_number.eje_x”) to a certain value (0.2) every 15 minutes.
Then I have another automation that sets this input number to 0 if it is avobe 0 for more than 30 seconds. It sould be fairly easy, but I am not able to get id done. Neither of automations seems to work. Follows what I have.

- id: '1609408389696'
  alias: Carga_eje_x
  description: Carga el valor de eje X priodicamente
  trigger:
  - platform: time_pattern
    minutes: "/15"
  condition: []
  action:
  - service: input_number.set_value
    data:
      entity: input_number.eje_x
      value: 0.2
    entity_id: input_number.eje_x
  mode: single

- id: '1609425950307'
  alias: eje_x a cero
  description: Pone a cero input_number.eje_x
  trigger:
  - platform: numeric_state
    entity_id: input_number.eje_x
    above: 0
    for:
      seconds: 30
  condition: []
  action:
  - service: input_number.set_value
    data:
      entity: input_number.eje_x
      value: 0
    entity_id: input_number.eje_x
  mode: single

Could someone tell me what is wrong here"

The second automation won’t work the way you want because of the way a Numeric State Trigger works.

The Numeric State Trigger you defined will only trigger when the input_number’s value rises from below 0 to above 0. That’s the moment it will trigger. It won’t trigger if the value is already above 0.

In your example, the value is never below 0, before rising above 0, so the Numeric State Trigger is never triggered.

My guess is the first automation probably works because all it does is set the input_number’s value to 0.2 every 15 minutes. Basically, the value remains at 0.2 forever because the second automation is never triggered.

I don’t know what these two automations are supposed to do but you may want to consider changing the first automation’s trigger to a State Trigger.

  trigger:
  - platform: state
    entity_id: input_number.eje_x
    to: 0.2
    for:
      seconds: 30

If the input_number’s value is 0.2 for at least 30 seconds, the automation will be triggered.

Thanks for your quick reply.
What I want to implement is a graph with tics every 15 minutes, and perhaps a higher one on the hour, to serve as an X-axis in a mini-graph, using a secondary Y-axis to plot them at a low size.

I will test your suggestion, valid for the second part, the one that puts input_number.eje_x to 0.
eHc

The second automation with the changes you suggested works, and set to 0 input_number.eje_x 30 seconds after it is set to 0.2, but the automation to set it to 0.2 every 15 minutes, is not working, I don’t know why.

Now I understand why the first one doesn’t work. The service call is incorrect. It refers to a non-existent option (entity).

Change it to this:

  - service: input_number.set_value
    data:
      entity_id: input_number.eje_x
      value: 0.2

Now it works. A silly mistake, but the problem is that I’m not confident in what I’m doing and I don’t look for the simple things.
Thanks a lot and I wish you a happy new year (we deserve that for a change)
eHc

1 Like