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

Does a sub-script 'inherit' a variable from a calling script?

$
0
0

@Mariusthvdb wrote:

trying to cut down on code, I hoped this would be valid, but not sure so please have a look?

      - service: script.notify_github #_update   <--- had the 2 scripts independently before, see following commented script
        data_template:
          repo: >
            {{state_attr(trigger.event.data.entity_id,'name')}}
          url: >
            {{state_attr(trigger.event.data.entity_id,'latest_release_url')}}
#
#      - service: script.persistent_notify_github_update
#        data_template:
#          repo: >
#            {{state_attr(trigger.event.data.entity_id,'name')}}
#          url: >
#            {{state_attr(trigger.event.data.entity_id,'latest_release_url')}}

script:
  notify_github:
    sequence:
      - service: script.notify_github_update    #<----these script now get the variable from above, but need to pass them on, do they?
      - service: script.persistent_notify_github_update

  notify_github_update:
    sequence:
      - condition: state
        entity_id: inut_boolean.notify_system
        state: 'on'
      - service: notify.system
        data_template:
          title: >
            Github update for {{repo}}
          message: >
           {{repo}} was updated to {{url.split('tag/')[1]}}.
           Visit the release page {{url}} to download.
           Download the [latest release]({{url}})

  persistent_notify_github_update:
    sequence:
      - condition: state
        entity_id: input_boolean.persistent_notification_create
        state: 'on'
      - service: persistent_notification.create
        data_template:
          title: >
            Github update for {{repo}}
          message: >
          ![image](/local/various/github_icon.png)  {{repo}} was updated to {{url.split('tag/')[1]}}.
           Visit the release page {{url}} to download.
           Download the [latest release]({{url}})
          notification_id: '{{repo}}'

thanks for having a look

Posts: 6

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 95394

Trending Articles



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