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.
This setting type allows users to input multi-line text.
{"id":"description","type":"textarea","title": { "en":"Textarea" },"value":"Enter your description here.","hint": { "en":"Provide a detailed description." },"pattern":"[a-zA-Z]"}
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.
'use strict';constHomey=require('homey');classMyAppextendsHomey.App {asynconInit() {constwidget=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;
Accessing Settings
index.html
<html><head>...</head><body> <scripttype="text/javascript">functiononHomeyReady(Homey) {Homey.ready();for (const [settingId,settingValue] ofObject.entries(Homey.getSettings())) {// Do something with the settings... } } </script></body></html>