Run script from scene

Hi,

If have this script to open my door:

alias: Open de voordeur
sequence:
  - service: lock.open
    target:
      entity_id: lock.voordeur
    data:
      code: ''
mode: single
icon: mdi:door-open

I want to start this script using a scene, so I can start it from my phone widget. The widget only support scenes at the moment.

Thanks in advance,

Rien

What widget on what phone?
On Android, you can have a widget that do a plain service call.

1 Like

Sorry I should have mentioned that.

It’s my iphone

Then I have no clue, but I guess you’re looking for

Use Apple Shortcuts app on your iphone. No need for the HA widgets and can call any script / service. Add a Shortcuts widget to your homescreen, or many as individual app/shortcuts you can put in a folder.

1 Like

This looks like a workaround and not easy and user friendly. It would be much easier when scenes can call scripts or the companion app can use scripts and automations in addition to scene.

Scenes will never be able to call scripts. They are totally different things. (Scene for restoring a collection of states, script for running a sequence of actions).

Correct me if I’m wrong but I assume you are looking for the convenience of running a HA script directly from your iPhone home screen. Apple shortcuts is definitely the easiest way to achieve this. I have a whole page on my homescreen for doing this. Lights out, movie mode, boost heating, notify family I’m on way home, TV shutdown sequence etc. This uses the Shortcuts homescreen widget rather than HA widget

It’s really pretty straightforward. But to help you along, here’s a template shortcut for running a script. Just change the script entity name in the first step. Shortcuts

Oh and if you don’t have the Shortcuts app already installed you’ll need to download from the app store (for free).

In case this helps someone else. I was looking for the same thing. It can now be done using iOS actions. These can then appear on the lock screen (Today view widget).

Another way of doing this is to create an automation from within Home Assistant that looks for the change in state of a scene as a trigger and then performs whatever actions you want, such as calling scripts or making other adjustments that don’t fit neatly into the scene paradigm. I have a helper automation for most of the scenes I use. It is easy to create from the UI. This is an example using YAML:

alias: Party_Scene_Helper
description: ""
trigger:
  - platform: event
    event_type: call_service
    event_data:
      domain: scene
      service: turn_on
      service_data:
        entity_id: scene.party
condition: []
action:
  - service: script.turn_on
    data: {}
    target:
      entity_id: script.party_scene_extras
mode: restart