Skip to content

Conversation

@DevelopIdeas
Copy link

Allows for use of device_id inside service / script functions
Screenshot 2024-03-14 at 23 55 30

Allows for use of device_id inside service / script functions
@jekalmin
Copy link
Owner

Thanks for your contribution!

I agree that it would be a nice feature to make device_id available to use in functions.
However, it would override device_id if it's used in parameters of spec.

I think it would be better if we change two things:

  1. Create reserved word which contains any data, such as user_input or exposed_entities, needed for users. The reserved word can be something like _params, _args, or word starting with _, so that it reduces possibility of conflict. Then your function should look like this.

    - service: python_script.play_music
      data:
        device_id: '{{_params.user_input.device_id}}'
        ...
  2. Make it available not only to script function but also to any functions.
    (Probably move your code to here and here would work)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants