Calling a package with call-service?

I have a script that I’m looking to add to a custom button card. The desired outcome is to call the script when the button is pressed.

The script, however, is in the packages folder (not /scripts) because I’m bundling different devices’ actions into one process. If I add it to the yaml, it complains that it can’t find scripts/find_roku_remote.

Is there a way to call a package using action: call-service? If not, do I need to move the script into the scripts folder and use service: script.myscript_1? Also, if I move this script out of the packages directory, will it break handling the script as far as HA is concerned?

type: custom:button-card
entity: input_boolean.living_room_remote_finder
styles:
  card:
    - height: 100%
size: 60%
color: rgb(5,144,51)
state:
  - value: 'on'
    color: lawngreen
  - value: 'off'
    color: grey
tap_action:
  action: call-service
  service: script.find_roku_remote
icon: mdi:remote-tv
show_name: true

This is possible without any problems.
Please post the relevant code from your configuration.yaml and your script.

Thanks for confirming. Below is the code snippet from configuration.yaml:

  #Packages
  packages: !include_dir_named packages

# Themes
frontend:
  themes: !include_dir_merge_named themes

# Other includes
automation: !include_dir_merge_list automations/
script: !include scripts.yaml
scene: !include scenes.yaml

Here is the script code:

input_boolean:
  living_room_remote_finder:
    name: "Living Room Remote Finder"
    initial: off
    icon: mdi:remote

ios:
  push:
    categories:
      - name: RemoteLR
        identifier: 'REMOTELR'
        actions:
          - identifier: 'LR_REMOTE_FOUND'
            title: 'Remote Found'
            activationMode: 'background'
            authenticationRequired: no
            destructive: no

          - identifier: 'LR_REMOTE_NOT_FOUND'
            title: 'Remote Not Yet Found'
            activationMode: 'background'
            authenticationRequired: no
            destructive: no

# Automations
automation:
  - alias: 'Find Roku Remote'
    id: 2346efcd-e8a8-ROKU-b5b6-43e54a72a95f
    mode: queued
    trigger:
      - platform: state
        entity_id: input_boolean.living_room_remote_finder
        to: 'on'

      - platform: event
        event_type: ios.notification_action_fired
        event_data:
          actionName: LR_REMOTE_NOT_FOUND

    action:
      - service: remote.send_command
        entity_id: remote.roku_ultra
        data:
          command: find_remote

      - service: script.notify_engine
        data:
          title: 'Living Room Remote'
          value1: 'Find Remote'
          ios_category: "REMOTELR"
          who: "family"
          apns_id: 'RemoteLR'

      - service: input_boolean.turn_off
        entity_id: input_boolean.living_room_remote_finder

  - alias: "Living Room Remote Found"
    id: 1f295bb8-ROKU-4b22-8f75-9fe079b295a8
    trigger:
      platform: event
      event_type: ios.notification_action_fired
      event_data:
        actionName: LR_REMOTE_FOUND
    action:
      - service: input_boolean.turn_off
        entity_id: input_boolean.living_room_remote_finder

      - service: script.notify_engine
        data:
          title: 'Living Room Remote'
          value1: 'Remote has been found.'
          who: "family"
          apns_id: 'RemoteLR'

I’m only seeing an automation, but no script.

So the script code above is the entire roku_remote_finder.yaml file. I realized I put the wrong filename in the service: section. It should be:

tap_action:
  action: call-service
  service: script.roku_remote_finder

Still, when I press the button, I get:

image

Because there is no script.roku_remote_finder to call. Does anything begin with script.… in your file?

Yes. Inside the roku_remote_finder.yaml file there are two actions with service: script.notify_engine:

      - service: script.notify_engine
        data:
          title: 'Living Room Remote'
          value1: 'Find Remote'
          ios_category: "REMOTELR"
          who: "family"
          apns_id: 'RemoteLR'

and

      - service: script.notify_engine
        data:
          title: 'Living Room Remote'
          value1: 'Remote has been found.'
          who: "family"
          apns_id: 'RemoteLR'

There is no service: script.roku_remote_finder you could call. If you explicitly want to call the script script.notify_engine, you have to adjust your button action. Since you have defined input_boolean.living_room_remote_finder as automation trigger, it is sufficient to press it in the frontend. As far as I remember, you have to call service toggle when using custom:button-card.

So it appears I’m not seeing the logic behind the service calls then. I figured call-service would call the referenced script and just run it from top to bottom.

A package is no script. It is a bunch of several platforms that can be grouped together due to their context. Instead of defining all elements individually in different places, you combine them in one file. From there, you are able to use any element in the package by its function.

When I read the headline, I assumed that you had just expressed yourself a little bit clumsily and that you were referring to a script (or something else) from a place other than automations.yaml or scripts.yaml/UI.

I see. That makes much more sense, thank you! I’ll have to re-evaluate how to deploy this then.

Just toggle the input boolean. This will trigger the automation.