Cannot call script from automation

I have a script “script.1582368367278”. I can call it from Developer/Services (just run “script.1582368367278” as the service) or as a button in Lovelace and it executes properly.

However, this doesn’t work when called from an automation. It just doesn’t execute. I call it the same way in the automation - action type: call service & service: script.1582368367278

This is the automation:

- id: '1583341040653'
  alias: Leaving home Xiaomi
  description: ''
  trigger:
  - entity_id: sensor.xiaomi_button_2_click
    platform: state
    to: double
  condition: []
  action:
  - data: {}
    service: script.1582368367278

This is in the log:
Unable to find referenced entities automation.leaving_home_xiaomi

I don’t understand this as I’m only picking the entity (script.1582368367278) from the drop down. The id number is correct.

Please help. HA 106.5 on Rpi4.

Can you share your automation?
Is kinda difficult to tell you what’s wrong without being able to see it :wink:

This is it:

- id: '1583341040653'
  alias: Leaving home Xiaomi
  description: ''
  trigger:
  - entity_id: sensor.xiaomi_button_2_click
    platform: state
    to: double
  condition: []
  action:
  - data: {}
    service: script.1582368367278

And the script is this (it executes properly when called from Lovelace so there’s probably nothing wrong with it).

The automation is generated by the automation editor GUI.

You probably need to enclose double in quotes. Also what happens when you manually trigger the automation?

No, that’s not it. I have an another automation for the same button with “single” without any quotes and it works properly.

When I manually trigger the automation in question, nothing happens. Also, when I call the script via script.turn_on with entity_id of the script, nothing happens as well. The method is fine as I can use it with other scripts.

Just noticed this. You forgot the service line…
service: script.turn_on

    - service: script.turn_on
      data:
        entity_id: script. 1582368367278

I want a whisky room!

1 Like

Well those are unhealthy results. Any error messages in the system log?

Is that really the name of the script? Or is it something like script.leaving_home?

Based on the scripts I have, whatever you put in alias becomes the script entity’s friendly_name (and not the script entity’s object_id).

Screenshot from 2020-03-17 16-46-42

Ok false alarm, sorry for the noise.

You don’t need the script.turn_on only the script.turn_off

That shouldn’t be needed, it should work like this:

and does for another automation of mine. But that is moot because it doesn’t work like this either:

@nickrout it’s a joke name of the light on my coffee table next to an armchair :wink:

yes, this as stated in the OP

Unable to find referenced entities automation.leaving_home_xiaomi

Sorry, no, it doesn’t work. I did remove the space after "script. "

I just nuked the original automation and re-created it. I did it the exact same way as the original and it works. It’s probably a glitch in matrix somewhere.

See if you spot any difference to the original code, I don’t:

- id: '1584482640624'
  alias: Leave home Xiaomi
  description: ''
  trigger:
  - entity_id: sensor.xiaomi_button_2_click
    platform: state
    to: double
  condition: []
  action:
  - data: {}
    service: script.1582368367278

Was that the error message produced when you manually triggered the automation?

The error message was Unable to find referenced entities followed by each of the entity in the script, which is clearly a bug because all of them are live, working and correct. I didn’t modify the script st all and it works fine with the new automation.

Have been here already :frowning:
Was banging my head… and at last found 2 ways for fixing not working automations created from UI.
First was to delete and recreate from scratch- OK, another was via automations.yaml- after tinkering via UI some lines were misplaced- go figure…
Best, JR

1 Like