Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 99075

Default values for script parameters?

$
0
0

@quentinsf wrote:

I’m delighted to see that scripts can take parameters using the ‘fields’ clause. Each parameter can be given a description and an example value.

It would be very nice to set defaults for the parameter values there, too, I think. At present you can handle defaults to some degree with a Jinja filter. Here’s my little trial script:

parameter_test:
  alias: Parameter test
  fields:
    number:
      description: The number to go in the message
      example: 123

  sequence:
    - service: notify.mobile_app_my_iphone
      data_template:
        title: "Life, the Universe and Everything"
        message: "The answer is {{ number|default('42') }}"

But if you use the parameter in multiple places, you get duplication, and I think it would be tidier anyway to be able to do this:

  fields:
    number:
      description: The number to go in the message
      example: 123
      default: 42

Should I dig in and see if I can implement this? Is there a better solution?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 99075

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>