Skip to content

An action

Switch a light and set its brightness, without JavaScript.

Light controls
<button data-hd-on-click="toggle('onoff')">Switch light</button><hd-slider bind="{{ cap.dim }}" label="Brightness"></hd-slider>

The preview runs on a made-up light.basic device, so you don’t need a Homey. Edit the template or style to try something; actions don’t reach a device here.

How it works

data-hd-on-click runs a fixed action when the button is tapped: toggle('onoff') switches the light. hd-slider is bound to the dim capability and sends its value while you drag.

Actions don’t reach a device in this preview. On a dashboard, they need a tile with a light that has onoff and dim.

Files

Download the package

template.liquid
<button data-hd-on-click="toggle('onoff')">Switch light</button><hd-slider bind="{{ cap.dim }}" label="Brightness"></hd-slider>
style.css
:host {  display: flex;  flex-direction: column;  gap: 12px;  padding: 12px;}p {  margin: 0;}.reading {  font: var(--hd-number-weight) 36px var(--hd-font-display);}button {  color: var(--hd-text);  background: var(--hd-surface);  border: 1px solid var(--hd-border);  padding: 10px;  border-radius: var(--hd-control-radius);}
tiledash.json
{  "id": "@your-handle/light-action",  "title": "An action",  "summary": "Switch a light and set its brightness, without JavaScript.",  "version": "1.0.0",  "licence": "MIT",  "tags": [],  "kind": "widget",  "widget": {    "kind": "device",    "match": {      "classes": [        "light"      ],      "requires": [        "onoff"      ],      "optional": [        "dim",        "light_temperature",        "light_hue",        "measure_power"      ]    },    "size": {      "default": [        3,        4      ],      "min": [        1,        1      ],      "max": [        6,        8      ]    },    "align": {      "x": "start",      "y": "end"    },    "settings": [      {        "name": "showWarmth",        "label": "Colour temperature slider",        "required": true,        "group": "content",        "type": "boolean",        "default": true      },      {        "name": "tileTap",        "label": "The light",        "required": false,        "group": "tap",        "type": "tap",        "gesture": "tap",        "default": {          "type": "toggle"        },        "hold": {          "type": "device"        },        "double": {          "type": "none"        },        "allow": [          "toggle",          "device",          "dashboard",          "flow",          "mood",          "variable",          "request"        ]      }    ],    "basedOn": "light.basic"  }}

Use it

In the editor, start from the widget it’s based on and paste the template and style; or unzip the package, replace your-handle with your name in the Community and publish it. Build your first widget walks through both.

Read more: Actions · Components