Delay for Automation

Hello Community,

I whould like to have a automation for auto watering with a miflora sensor and a relay for the pumps. For the first the automation works when the miflora sensor say the moisture is under 20% it triggers the relay for the pumps. But now i whould like to have a delay that switch the toggle to off after 30 seconds or 1 minute. I set a delay but dont work for me. Can anyone help me please whats the mistake

?

Presuming the second screenshot is your ‘action’ it looks as though the delay is after the toggle?

1 Like

Yes and I do not know how to write it 00:00:01 or 00:01

Military time HH:MM:SS

1 Like

Yes that works but its wrong :rofl: sry my bad english. Now it switch the toggle 30 seconds later when the sensor is trigger but i will then when the sensor is trigger it turn on and after 30 seconds it set off. Simply said i will that it switch FOR 30 seconds

1 Like

Yeah, I don’t know how it’s supposed to look in the editor but the code in your automations.yaml should look like this…

trigger:
  platform: numeric_state
  entity_id: sensor.flower_1_moisture
  below: 20
action:
  - service: homeassistant.turn_on
    entity_id: switch.pumpe_1
  - delay: '00:00:30' 
  - service: homeassistant.turn_off
    entity_id: switch.pumpe_1
1 Like

Hm ok when i set i for the switch its switch after 30 seconds and when i set it after the switch it do nothing…i look tomorrow in the automation.yaml

Thanks for your help.

1 Like

The automation from the automation editor looks completely different thats the first picture

And the second picture it says me a other error but i have no document seperator or so

Yes i have it your automation works perfect for me. Thank you verry much now my project is complete :+1:

1 Like