Skip to content

Settings

Let each tile choose a device, a number, a colour or a title, and read the choice in the template and in the style.

A widget you share across many tiles shouldn’t have a device name or a favourite colour written into it. Settings let each tile choose these things, and the widget reads the choice.

A tile’s settings dialog is built from the settings your widget declares, so you never draw a form yourself. A setting for a device becomes a device picker that lists only the devices that fit, a setting for a number becomes a slider, and so on.

Declaring settings

Open the Settings tab in the editor and press Add a setting. Pick a kind, give it a name and a label, and fill in what it needs. Beside the form, a preview shows what the tile’s settings dialog will look like.

The form and its JSON view are two ways of editing the same list, which the editor stores with your widget. Use the JSON view if you prefer typing or pasting. This list declares four settings:

[  { "type": "text", "name": "title", "label": "Title", "default": "Garden", "maxLength": 30 },  {    "type": "color",    "name": "accent",    "label": "Accent colour",    "default": "lit",    "group": "look"  },  {    "type": "size",    "name": "titleSize",    "label": "Title size",    "default": "medium",    "group": "look"  },  {    "type": "device",    "name": "pump",    "label": "Pump",    "help": "The socket the garden pump is plugged into",    "requires": { "all": ["onoff"] },    "classes": ["socket"]  }]

Every setting has these fields:

  • type is the kind of setting.
  • name is the key the template reads: settings.title. It starts with a lower-case letter and continues with letters and digits, up to 32 characters.
  • label is what the tile’s dialog calls it, up to 60 characters.
  • help is an optional line under it, up to 200 characters.
  • required says whether a tile must choose something. It is true unless you say otherwise.
  • group says which tab of the tile’s settings it sits on: content (the default), layout, look, chart, map or tap.

Settings that are simple values always have a default, so the widget works before anyone has chosen anything. A widget can declare up to 32 settings. The settings reference lists every kind with all its options.

The kinds

Some settings choose something from the tile’s Homey:

  • A device picks a device. You say which devices fit: readings they must all have, readings of which one is enough, and optionally a device class. A socket that is set to be an EV charger in Homey counts as an EV charger.
  • A capability picks one reading, of the tile’s own device or of a device setting.
  • A value picks one value from anywhere: a reading of any device, a Homey variable, or the Homey’s energy and prices. You say where it may come from and whether it holds a number, yes or no, or text.
  • A flow, a mood and a dashboard pick one of those on the Homey.
  • Turn on Several for any of these four, and the tile picks a list of them. “All my smoke detectors” is then one setting, not eight.
  • A zone picks a room, a floor or the whole home. The template gets the zone with its devices and its totals now: lights on, temperature, humidity, motion, power and what is playing. A device setting can keep to it with Only devices in, so a room card’s lights follow its room. See zone.
  • A person picks someone of the household. The template gets their name, picture, and whether they are home and asleep. See person.
  • Calendars picks the account’s calendars, all of them unless some are ticked. The template gets their events for the next 30 days, with words for each day and time. See calendars.
  • PINs picks which of the account’s other PINs a keypad takes, besides the account’s own. See pins.
  • A floor plan picks one of your floor plans, a level of it, and the whole level or one room. The template gets the plan, the level and its rooms with their temperature and humidity, and <hd-floorplan> draws it. See floorplan.
  • A model picks a piece of Tiledash’s furniture, one of your own 3D models or one you installed from the Community. The template gets its name and whether it can be drawn, and <hd-model> draws it. A 3D view goes with it: the tile’s owner drags the model into place, any way round, and the template gets that camera for <hd-model>. See model and modelCamera.

Others are simple values with a default: a number (a slider, a stepper or a field), a percentage, yes/no, text, a choice, a colour, an icon, a size and a spot (one of the nine places on a tile).

A third group is made for bigger jobs: lists of readings for a chart, values like the custom tile has, buttons, places for a map, and a tap, which lets the tile’s owner choose what a part of the widget does when it is tapped. You will read more about taps in Taps and handlers.

Tiles is for a widget that holds other widgets, such as a room card whose owner chooses what is on it. The tile’s owner adds tiles of any widget and places them on a grid inside yours, optionally on pages of their own. You say whether the template draws them as a grid (where they were put) or a list (in order), whether there are pages (groups), which kinds can be added (device, flow, mood or free) and the most tiles (max, up to 128). See Widgets in widgets.

Reading a setting in the template

Every setting is under settings, by its name:

<h2 class="title">{{ settings.title }}</h2>{% if settings.pump %}  <p>    {{ settings.pump.name }}:    {{ settings.pump.cap.measure_power.text }} {{ settings.pump.cap.measure_power.unit }}  </p>{% else %}  <p>Choose a pump in the tile’s settings.</p>{% endif %}

What you get depends on the kind:

  • A device reads like the tile’s own device, with its own cap: settings.pump.name, settings.pump.cap.onoff.value.
  • A capability reads like cap.<id>, with its id as well: settings.reading.text.
  • A value has its label, value, text and unit: {{ settings.outside.text }} {{ settings.outside.unit }}.
  • A flow and a mood are objects with an id and a name, and a dashboard has an id and a name.
  • Tiles is the grid and the tiles placed on it, { columns, rows, tiles }, or with pages { columns, rows, groups }. Tiles and pages that aren’t showing now are left out. See Tiles your users place.
  • Numbers, text, choices, colours, icons, sizes and spots are the value itself. A yes/no is true or false.

A setting that isn’t chosen, is gone from the Homey, or no longer fits is null. That is why {% if settings.pump %} works, and why a device setting must always be tested before you use it. An optional text left empty, and an icon or a colour without a default, are null as well.

Going through a list

A setting with Several on is a list. Go through it with for:

{% for alarm in settings.alarms %}  <p class="{% if alarm.cap.alarm_smoke.value %}alarm{% endif %}">    {{ alarm.zone }}: {{ alarm.cap.alarm_smoke.text }}  </p>{% else %}  <p>Choose smoke detectors in the tile’s settings.</p>{% endfor %}

Each device in the list reads like a device setting. A list is never null, only empty, so test it with {% if settings.alarms.size > 0 %}.

Each tile picks its devices in an order, or takes every device that fits. With every device that fits, a smoke detector added to Homey later shows up by itself.

An action inside the loop names its device: toggle('onoff', '{{ alarm.id }}'). While it is on its way, alarm.pending.onoff shows it, as settings.pump.pending does for a single device.

The editor checks your widget with settings left empty, so a template that assumes a device is there is reported while you write it. Reading settings.pump without declaring it is an error.

Settings per screen size

A simple setting (a choice, yes/no, a number, a size…) with "perSize": true can differ per screen size: the tile’s settings get a Desktop, Tablet and Phone switch, and a size left alone follows Desktop. The template and the style read the value of the size on screen, as always under settings.<name>. A dock setting with "perSize": true lets a tile sit flush on a side on a tablet and at the bottom on a phone.

Tips about your settings

A widget can explain what its settings can do with up to three tips. Each points at one of its settings: the first time someone opens a tile’s settings with that setting on screen, a Did you know? shows beside it, one tip at a time and each only once. A widget with settings per screen size gets the app’s own tip at the size switch first.

"tips": [  {    "name": "tab-view",    "setting": "dock",    "title": "A tab view, like an app",    "text": "Set Where to Flush on the left and the stack sits against the sidebar at its full height."  }]

A name is lower case and dashes. The title is at most 40 characters and the text at most 220. They translate as tip.<name>.title and tip.<name>.text. Use the settings’ own labels and choices in the text, so people find what it talks about.

Reading a setting in the style

Settings that are simple values reach the style as CSS variables. The name is --setting- followed by the setting’s name in lower-case words joined with dashes: titleSize becomes --setting-title-size.

.title {  color: var(--setting-accent);  font-size: calc(18px * var(--setting-title-size-scale));}

What each kind becomes:

KindThe variable holds
A numberThe number, followed by its unit when that is a CSS unit: 24px, 1.5em, 7.4
A percentageThe number and a percent sign: 62%
Yes/no1 or 0
A colourThe theme’s variable, such as var(--hd-lit), or the #rrggbb colour
A sizesmall, medium or large, and -scale adds 0.85, 1 or 1.25
A choiceThe chosen value
A spotThe spot’s name, such as top-left
Text, an iconThe text as a quoted CSS string

Devices, capabilities, flows, moods and the bigger kinds aren’t values a style can use, so they get no variable.

A style can also look at a choice through an attribute that you set from Liquid:

<div class="panel" data-layout="{{ settings.layout }}">…</div>
.panel[data-layout='compact'] {  gap: 4px;}

Devices by their id

Sometimes you want a widget for one particular device, and you copy its id into the template as devices['…']. That works, but only on your Homey, and the editor warns you about it. A device setting does the same job on every Homey, so the editor offers Make this a setting instead. The same goes for a Homey variable named by its id, variables['…']: Make this a setting turns it into a value setting.

A reading of the tile’s own device, cap.<id>, can become a value setting too, so each tile picks what it shows: a reading of any device, a variable, or energy and prices. In the Data panel, a reading the template uses has a Make this a setting button. It reads the setting where the template read the reading’s value, text, unit, title (as label) or lastUpdated. A reading used whole, as a live reference (bind="{{ cap.dim }}"), stays as it is: the editor says which line.

Naming settings well

  • Name the setting after what it is, not where it sits: charger, not device2.
  • Write the label for the person using the tile: Charger, not charger_device.
  • Put a few lines of help on the settings that need explaining.
  • Keep the first tab short. Move settings about looks to look, so a tile’s Content tab only holds what matters most.