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

I’ve seen this message occur many times when searching here, but each case seems different.

I want to reset my modem (which tends to act up after a while… it’s a ISP-provided modem-router, and it just serves as a modem, I have proper routers in the house). This is my first true automation, after testing a few easy things I figured it would be easy to use a smart plug, turn it off once a month, wait 15 seconds then turn it back on.

I plowed through the UI, no dice, tried my hand at NodeRED (even asking ChatGPT to help, which gave me inaccurate directions), then looked at a lot of YAML examples. I believe I’ve got something which works, but each time I try to save it, the UI asks me for a name for the automation, then tells me “Message malformed: extra keys not allowed @ data[‘0’]”.

I can’t figure out what I did wrong, and it seems simple enough. For the record, I was trying on another, less mission-critical plug at the time, figuring if it works I’ll just replace the automation with the proper plug. Here’s my rather simple YAML code:

  • alias: Eteindre routeur une fois par mois
    trigger:
    • platform: time
      at: ‘17:10:30’
      condition:
    • condition: template
      value_template: “{{ now().day == 8 }}”
      actions:
      sequence:
    • service: switch.turn_off
      entity_id: switch.prise_ecran_bernard
    • wait:
      timeout: ‘00:00:15’
    • service: switch.turn_on
      entity_id: switch.prise_ecran_bernard

I tried with and without “sequence”, no dice. When removing “sequence”, I removed one space for the indent of all the items following it.

Any input will be welcome!

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

This is not valid:

See: Script Syntax - Home Assistant

Most likey what you want is:

- delay: 15

Thanks. That didn’t work, sadly. Here’s (I hope" a better formatting of the current code

- alias: Eteindre routeur une fois par mois
  trigger:
   - platform: time
     at: '17:10:30'
  condition:
   - condition: template
      # Change the number here to get whatever day of the month you want.
     value_template: "{{ now().day == 8 }}"
  actions:
   sequence:
    - service: switch.turn_off
      entity_id: switch.prise_ecran_bernard
    - delay: 15
    - service: switch.turn_on
      entity_id: switch.prise_ecran_bernard

Remove this:

That is only used in scripts (and some branching actions).

Also updated to use action: instead of service:

  actions:
    - action: switch.turn_off
      target:
        entity_id: switch.prise_ecran_bernard
    - delay: 15
    - action: switch.turn_on
      target:
        entity_id: switch.prise_ecran_bernard

“service” will still work but it is old syntax.

See Automation actions - Home Assistant

Your lengthy post doesn’t describe what you actually expect to happen (in addition to lacking formatting, as @tom_l pointed out).

Help us help you by being more detailed?

Still no dice. I followed the advice by tom_l. Here’s what I have.

- alias: Eteindre routeur une fois par mois
  trigger:
   - platform: time
     at: '17:10:30'
  condition:
   - condition: template
     value_template: "{{ now().day == 8 }}"
  actions:
    - action: switch.turn_off
      entity_id: switch.prise_ecran_bernard
    - delay: 15
    - action: switch.turn_on
      entity_id: switch.prise_ecran_bernard

@d921 : this is my first post. Please be tolerant. I fixed the formatting in my next reply. And I did explain what I want to do : once per month, turn off the router for 15 seconds, then turn it back on. I’m open to any suggestion to make it work, I haven’t found a way using the UI or NodeRED.

What error are you getting now?

Also look closer at my yaml. See where I used target:?

You are missing this in two places.

How are you testing it?

Your trigger as defined will only happen at a very specific time of day.

@tom_l still getting “Message malformed: extra keys not allowed @ data[‘0’]” when trying to save the automation (after giving it a name). It won’t let me save it.

My YAML is currently:

- alias: Eteindre routeur une fois par mois
  trigger:
   - platform: time
     at: '17:10:30'
  condition:
   - condition: template
     value_template: "{{ now().day == 8 }}"
  actions:
    - action: switch.turn_off
      target:
        entity_id: switch.prise_ecran_bernard
    - delay: 15
    - action: switch.turn_on
      target:
        entity_id: switch.prise_ecran_bernard

@d921 I’m not yet able to test it since I can’t save it. It is intended to run at a given time. Once I can save it, I’ll use a plug near me (the one used in my YAML) and test by updating the time to whatever’s current. Then once I know it works, I’ll replace the plug with the modem’s plug, and the time with what I want it to be in the future.

Where are you trying to save this?

I tried creating a new automation. I get the UI, then click the three dots, “Modify in YAML”. I’m using the code we’ve been discussing, then at the bottom right there’s a blue “Save” button (mine’s in French, it might say a synonym of “save”). It then asks for a name, and when I click “Save” in that new window, I get the error message I shared.

EDIT: I listened to my teenager and asked Chat GPT to correct the code. It came up with this, which worked:

alias: Eteindre routeur une fois par mois
trigger:
  - platform: time
    at: '17:10:30'
condition:
  - condition: template
    value_template: "{{ now().day == 8 }}"
action:
  - service: switch.turn_off
    target:
      entity_id: switch.prise_ecran_bernard
  - delay: "00:00:15"
  - service: switch.turn_on
    target:
      entity_id: switch.prise_ecran_bernard

It had me revert to “service” instead of “action”, saying it’s the “correct” wording. I pasted it in the HA editor and boom, I got a working automation. Go figure.

Thanks for the useful discussion! I still don’t know what changed, indentation and other stuff doesn’t seem to have changed (apart from the dash before “alias” ).

Ok the editor yaml window is for one automation, not all of them. So you do not need to format it as a list. So like this:

alias: Eteindre routeur une fois par mois
trigger:
  - platform: time
    at: '17:10:30'
condition:
  - condition: template
    value_template: "{{ now().day == 8 }}"
actions:
  - action: switch.turn_off
    target:
      entity_id: switch.prise_ecran_bernard
  - delay: 15
  - action: switch.turn_on
    target:
      entity_id: switch.prise_ecran_bernard

Note the absence of the first dash and the indentation.