Using packages has some advantages, especially if you like the yaml way of living.
You can include almost everything in a package like groups, template definition, integrations and automations. This enebles me to create one package for a project, like my garden irrigation system or alarm. However, I simply cannot include a script in a package, simply because the dict definitions are missing…
Can you clarify what you are talking about and/or share an example that isn’t working?
I created some notification scripts, and put them in the package directory. The I get the error that it was not able to merge, because there is no dict. As I read the documentation page about packages, scripts indeed are not mentioned…
example script for in the package:
notification_package_script:
# PDW 2023-08, V1
script:
- id: F968B7BA929F417BAFA431A50C047EB0
alias: notify_sender
description: send message urgent to all devices using push and telegram and persistant
icon: mdi:message-text-fast-outline
fields:
topic:
description: "short title identifying the tread"
example: "Alarm"
message:
description: "The actual message to send"
example: "Motion detected in Home(assistant)"
snapshot:
description: "filename of a snapshot to be sent"
example: '{{state_attr("var.camera_driveway","last_snapshot_alarm")}}'
variable:
image_url: >-
{%- if snapshot != "" -%}
https://home.myserver.online/local/snapshots/{{snapshot}}
{%- else -%}{{""}}{%- endif -%}
image_md: >-
{%- if snapshot != "" -%}
´![Foto]({{image_url}})'
{%- else -%}{{""}}{%- endif -%}
sequence:
# Persistant notification
- service: persistent_notification.create
data:
title: '{{topic}}'
message: '{{message }} {{image_md}}'
# Push notification to the app
- service: notify.all_devices
data:
message: '{{topic}}/n{{message}}'
data:
url: '{{image_url}}'
clickAction: '{{image_url}}'
channel: Motion
importance: high
push:
interruption-level: time-sensitive
ttl: 0
priority: high
# Send message to Telegram
- service: notify.telegram
data:
title: '{{topic}}'
message: '{{message }}'
data:
photo:
- url: '{{image_url}}'
You need to include a key/object_id for each script entity, just like you would in the standard scripts.yaml file.
notification_package_script:
# PDW 2023-08, V1
script:
notify_sender:
alias: notify_sender
description: send message as defined in var.notification_message
icon: mdi:message-text-fast-outline
fields:
topic:
description: "short title identifying the tread"
example: "Alarm"
message:
description: "The actual message to send"
example: "Motion detected in Home(assistant)"
snapshot:
description: "filename of a snapshot to be sent"
example: '{{state_attr("var.camera_driveway","last_snapshot_alarm")}}'
variables:
image_url: >-
{%- if snapshot != "" -%}
https://home.goatnet.nl/local/snapshots/{{snapshot}}
{%- else -%}{{""}}{%- endif -%}
image_md: >-
{%- if snapshot != "" -%}
´![Foto]({{image_url}})'
{%- else -%}{{""}}{%- endif -%}
sequence:
# Persistent notification
- service: persistent_notification.create
data:
title: '{{topic}}'
message: '{{message }} {{image_md}}'
# Push notification to the app
- service: notify.all_devices
data:
message: '{{topic}}/n{{message}}'
data:
url: '{{image_url}}'
clickAction: '{{image_url}}'
channel: Motion
importance: high
push:
interruption-level: time-sensitive
ttl: 0
priority: high
# Send message to Telegram
- service: notify.telegram
data:
title: '{{topic}}'
message: '{{message }}'
data:
photo:
- url: '{{image_url}}'
Thanks!
You are right, despite it is not explicitly mentioned in the documentation, it is actually possible this way!