Actions

Actions

A handler such as data-hd-on-click runs one or more actions, separated by ;. Up to eight per tap.

Taps the tile’s user chooses

Mark a part instead of writing a handler, and whoever uses the widget picks what tapping it does in the tile’s settings.

MarkWhat it does
data-hd-tap="partTap"The tile’s user picks what tapping it does.
data-hd-longpress="partHold"The tile’s user picks what holding it does.
data-hd-tap="readingTap" data-hd-capability="{{ id }}"Inside a loop: each names its reading, for switching and its history.

Devices

toggle(capability, deviceId?)

Switches a yes/no capability to the other value: on becomes off, off becomes on. A yes/no capability that can be changed, of the tile’s device or of the device given.

TakesWhat it is
capabilityrequiredA capability id of that device, quoted: 'onoff', 'evcharger_charging'.
deviceIdA device: a setting’s settings.<name>.id. Left out, the tile’s own device.
toggle('onoff')toggle('onoff')

set(capability, value, deviceId?)

Sets a capability: true or false, a number within its min and max (snapped to its step), or one of an enum’s ids. A capability that can be changed, of the tile’s device or of the device given.

TakesWhat it is
capabilityrequiredA capability id of that device, quoted: 'onoff', 'evcharger_charging'.
valuerequiredWhat to set it to.
deviceIdA device: a setting’s settings.<name>.id. Left out, the tile’s own device.
set('evcharger_charging', false)confirm('Stop charging?') && set('evcharger_charging', false)set('dim', 0.5)

increment(capability, step, deviceId?)

Adds the step to a number capability (a negative step lowers it), stopping at its min or max. A number capability that can be changed and has a value.

TakesWhat it is
capabilityrequiredA capability id of that device, quoted: 'onoff', 'evcharger_charging'.
steprequiredHow much to add, e.g. 0.5 or -1.
deviceIdA device: a setting’s settings.<name>.id. Left out, the tile’s own device.
increment('target_temperature', 0.5)increment('volume_set', 0.05)

Flows and moods

startFlow(flowId)

Starts a flow and says so in a toast. A flow of this Homey that can be started by hand: a flow setting’s settings.<name>.id.

TakesWhat it is
flowIdrequiredThe flow’s id.
startFlow(settings.boost.id)

setMood(moodId)

Sets a mood and says so in a toast. A mood of this Homey: a mood setting’s settings.<name>.id.

TakesWhat it is
moodIdrequiredThe mood’s id.
setMood(settings.evening.id)

Open

openHistory(capability, range?, deviceId?)

Opens a capability’s history in a dialog; the range is picked there and starts at 24 hours. A capability the device has (it doesn’t have to be changeable).

TakesWhat it is
capabilityrequiredA capability id of that device, quoted: 'onoff', 'evcharger_charging'.
rangeIgnored for now: the dialog starts at 24 hours.
deviceIdA device: a setting’s settings.<name>.id. Left out, the tile’s own device.
openHistory('measure_power', '24h')

openDevice(deviceId?)

Opens the device’s details on the Devices page. A device of this Homey.

TakesWhat it is
deviceIdA device: a setting’s settings.<name>.id. Left out, the tile’s own device.
openDevice()

openCamera(deviceId?)

Shows a camera big and live. A camera of this Homey.

TakesWhat it is
deviceIdA device: a setting’s settings.<name>.id. Left out, the tile’s own device.
openCamera()

navigate(dashboardSlug)

Goes to another dashboard; a toast says so when it no longer exists. A dashboard of yours, by its slug.

TakesWhat it is
dashboardSlugrequiredThe dashboard’s slug, quoted.
navigate('energy')

openDashboard(dashboardId, mode?)

Opens a dashboard as a page, or over this one as a popup, a side panel or full screen. A dashboard of yours, by its id.

TakesWhat it is
dashboardIdrequiredThe dashboard’s id.
mode'page' (the default), 'popup', 'side' (a side panel) or 'full' (full screen).
openDashboard(settings.dashboard.id, 'popup')openDashboard(settings.dashboard.id, 'side')openDashboard(settings.dashboard.id, 'full')

This widget

setState(key, value, forMs?)

Keeps a value in state.<key> for this tile on this screen and draws the widget again; it is remembered there after a reload. With forMs it goes back to null after that long, and isn’t remembered. Nothing outside the widget. At most 32 keys; forMs from 100 to 60000.

TakesWhat it is
keyrequiredA name: letters, digits and _, starting with a letter.
valuerequiredText, a number, true, false or null.
forMsOptional: milliseconds until it goes back to null.
setState('details', true)setState('flash', true, 2000)

toggleState(key)

Flips state.<key> between true and false. Nothing outside the widget.

TakesWhat it is
keyrequiredA state name.
toggleState('open')

runTap(setting)

Runs what the tile’s user chose for a tap setting (or its default), as tapping a part marked with it does: for a handler of your own that taps through to it, like the map’s plain tap. A tap setting of this widget; its choice goes through the same checks as any action.

TakesWhat it is
settingrequiredThe tap setting’s name, quoted.
runTap('tileTap')confirm('Open it?') && runTap('tileTap')

Ask and tell

confirm(message)

Asks yes or no; with && the rest only runs after yes. The person at the screen.

TakesWhat it is
messagerequiredThe question, at most 200 characters.
confirm('Stop charging?') && set('evcharger_charging', false)

toast(message)

Shows a short message at the bottom of the screen. The person at the screen.

TakesWhat it is
messagerequiredAt most 200 characters.
toast('Charging stopped')