Script

Description

The top-level script.

Fields

Key Type Description
metadata Metadata

Provides the metadata of the script, like name and description.

Required

input Input

Defines a list of input variables.

Required

automations [Automation]

Specifies a list of automations.

Required

inputValue InputValue

Supplies the value data of input variables.

Optional

Examples

Simple script to control a light with a switch

metadata:
  name: Turn on light with switch
  description: Basic example of turning on a light with another switch.

automations:
  starters:
    type: device.state.OnOff
    device: Office Switch - Office
    state: on
    is: true
  actions:
  - type: device.command.OnOff
    devices:
    - Christmas lights - Living Room
    on: true

Simple script to control lights with a switch. The light and switch devices can be selected from configuration UI.

metadata:
  name: Turn on light with switch
  description: Basic example of turning on a light with another switch.

inputValue:
  switch: Office Switch - Office
  lights:
  - Christmas lights 1 - Living Room
  - Christmas lights 2 - Living Room
input:
  switch:
    metadata:
      name: the switch to control a light
      description: the switch to control a light
    selector:
      type: device
      multiSelect: false
      supportedTypes: SWITCH
  lights:
    metadata:
      name: the lights to be controlled
      description: the lights to be controlled
    selector:
      type: device
      multiSelect: true
      supportedTypes: LIGHT

automations:
  starters:
    type: device.state.OnOff
    device: $switch
    state: on
    is: true
  actions:
  - type: device.command.OnOff
    devices:
    - $lights
    on: true