Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add scripts on Actions #945

Open
raedkit opened this issue May 18, 2024 · 6 comments
Open

Unable to add scripts on Actions #945

raedkit opened this issue May 18, 2024 · 6 comments
Labels
bug Something isn't working work-in-progress

Comments

@raedkit
Copy link

raedkit commented May 18, 2024

Alarmo Version

v1.10.1

HA Version

2024.5.3

Bug description

On this version of Alarmo I'm unable to add any script on actions for when alarmo is triggered. I have always an error : required key 'service' is missing even if it really exists the YAML

Steps to reproduce

  1. go to Actions tab
  2. Create a new action
  3. Add as a trigger : alarm is triggered
  4. As an action select a script
  5. Click on run button for the script
  6. Add a description of the action on the field below
  7. Click on save button
  8. An error message appears on the service run button with required (even if it's already clicked)
  9. When switching to yaml it appears : required key 'service' is missing eventhough it appears on the yaml

Relevant log output

No response

@raedkit raedkit added the bug Something isn't working label May 18, 2024
@nielsfaber
Copy link
Owner

I took a look into this. My finding was that this issue only occurs in case you have a script that is later renamed. As a result the entity_id of the script could be different to the service that is related, Alarmo is unable to find it back.
I made some changes to improve this (b454170), I will let you know when this is released.

@DJaeger
Copy link

DJaeger commented Jun 5, 2024

As I have the same issue, I researched this and it seems to bee a core issue:
home-assistant/core#115334

The change you've made in b454170 is a breaking change, as it changes the behaviour of how the scripts are started, if more than one is defined:
https://www.home-assistant.io/integrations/script/#waiting-for-script-to-complete

But there is a workaround to fix you scripts service name:
home-assistant/core#115334 (comment)

@nielsfaber
Copy link
Owner

@DJaeger Thanks for your comment, I'm glad that you pointed out this is a core issue (which hopefully will get some attention soon).

The change you've made in b454170 is a breaking change, as it changes the behaviour of how the scripts are started, if more than one is defined:

I don't quite follow your point here.
For a script having entity script.my_new_entity_name and related service script.my_original_entity_name, before the change Alarmo would create yaml config for the service call as such:

service: script.my_new_entity_name
entity_id: script.my_new_entity_name
data: {}

and after the change:

service: script.my_original_entity_name
entity_id: script.my_original_entity_name
data: {}

Effectively, Alarmo no longer looks at the entity list to find scripts (and their IDs) but takes them from the service list.
Technically both are wrong, in the old code the wrong service would be called, in the new code the wrong entity_id will be passed. But I couldn't find a way to find the matching entity_id for a given service. It seems that passing the entity_id when calling a script is optional and doesn't have any effect.

@nielsfaber
Copy link
Owner

@raedkit The fix is now included in release v1.10.2, please update to the latest version and test if it works OK for you now.
You can close the issue if so, otherwise please let me know.

@DJaeger
Copy link

DJaeger commented Jun 5, 2024

@nielsfaber Your're right, I overlooked an exclamation mark and misunderstood it, sorry.
The entity_id seems to be required only when using e.g. script.turn_on

@raedkit
Copy link
Author

raedkit commented Jun 6, 2024

@raedkit The fix is now included in release v1.10.2, please update to the latest version and test if it works OK for you now. You can close the issue if so, otherwise please let me know.

Thank you for the fix. I will test it this weekend and will let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working work-in-progress
Projects
None yet
Development

No branches or pull requests

3 participants