Simple switch for the plug socket: watering tomatoes

Hello, I am a complete beginner and would now like to create my first automations. I usually get into it relatively quickly if I get a little initial support.

I want to create an automation that switches on the socket for 2 minutes every 2 hours between 8am and 8pm.

I imagined it something like this:

automation my_plug:
  description: "Steckdose für die Tomaten schaltet sich alle 2 Stunden ein"
  - alias: "Steckdose zeitgesteuert"
    trigger:
      - platform: time
         hours: '/2'
         minutes: '0'
         seconds: '0'
    condition:
      - condition: time
        after: "16:00:00"
        before: "23:00:00"
    action:
      - service: switch.turn_on
        entity_id: sensor.shellyplusplugs_80646fd65fc8_switch_0_power
      - delay: '00:02:00'
      - service: switch.turn_off
        entity_id: sensor.shellyplusplugs_80646fd65fc8_switch_0_power

But there seems to be a bug in here, because I get the following error message.

Message malformed: extra keys not allowed @ data['hours']

Hours minutes and seconds need an extra space.

1 Like

Also 16:00 is 4:00 pm (not 8:00am) and 23:00 is 11:00pm (not 8:00pm).

oh sorry, that was another time I inserted to test. I would have replaced it with the correct time.

I’ve changed the time into am/pm format and now it works as far as I can save now. But when I edit this automatism, I see that the action, the trigger and the condition have not been saved. The syntax is probably not yet correct.

Here is what I have entered

automation my_plug:
  description: "Steckdose für die Tomaten schaltet sich alle 2 Stunden ein"
  - alias: "Steckdose zeitgesteuert"
    trigger:
      - platform: time
         hours: '/2'
         minutes: '0'
         seconds: '0'
    condition:
      - condition: time
        after: "8:00 am"
        before: "8:00 pm"
    action:
      - service: switch.turn_on
        entity_id: sensor.shellyplusplugs_80646fd65fc8_switch_0_power
      - delay: '00:02:00'
      - service: switch.turn_off
        entity_id: sensor.shellyplusplugs_80646fd65fc8_switch_0_power

and this is what came out.

alias: Tomaten Steckdose
description: Steckdose für die Tomaten schaltet sich alle 2 Stunden ein
trigger: []
condition: []
action: []
mode: single

I have solved the problem. My script:

alias: Tomaten Wässern
description: Alle 2 Stunden werden die Tomaten gewässert
trigger:
  - platform: time_pattern
    hours: "/2"
condition:
  - condition: time
    after: "08:00:00"
    before: "20:00:00"
    weekday:
      - sun
      - sat
      - fri
      - thu
      - wed
      - tue
      - mon
action:
  - type: turn_on
    device_id: xxxx
    entity_id: switch.shellyplusplugs_80646fd65fc8_switch_0
    domain: switch
  - delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: xxx
    entity_id: switch.shellyplusplugs_80646fd65fc8_switch_0
    domain: switch
mode: single