Automation constantly triggers

Hi guys,

I’ve just started to get into homeassistant (and loving it) - but i’m having trouble getting some automation working.

It should be very simple… but i’m finding that once my automation trigger occurs, the action keeps happening every ~5 seconds.

Configuration has a basic slider, the commands required for on/off/check status and the shell command for automation:

input_number:
  sprinkler_manual_timer:
    name: Timer
    min: 1
    max: 60
    step: 1
    initial: 20
    unit_of_measurement: mins
    icon: mdi:target

switch:
  - platform: command_line
    switches:
      spinkler_manual:
            command_on: '/usr/bin/curl -X GET "http://ip/cm?pw=xxx&sid=3&en=1&t=60"'
            command_off: '/usr/bin/curl -X GET "http://ip/cm?pw=xxx&sid=3&en=0"'
            command_state: '/usr/bin/curl -X GET "http://ip/js?pw=xxx&sid=3&en=0"'
            friendly_name: On / Off
            value_template: "{{ value_json.sn[3] == 1 }}"

shell_command:
  set_manual_sprinkler: '/usr/bin/curl -X GET "http://ip/cm?pw=xxx&sid=3&en=1&t={{ states.input_number.sprinkler_manual_timer.state | multiply(60) | int }}"'

and automation:

- id: sprinkler_automation_v1
  alias: Manual Sprinkler
  trigger: 
    platform: state
    entity_id: input_number.sprinkler_manual_timer
  action:
    service: shell_command.set_manual_sprinkler

As i mentioned, it works as expected - when the slider is changed to another value, it immedately triggers the shell command with the udpated variable but the issue i’m having is that it sends that command every ~5 seconds (ignore the on/off switch - that takes ~15 seconds to update):

I figured it might be due to the trigger being the slider, but i tried using the switch as the trigger and get the same result.

Any help or advice would be very much appreciated!

Have you looked in home-assistant.log? All the detail of what’s going on should be there. You may have to enable DEBUG (but it’s on by default if you haven’t changed the log level.)

I suspect it is not your automation but is the command line switch that is communicating every 5 seconds.

You can alter the scan interval. See here:

That would only apply if it was the command_state part of the command_line switch that was causing the problem (since that polls.) Which may be possible. But the shell_command (which in theory is causing the problem) does not poll.

In either case, the log should shed some light on what’s really happening.

That’s what I mean. The activity @ideasman69 is seeing is might not be due to the shell command. As the command_state is quite similar it could be this polling activity he is seeing.

The quickest way to check would be to comment out the switch, restart, and see if the activity stops.

Thanks for the input guys - much appreciated!

After tailing the logs and noticing no traffic headed to the prinkler system, i noticed something interesting and it’s actually obvious in the GIF in my original post.

When the shell command is sent, the “master” solenoid turns off for some reason. Sometimes it takes 5 seconds to come back on and other times up to 20 seconds. So the countdown timer keeps resetting back to the originally requested time until the master solenoid powers back on. Makes sense i guess - just wish i noticed earlier!

edit: ideally i wanted to get it to the point where i’d set the slider and then flick the switch to “on” for it to use the slider value but i can’t quite get my head around it.