Automation can't find script?

Is there something wrong with this automation as I have checked and checked again and I can’t seem to see the issue but there is one as it’s not hitting the script.

This is the error:

Error while executing automation automation.front_door_open. Service not found for call_service at pos 1: Unable to find service script/scan_bt_arrive

This is my automation code:

Located automation/security/front_door_open.yaml

alias: 'Front door open'
initial_state: 'on'
trigger:
  - platform: state
    entity_id: binary_sensor.front_door
    to: 'on'
action:
  - service: script.scan_bt_arrive

This is my script:

Located at script/scan_bt_arrive.yaml

scan_bt_arrive:
  alias: scan_bt_arrive
  sequence:
    - wait_template: "{{ is_state('script.scan_bt_depart', 'off') }}"
    - service: mqtt.publish
      data:
        topic: monitor/scan/arrive
        payload: ''
    - delay: '00:00:15'
    - service: mqtt.publish
      data:
        topic: monitor/scan/arrive
        payload: ''

Man I’m so close to 100% prefected presence!

Thanks in advance.

Dave.

You nedd to call your scrpt with:

    action:
      - service: homeassistant.turn_on
        entity_id: script.scan_bt_arrive

Scripts are services and this should work

  - service: script.scan_bt_arrive

What does your configuration.yaml file script: entry look like. I’m guessing the !include is not correct.

1 Like

script: !include_dir_merge_list script/

!include_dir_merge_list will return the content of a directory as a list by merging all files (which should contain a list) into 1 big list.

Your files need to contain a list (lists start with - ):

- scan_bt_arrive:
    alias: scan_bt_arrive
    sequence:
      - wait_template: "{{ is_state('script.scan_bt_depart', 'off') }}"
      - service: mqtt.publish
        data:
          topic: monitor/scan/arrive
          payload: ''
      - delay: '00:00:15'
      - service: mqtt.publish
        data:
          topic: monitor/scan/arrive
          payload: ''

OR you can use !include_dir_merge_named

3 Likes

I’m not sure that is all entirely correct.

Scripts are always named and not lists so they don’t start with a dash.

so if you write your scripts directly in configuration.yaml you would do this:

script:
  script1:
    sequence:...
  script2:
    sequence:...

the same is also true of groups, shell_commands, panel_iframes, etc.

However, automations, switches, sensors, etc are written as lists and each entry starts with a dash:

sensor:
  - sensor1:
    config...
  - sensor2:
    config...

Don’t ask me why there is a difference because I have no idea. I’m sure it has something to do with Python dicts and lists but other than that I’m clueless on what the distinction would be between the different types.

So to split things from your configuration.yaml that are named you have to use “!include_dir_merge_named” & for things that are lists you have to use “!include_dir_merge_list”. I don’t think those things are interchangeable just by adding or removing the dashes. I don’t think…

that’s the way my config is split and it works.

I don’t use either method so you are probably correct.

Yea, that sorted it!

I was sure that I set the format right, but clearly not. I don’t suppose you know of a guide to use of !include I’ve read up on yaml and the use of !include but clearly I don’t have a full understanding of it as I know there are multiple uses of !include

Any further help is appreciated!

Dave.

Which solution did you use?

Creating a list or using merge_named ?

That was my fix, gotta love K.I.S.S

2 Likes