Skip to content
Home Assistant BridgeHome Assistant Bridge
Esc
↑↓navigate↵open⌘Jpreview
On this page

Scripts

Start, stop and run scripts, with variables and responses, and read and change their configs.

script turn-on (on) starts a script and returns straight away. turn-off (off) stops it and toggle (t) does either:

ha-bridge script turn-on morning_routine
ha-bridge script turn-off morning_routine
ha-bridge script toggle morning_routine

Running and waiting

script run runs the script, waits for it to finish and prints its response as JSON. A script sets its response with a stop action and response_variable; scripts without one print null:

ha-bridge script run get_bin_day
{"bin":"recycling","day":"Thursday"}

Variables

turn-on and run take --variables, a JSON object the script reads as variables:

ha-bridge script run announce_weather --variables '{"room":"kitchen"}'

script reload reloads scripts from YAML.

Command Home Assistant action
script turn-on script.turn_on
script turn-off script.turn_off
script toggle script.toggle
script run script.<name>
script reload script.reload

Reading and changing configs

script config reads and writes scripts as Home Assistant’s script editor does, the same way as automation config. It needs a token that belongs to an admin.

ha-bridge script config get morning_routine
ha-bridge script config validate -f morning.yaml
ha-bridge script config update morning_routine -f morning.yaml
ha-bridge script config create -f new-script.yaml
ha-bridge script config delete morning_routine

config get prints the script’s config as YAML, or { "domain", "entity_id", "id", "editable", "config" } with --json. create, update and delete change scripts.yaml, and only scripts in it can be changed. A new script’s key comes from its alias unless you pass --id, such as --id morning_routine, and create prints it. validate checks the script’s sequence and what it names without saving, as for automations.

See ha-bridge script for every argument and flag.

Last updated on