Every setting has a type property that determines what values it can have and how it is presented to the user. The value property of each setting is the initial value of the setting. The following setting types are supported:
Text
string | null
This is a single line text input whose value is a string. You can optionally validate the value using a regex pattern by adding a pattern property.
Textarea
string | null
This setting type allows users to input multi-line text.
Number
number | null
This setting type allows users to input numerical values. The min and max properties are optional and can be used to define the acceptable range of values.
Dropdown
string | null
This setting type allows users to select a value from a predefined list.
Checkbox
boolean | null
This setting type allows users to enable or disable a feature.
Autocomplete
object | null
This setting type provides an input that suggests options as the user types.
Accessing Settings
Devices
Many widgets are designed to display content based on specific Homey devices. To simplify this, a dedicated devices setting is provided, allowing users to select one or more devices. Once selected, your widget can access their IDs using Homey.getDeviceIds().
Configuration Options
The devices setting includes the following required properties:
'use strict';
const Homey = require('homey');
class MyApp extends Homey.App {
async onInit() {
const widget = this.homey.dashboards.getWidget('my-widget')
widget.registerSettingAutocompleteListener('composer', async (query, settings) => {
return [
{
name: "Mozart",
// Optionally provide the following properties.
description: "...",
image: "https://some.url/",
// You can freely add additional properties
// that you can access in Homey.getSettings()['mySettingId'].
id: "mozart",
},
{
name: "Amadeus",
// You can freely add additional properties
// that you can access in Homey.getSettings()['mySettingId'].
id: "amadeus",
},
].filter((item) => item.name.toLowerCase().includes(query.toLowerCase()));
});
}
}
module.exports = MyApp;
index.html
<html>
<head>
...
</head>
<body>
<script type="text/javascript">
function onHomeyReady(Homey) {
Homey.ready();
for (const [settingId, settingValue] of Object.entries(Homey.getSettings())) {
// Do something with the settings...
}
}
</script>
</body>
</html>