Help with an error, please. It's driving me nuts!

I’m getting the following error:

Invalid config for [automation]: [initial_state] is an invalid option for [automation]. Check: automation->action->1->initial_state. (See /config/configuration.yaml, line 118)

Line 118 is:

group: !include groups.yaml

I do have an empty groups.yaml file.

If you need any more info to help me solve this just ask.

Many thanks.

Ignore the line number, the checker sometimes gets them wrong.

It looks like one of your automations is incorrect. Did you recently add an automation?

If so, check that or post the code here.

It looks like you have an initial_state defined for an automation but you have put it under the actions section instead of at the top level.

Thank you for your help.

That makes sense as, if I comment out the automation below, I don’t get the error. I can’t find what’s wrong with the automation though.

  • alias: Reset garagePIR state
    initial_state: ‘on’
    • platform: state
      entity_id: binary_sensor.garage_motion
      from: ‘off’
      to: ‘on’
      seconds: 5
    • service: mqtt.publish
      topic: tele/RF_Bridge/RESULT
      payload: D3226Eoff

Any ideas?

I should add that I’m very new to this!

Can you post your code with the proper formatting?

That is what I used but for some reason it’s replacing the - with circles. Otherwise, it’s all as was.

Having said that, I have it working now. Unfortunately, I changed so many things I’m not 100% sure what caused the error to go.

Bad practice, I know.

All the same, I appreciate the support.

Thank you.

You have to do this right after copying the code from your .yaml file. Right after pasting it into your post/reply, make sure it’s all selected, then click that button.

If you don’t do that then not only will it change dashes to circles, etc., but the indentation will be changed, too. Wrong indentation is often the root of problems like this, which we can’t spot if the code has been reformatted. By clicking that button you’re actually preventing automatic reformatting that messes it up.

OK. Thank you. I did it the other way around. I’ll remember that for next time.

Here’s what I have now:

- alias: Reset garage_door
  hide_entity: false
    platform: state
    entity_id: binary_sensor.garage_door
    from: 'off'
    to: 'on'
      seconds: 5
    service: mqtt.publish
      topic: "tele/Garage_RFBridge/RESULT"
      payload: '71D821off'
      retain: 'false'

I’d appreciate knowing what the ‘retain’ does and if there are any lines there that I really don’t need.

Also, is there any difference between using double and single quotation marks?

Could this be written more efficiently?

Retain tells the broker to store the value so it can be served up instantly to new subscriptions to the topic. Otherwise the new subscriber has to wait until the next published value.

You can leave out from: 'off' (it’s redundant).

There’s some info on quotes half way down this page:

It’s about as efficient as you can get that sort of simple automation.

That’s great. Thank you very much.