Timer to execute command

Hello,

I’m trying to create a timer automation for my infrared vacuum cleaner.
I want to choose how long it takes to execute a command to start the vacuumcleaner.

After some googleing i found some code, but there is missing something.
The code is missing what had to happen when the timer is finished, where do i place that code?

This is what i’ve go so far:
hombot

First line: execute the command right now
Second line: status of the vacuum
Third line: switch to turn on the timer
Fourth line: slider to fill in the minutes for the timer
Fifth line: how many minutes remaining from the timer.

Code:


input_number:
  stofzuigen_tijd:
    name: stofzuigen
    initial: 15
    min: 5
    max: 60
    step: 5
    mode: slider

input_boolean:
  stofzuigen_tijd:
    name: stofzuigen
    initial: off

timer:
  stofzuigen_tijd:
    name: stofzuigen

automation:
  - alias: Timer start
    trigger:
      platform: state
      entity_id: input_boolean.stofzuigen_tijd
      to: 'on'
    action:
      service: timer.start
      entity_id: timer.stofzuigen_tijd
      data_template:
        duration: "{{ states('input_number.stofzuigen_tijd') | int * 60 }}"

  - alias: Timer cancel
    trigger:
      platform: state
      entity_id: input_boolean.stofzuigen_tijd
      to: 'off'
    action:
      service: timer.cancel
      entity_id: timer.stofzuigen_tijd

  - alias: Timer stop
    trigger:
      platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.stofzuigen_tijd
    action:
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.stofzuigen_tijd

The code to execute command to start the vacuumcleaner:

  action:
    - service: remote.send_command
      data:
        entity_id: remote.harmony_hub
        command:
          - PowerToggle
        device: 59082838

How do i implement this?
My noobness can’t think of how i should do this :slight_smile:

Thanks!

  - alias: Timer stop
    trigger:
      platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.stofzuigen_tijd
    action:
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.stofzuigen_tijd

That automation - that runs when the timer finishes. If you want to then start the vacuum, you add the service call to that action:

  - alias: Timer stop
    trigger:
      platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.stofzuigen_tijd
    action:
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.stofzuigen_tijd
    - service: remote.send_command
      data:
        entity_id: remote.harmony_hub
        command:
          - PowerToggle
        device: 59082838

Thanks, changed it in the config.
When i execute the “start timer” automation nothing happens.
When i execute the stop timer, the harmony would have to do his trick imediatly isn’t it?
He doens’t do anything…

Can’t get the timer to start…

If the timer doesn’t start, then there’s a problem with the start automation.

Check your Home Assistant log for any errors. Check the template is doing what you expect in the dev-templates menu, under Developer Tools.

That’s the strange thing, if i click on “Logboek” in the left menu nothing loads.
In my configuration i’ve got the code “logger:” but HA doen’t log anything it seams…

This is what i see at developer tools > “sjablonen (= templates?!)”

- alias: Timer start
  trigger:
    platform: state
    entity_id: input_boolean.stofzuigen
    to: 'on'
  action:
    service: timer.start
    entity_id: timer.stofzuigen_tijd
    data_template:
      duration: "0"

Don’t even know why i have to use a boolean for a timer…

You need a trigger, what you use to trigger is up to you.

You’re pushing TRIGGER on the automation card to test it out?

I found a copy and paste solution!
Going to try that, got realy to less time for figuring this all out.
Kids and stuff :slight_smile: