Core Concept
There are two fundamentally different data types in ioBroker: so-called states(states) and objects.
Objects represent rarely changing and larger data, like meta-data of your system devices, configurations, and additional files. Every Object has to have an attribute "type". See below for more information about what object types are available and which mandatory attributes an object of a specific type needs. Functions like setObject, getObject, ... are provided to you by the adapter module.
States represent often changing data in your system, like f.e. if a lamp is on or off, if a motion detector detected
some motion, the temperature of your living room or if the button of a remote control is pressed. Contrary to objects,
states can be used to trigger actions and states can create history data. To work with states, there are several functions
in the adapter module like setState, getState and so on.
For every state there also has to exist a corresponding object with type=state.
The following chapters describe Database Schema.
IDs
ID is a string with a maximum length of 240 bytes, hierarchically structured, levels separated by dots.
The regex that it used to check for characters that are prohibited to use in IDs can be found here.
The ID has different levels. Each level is determined by the dot. Example: system.adapter.admin.0
system- is the name space for system objectsadapter- namespace for adapter configsadmin- adapter name0- adapter instance
Or other example hm-rpc.1.ABC110022.2.VALUE:
hm-rpc- is the name of adapter1- adapter instanceABC110022- device address2- channel nameVALUE- state name
Namespaces
system.- System objects and statessystem.host.- Controller processessystem.config.- System settings, like default languagesystem.meta.- System meta datasystem.user.- Userssystem.group.- Groupssystem.adapter.<adapter-name>- default config of an adapter<adapter-name>.- objects for specific adapter.<adapter-name>.meta.- common meta-data used by all instances of this adapter<adapter-name>.<instance-number>.- An adapters instance namespaceenum.- Enumerationshistory.- History Datascripts.- Script Engine Scriptsscripts.js.- javascript Script Engine Scriptsscripts.py.- python Script Engine Scripts (future)
Namespace system.config.
{
_id: id,
type: 'config',
common: {
language: 'en', // Default language for adapters. Adapters can use different values.
tempUnit: '°C', // Default temperature units.
currency: '€', // Default currency sign.
dateFormat: 'DD.MM.YYYY' // Default date format.
isFloatComma: true, // Default float divider ('.' - false, ',' - true)
"activeRepo": "online1", // active repository
"listRepo": { // list of possible repositories
"default": "conf/sources-dist.json",
"online1": "https://raw.githubusercontent.com/ioBroker/ioBroker.nodejs/master/conf/sources-dist.json"
}
}
}
Namespace system.host.<hostname>
{
_id: id,
type: 'host',
common: {
name: id,
process: title, // iobroker.ctrl
version: version, // Vx.xx.xx
platform: 'javascript/Node.js',
cmd: process.argv[0] + ' ' + process.execArgv.join(' ') + ' ' + process.argv.slice(1).join(' '),
hostname: hostname,
address: ipArr,
defaultIP: ???
},
native: {
process: {
title: process.title,
pid: process.pid,
versions: process.versions,
env: process.env
},
os: {
hostname: hostname,
type: os.type(),
platform: os.platform(),
arch: os.arch(),
release: os.release(),
uptime: os.uptime(),
endianness: os.endianness(),
tmpdir: os.tmpdir()
},
hardware: {
cpus: os.cpus(),
totalmem: os.totalmem(),
networkInterfaces: os.networkInterfaces()
}
}
};
States
getState method and stateChange event delivers an object with all attributes except expire
for setState method everything except val is optional, from is set automatically by the setState method. ack defaults to false, ts and lc are set as expected
It is important to note that the value a state of type array, object, mixed or file must be serialized using JSON.stringify().
Attributes for getState/stateChange/setState object:
val- the actual value - can be any type that is JSON-"encodable"ack- a boolean flag indicating if the target system has acknowledged the valuets- a UNIX timestamp indicating the last update of the state (in milliseconds)lc- a UNIX timestamp indicating the last change of the state's actual value (in milliseconds)from- adapter instance that did thesetStateuser- the username, that set the valueexpire- an integer value that can be used to set states that expire after a given number of seconds. Can be used ony withsetValue. After the value expires, it disappears from redisDB.c- comment for this state change.q- quality. Number of the following states:
0x00 - 00000000 - good (can be undefined or null)
0x01 - 00000001 - general bad, general problem
0x02 - 00000010 - no connection problem
0x10 - 00010000 - substitute value from controller
0x20 - 00100000 - substitute initial value
0x40 - 01000000 - substitute value from device or instance
0x80 - 10000000 - substitute value from sensor
0x11 - 01000001 - general problem by instance
0x41 - 01000001 - general problem by device
0x81 - 10000001 - general problem by sensor
0x12 - 00010010 - instance not connected
0x42 - 01000010 - device not connected
0x82 - 10000010 - sensor not connected
0x44 - 01000100 - device reports error
0x84 - 10000100 - sensor reports error
Every state has to be represented by an object of the type state containing Meta-Data for the state. See below.
Objects
Mandatory attributes
The following attributes have to exist in every object:
_idtype- see below for possible valuescommon- an object containing ioBroker specific abstraction propertiesnative- an object containing congruent properties of the target system
Optional attributes
common.name- the name of the object (optional but strictly suggested to fill it)
Tree structure
The tree structure is assembled automatically by names. E.g. system.adapter.0.admin is the parent for system.adapter.0.admin.uptime. Use this name convention with point ".", as divider of levels.
Object types
state- parent should be of type channel, device, instance or hostchannel- object to group one or more states. Parent should be a device.device- object to group one or more channels or state. Should have no parent except adapter instance namespace.enum- objects holding an array incommon.membersthat points to the states, channels, devices or files. enums can have a parent enum (tree-structure possible)host- a host that runs a controller processadapter- the default config of an adapter. presence also indicates that the adapter is successfully installed. (suggestion: should have an attribute holding an array of the hosts where it is installed)instance- instance of adapter. Parent has to be of type adaptermeta- rarely changing meta-information that an adapter or his instances needsconfig- configurationsscript- scriptsuser- usersgroup- groupschart- chartsfolder- a bunch of devices or may be other things.schedule- a schedule,e.g. calendar eventdesign- a design object used forgetObjectView
Attributes for specific object types
State
Attributes:
common.type(optional - (default ismixed==any type) (possible values:array,boolean,file,json,mixed,multistate,number,object,string). As exception the objects with typemetacould havecommon.type=meta.userormeta.folder. It is important to note that array, object, mixed and file must be serialized usingJSON.stringify().common.min(optional)common.max(optional)common.step(optional) - increase/decrease interval. E.g., 0.5 for thermostatcommon.unit(optional)common.def(optional - the default value)common.defAck(optional - ifcommon.defis set this value is used as an acknowledgment flag,js-controller2.0.0+)common.desc(optional, string or object) - description, object for multilingual descriptioncommon.read(boolean, mandatory) - true if state is readablecommon.write(boolean, mandatory) - true if state is writablecommon.role(string, mandatory) - role of the state (used in user interfaces to indicate which widget to choose, see below)common.states(optional) - provide more context on allowed values for states with data types string and number:- for numbers without provided common.min/common.max: contains the list of allowed number values and their (displayed) label as an object in form
{0: 'OFF', 1: 'ON', '-1': 'whatever'}. Only these values are allowed - for numbers with provided
common.minand/or common.max: the allowed number range is defined by min/max, this attribute contains a list of "special" number values and their (displayed) label as object like{0: 'OFF', 254: 'ON', 255: 'BLINK'}(min=0, max=255). It is allowed to only specify min or max, the missing limit is then assumed as +/-Infinity (+/-Infinity not included) - for strings contains the list of allowed values and their (displayed) label as object like
{'value': 'valueName', 'value2': 'valueName2'}. Only these values are allowed - for strings contains the list of allowed values as array like
['Start', 'Flight', 'Land'](which in fact is the same as{'Start': 'Start', 'Flight': 'Flight', 'Land': 'Land'}). Only these values are allowed - These values are currently (as of js-controller 4.0) not checked or validated by the js-controller and are only there for UIs and Visualizations
- for numbers without provided common.min/common.max: contains the list of allowed number values and their (displayed) label as an object in form
common.workingID(string, optional) - if this state has helper state WORKING. Here must be written the full name or just the last part if the first parts are the same with actual. Used forHM.LEVELand normally has valueWORKINGcommon.custom(optional) - the structure with custom settings for specific adapters. Like{"influxdb.0": {"enabled": true, "alias": "name"}}.enabledattribute is required, and if it is not true, the whole attribute will be deleted.
State common.role
common.role(indicates how this state should be represented in user interfaces)
Channel
Channel common.role (optional)
suggestion: the channel-objects common.role should/could imply a set of mandatory and/or optional state-child-objects
possible values:
-
info- Currency or shares rate, fuel prices, post box insertion and stuff like that -
calendar- -
forecast- weather forecast -
`media - common media channel
-
media.music- media player, like SONOS, YAMAHA and so on -
media.tv- TV -
media.tts- text to speech -
thermo- Monitor or control the temperature, humidity and so on -
thermo.heat -
thermo.cool -
blind- Window blind control -
light -
light.dimmer- Light dimmer -
light.switch- Light switch. -
light.color- Light control with ability of color changing -
light.color.rgb- Set color in RGB -
light.color.rgbw- Set color in RGBW -
light.color.hsl- Set color in Hue/Saturation/Luminance (Hue color light - LivingColors...) -
light.color.hslct- Set color in Hue/Saturation/Luminance or Color Temperature (Hue extended color light) -
light.color.ct- color temperature K -
switch- Some generic switch -
sensor- E.g. window or door contact, water leak sensor, fire sensor -
sensor.door- open, close -
sensor.door.lock- open, close, locked -
sensor.window- open, close -
sensor.window.3- open, tilt, close -
sensor.water- true(alarm), false (no alarm) -
sensor.fire- true(alarm), false (no alarm) -
sensor.CO2- true(alarm), false (no alarm) -
alarm- some alarm -
phone- fritz!box, speedport and so on -
button- like wall switch or TV remote, where every button is a state like .play, .stop, .pause -
remote- TV or other remotes with state is string with pressed values, e.g. "PLAY", "STOP", "PAUSE" -
meta- Information about a device -
meta.version- device version -
meta.config- configuration from device -
...
Channel descriptions
The names of the attributes can be free defined by the adapter, except ones written with bold font.
"W" - common.write=true
"M" - Mandatory
Optional states for every channel/device
// state-working (optional)
{
"_id": "adapter.instance.channelName.stateName-working", // e.g. "hm-rpc.0.JEQ0205612:1.WORKING"
"type": "state",
"common": {
"name": "Name of state", // mandatory, default _id ??
"def": false, // optional, default false
"type": "boolean", // optional, default "boolean"
"read": true, // mandatory, default true
"write": false, // mandatory, default false
"min": false, // optional, default false
"max": true, // optional, default true
"role": "indicator.working", // mandatory
"desc": "" // optional, default undefined
}
}
// state-direction (optional). The state can have the following states: "up"/"down"/""
{
"_id": "adapter.instance.channelName.stateName-direction", // e.g. "hm-rpc.0.JEQ0205612:1.DIRECTION"
"type": "state",
"common": {
"name": "Name of state", // mandatory, default _id ??
"def": "", // optional, default ""
"type": "string", // optional, default "string"
"read": true, // mandatory, default true
"write": false, // mandatory, default false
"role": "direction", // mandatory
"desc": "" // optional, default undefined
}
}
// state-maintenance (optional).
{
"_id": "adapter.instance.channelName.stateName-maintenance", //e.g. "hm-rpc.0.JEQ0205612:1.MAINTENANCE"
"type": "state",
"common": {
"name": "Name of state", // mandatory, default _id ??
"def": false, // optional, default false
"type": "boolean", // optional, default "boolean"
"read": true, // mandatory, default true
"write": false, // mandatory, default false
"min": false, // optional, default false
"max": true, // optional, default true
"role": "indicator.maintenance", // mandatory
"desc": "Problem description" // optional, default undefined
}
}
// state-maintenance-unreach (optional).
{
"_id": "adapter.instance.channelName.stateName-maintenance-unreach", //e.g. "hm-rpc.0.JEQ0205612:0.UNREACH"
"type": "state",
"common": {
"name": "Name of state", // mandatory, default _id ??
"def": false, // optional, default false
"type": "boolean", // optional, default "boolean"
"read": true, // mandatory, default true
"write": false, // mandatory, default false
"min": false, // optional, default false
"max": true, // optional, default true
"role": "indicator.maintenance.unreach", // mandatory
"desc": "Device unreachable" // optional, default 'Device unreachable'
}
}
light.switch - Attributes description
| Name | common.role | M | W | common.type | Description |
|---|---|---|---|---|---|
| state | switch | X | X | boolean | |
| description | text.description | ||||
| mmm | indicator.maintenance.mmm | mmm = lowbat or unreach or whatever |
// SWITCH CHANNEL
{
"_id": "adapter.instance.channelName", // e.g. "hm-rpc.0.JEQ0205614:1"
"type": "channel",
"common": {
"name": "Name of channel", // mandatory, default _id ??
"role": "light.switch" // optional default undefined
"desc": "" // optional, default undefined
}
},
// SWITCH STATES
{
"_id": "adapter.instance.channelName.state-switch", // e.g. "hm-rpc.0.JEQ0205614:1.STATE"
"type": "state",
"common": {
"name": "Name of state", // mandatory, default _id ??
"def": false, // optional, default false
"type": "boolean", // optional, default "boolean"
"read": true, // mandatory, default true
"write": true, // mandatory, default true
"role": "switch" // mandatory
"desc": "" // optional, default undefined
}
}
// see "Optional states for every channel/device" for description of optional states
// "adapter.instance.channelName.state-maintenance" // optional
// "adapter.instance.channelName.state-maintenance-unreach" // optional
light.dimmer - Attributes description
// DIMMER CHANNEL
{
"_id": "adapter.instance.channelName", // e.g. "hm-rpc.0.JEQ0205612:1"
"type": "channel",
"common": {
"name": "Name of channel", // mandatory, default _id ??
"role": "light.dimmer" // optional default undefined
"desc": "" // optional, default undefined
}
},
// DIMMER STATES
{
"_id": "adapter.instance.channelName.state-level", // e.g. "hm-rpc.0.JEQ0205612:1.LEVEL"
"type": "state",
"common": {
"name": "Name of state", // mandatory, default _id ??
"def": 0, // optional, default 0
"type": "number", // optional, default "number"
"read": true, // mandatory, default true
"write": true, // mandatory, default true
"min": 0, // optional, default 0
"max": 100, // optional, default 100
"unit": "%", // optional, default %
"role": "level.dimmer" // mandatory
"desc": "" // optional, default undefined
}
}
// see "Optional states for every channel/device" for description of optional states
// "adapter.instance.channelName.state-working", // optional
// "adapter.instance.channelName.state-direction", // optional
// "adapter.instance.channelName.state-maintenance" // optional
// "adapter.instance.channelName.state-maintenance-unreach" // optional
blind - Attributes description
// BLIND CHANNEL
{
"_id": "adapter.instance.channelName", // e.g. "hm-rpc.0.JEQ0205615:1"
"type": "channel",
"common": {
"name": "Name of channel", // mandatory, default _id ??
"role": "blind" // optional default undefined
"desc": "" // optional, default undefined
}
},
// BLIND STATES
// Important: 0% - blind is fully closed, 100% blind is fully opened
{
"_id": "adapter.instance.channelName.state-level", // e.g. "hm-rpc.0.JEQ0205615:1.LEVEL"
"type": "state",
"common": {
"name": "Name of state", // mandatory, default _id ??
"def": 0, // optional, default 0
"type": "number", // optional, default "number"
"read": true, // mandatory, default true
"write": true, // mandatory, default true
"min": 0, // optional, default 0
"max": 100, // optional, default 100
"unit": "%", // optional, default %
"role": "level.blind" // mandatory
"desc": "" // optional, default undefined
}
}
phone - Attributes description
| Name | common.role | M | W | common.type | Description |
|---|---|---|---|---|---|
ringing_number | text.phone_number | string | |||
ringing | indicator | boolean |
...
Device
Enum
common.members- (optional) array of enum member IDs
Meta
ID
*<adapter-name>.<instance-number>.meta.<meta-name>**<adapter-name>.meta.<meta-name>*system.*meta.<meta-name>*
Adapter
ID: system.adapter.<adapter.name>
Notice: all flags are optional except special marked as mandatory.
common.adminColumns- Custom attributes, that must be shown in the admin in the object browser. Like:[{"name": {"en": "KNX address"}, "path": "native.address", "width": 100, "align": "left"}, {"name": "DPT", "path": "native.dpt", "width": 100, "align": "right", "type": "number", "edit": true, "objTypes": ["state", "channel"]}].typeis a type of the attribute (e.g. string, number, boolean) and only needed if edit is enabled.objTypesis a list of the object types, that could have such attribute. Used only in edit mode too.common.adminTab.fa-icon- (deprecated) Font-Awesome icon name for TAB.common.adminTab.icon- (optional) link to icon or base64 encoded icon for TAB. Could be SVGcommon.adminTab.ignoreConfigUpdate- do not update config TAB if configuration changed (to enable configure settings in TAB)common.adminTab.link- link for iframe in the TAB. You can use parameter replacement like this:http://%ip%:%port%. IP will be replaced with host IP. Aportwill be extracted fromnative.port.common.adminTab.name- name of TAB in admincommon.adminTab.singleton- [true/false] if adapter has a TAB for the admin. Only one TAB for all instances will be shown.common.adminUI.config- [none/json/materialize/html] type of configuration UI. If not defined, the adapter will be shown as HTML. (jsonConfig.jsonorjsonConfig.json5byjson,index_m.htmlbymaterialize,index.htmlbyhtmlare expected inadminfolder)common.adminUI.custom- [none/json] type of custom configuration UI. If not defined, no custom UI will be shown. It is only possible to usejsonCustom.jsonorjsonCustom.json5inadminfolder.common.adminUI.tab- [none/html] type of TAB UI.tab.htmlortab_m.htmlare extended in folderadminif defined tohtml.common.allowInit- [true/false] allow for "scheduled" adapter to be called "not in the time schedule", if settings changed or adapter started. Or allow scheduled adapter start once after configuration changed and then by schedule.common.availableModes- values forcommon.modeif more than one mode is possiblecommon.blockly- [true/false] if adapter has custom blocks for blockly. (admin/blockly.jsrequired)common.compact- says to controller that this adapter can be started in the same process if desiredcommon.config.height- default height for configuration dialog (deprecated - valid only for admin2)common.config.minHeight- minimal height for configuration dialog (deprecated - valid only for admin2)common.config.minWidth- minimal width for configuration dialog (deprecated - valid only for admin2)common.config.width- default width for configuration dialog (deprecated - valid only for admin2)common.connectionType- Connection type with the device:local/cloud. Seecommon.dataSourcetoo.common.dataFolder- folder relative to iobroker-data where the adapter stores the data. This folder will be backed up and restored automatically. You can use variable%INSTANCE%in it.common.dataSource- How the data will be received from a device:poll/push/assumption. It is important together withconnectionType.common.dependencies- Array like[{"js-controller": ">=2.0.0"}]that describes which ioBroker modules are required for this adapter on the same host.common.disableDataReporting- Do not report errors via thesentryfor this instancecommon.docs- The structure like{"en": "docs/en/README.md", "de": ["docs/de/README.md", "docs/de/README1.md"]}that describes the documentation if not inREADME.mdcommon.enabled- mandatory [true/false] value should be false so new instances are disabled by defaultcommon.engineTypes- deprecated. Use engine in package.jsoncommon.eraseOnUpload- erase all previous data in the directory before uploadcommon.expert- show this object only in the expert mode in admincommon.extIcon- link to external icon for uninstalled adapters. Normally on GitHub.common.getHistory- [true/false] if adapter supports getHistory messagecommon.globalDependencies- Array like[{"admin": ">=2.0.0"}]that describes which ioBroker modules are required for this adapter on one of the hosts.common.icon- name of the local icon (should be located in subdirectory "admin")common.ignoreVersion- Do not show the update icon for this adapter for this specific versioncommon.installedVersion- Do not use it, will be set internally onlycommon.jsonConfig- This adapter supports admin5 and provides admin/jsonConfig.json with description of configuration dialog layoutcommon.jsonCustom- This adapter supports admin5 and provides admin/jsonCustom.json with description of custom settings layoutcommon.keywords- Similar to keywords in package.json, but can be defined in many languages. Just an array.common.localLink- deprecated. Usecommon.localLinks.common.localLinks- link to the web service of this adapter. E.g., to http://localhost:5984/_utils for the futon from admincommon.logTransporter- if this adapter receives logs from other hosts and adapters (e.g., to store them somewhere)common.loglevel- debug, info, warn or errorcommon.main- Deprecated Use main in package.json.common.materializeTab- if adapter supports > admin3 for the tab (materialize style)common.materialize- if adapter supports > admin3 (materialize style)common.messagebox- true if message box supported. Hence, the adapter can receive sendTo messages (used for email, pushover,...)common.messages- Conditional messages by update. See Conditional messages for details.common.mode- mandatory possible values see belowcommon.name- mandatory name of adapter without "ioBroker."common.noConfig- [true/false] do not show configuration dialog for instancecommon.noIntro- never show instances of this adapter on Intro/Overview screen in the admin (like icons, widgets)common.noRepository- [true/false] if adapter delivered with initial installation or has own repositorycommon.nogit- if true, no installation from GitHub directly is possiblecommon.nondeletable- [true/false] this adapter cannot be deleted or updated. It will be updated together with the controller.common.npmLibs- deprecated. Use package.jsondependencies.common.onlyWWW- [true/false] say to controller, that adapter has only HTML files and no main.js, like rickshawcommon.osDependencies.darwin- array of OSX packages that required for this adaptercommon.osDependencies.linux- array of debian/centos packages, that required for this adapter (of course only OS with apt, apt-get, yum as package managers)common.osDependencies.win32- not used, because win32 has no package managercommon.os- string or array of the supported operating systems, e.g.["linux", "darwin"]common.platform- mandatory possible values: Javascript/Node.js, more comingcommon.preserveSettings- string (or array) with names of attributes in common of instance, which will not be deleted. E.g. "history", so bysetState("system.adapter.mqtt.0", {..})the fieldcommon.historywill not be deleted even if new object does not have this field. To delete the attribute it must be explicitly done withcommon: {history: null}.common.pugins.sentry- structure with the configuration data for thesentryplugincommon.readme- URL of the ReadMe filecommon.restartAdapters- array with names of adapter that must be restarted after this adapter is installed, e.g. ["vis"]common.restartSchedule- CRON schedule to restart modedaemonadapterscommon.schedule- CRON schedule if adapter runs in modeschedule.common.serviceStates- [true/false or path] if adapter can deliver additional states. If yes, the pathadapter/lib/states.jswill be called, and it gives following parameters function (objects, states, instance, config, callback). The function must deliver the array of points with values likefunction (err, result) { result = [{id: 'id1', val: 1}, {id: 'id2', val: 2}]}common.singletonHost- adapter can be installed only once on one hostcommon.singleton- adapter can be installed only once in a whole systemcommon.smartName- Related to IoT adapter to store settings for alexa & co.common.statusStates- Structure for status indication in admin in form"statusStates": {"onlineId": "0.connected", "errorId": "hm-rpc.0.AB203424.0.error"}. Instead ofonlineIdtheofflineIdcould be used. If ID is very short (less than 2 dots in it), so the ID will be treated as relative to the current object.common.stopBeforeUpdate- [true/false] if adapter must be stopped before updatecommon.stopTimeout- timeout in ms to wait, till the adapter shut down. Default 500ms.common.stoppedWhenWebExtension- If instance has modedaemonbut it runs as a web extension (native.webInstance !== ''), controller will not start this instance ifcommon.stoppedWhenWebExtensionis true.common.subscribable- variables of this adapter must be subscribed with sendTo to enable updatescommon.subscribe- name of variable that is subscribed automaticallycommon.supportCustoms- [true/false] if the adapter support settings for every state. It has to have custom.html file in the admin. Sample can be found inioBroker.historycommon.supportStopInstance- [true/false] if adapter supports signal stopInstance (messagebox required). The signal will be sent before stop to the adapter. (used if the problems occurred with SIGTERM)common.tier- start order of the instance. Allowed values: 1, 2, 3. 1 - first, 3 - lastcommon.titleLang- mandatory longer name of adapter in all supported languages like{en: 'Adapter', de: 'adapter', ru: 'Драйвер'}common.title- (deprecated) longer name of adapter to show in admincommon.type- Adapter type. See Typescommon.unchanged- (system) please do not use this flag. It is a flag to inform the system that configuration dialog must be shown in the admin.common.unsafePerm- [true/false] if the package must be installed withnpm --unsafe-permparametercommon.version- mandatory available versioncommon.visWidgets- Describesvis2 react widgets. Like{"i18n": "component", "vis2NAMEWidgets": { "name": "vis2NAMEWidgets", "url": "vis-2-widgets-NAME/customWidgets.js", "components": [ "NAMEwidgetName"]} }common.wakeup- Adapter will be started if some value is written intosystem.adapter.NAME.x.wakeup. Normally, the adapter should stop after processing of event.common.webByVersion- show a version as prefix in web adapter (usually -ip:port/material, webByVersion -ip:port/1.2.3/material)common.webExtendable- [true/false] if web server in this adapter can be extended with plugin/extensions like proxy, simple-apicommon.webExtension- relative filename to connect the web extension. E.g., insimple-apilib/simpleapi.jsrelative to the adapter root directory. Additionally,native.webInstanceis required to say where this extension will be included. Empty means, it must run as own web service. "*" means every web server must include it.common.webPreSettings- list of parameters that must be included in info.js by webServer adapter. (Example material)common.webservers- array of web server's instances that should serve content from the adapter's www foldercommon.welcomeScreen.order- todocommon.welcomeScreenPro- Same ascommon.welcomeScreenbut used only by access from ioBroker.cloud.common.welcomeScreen- array of pages, that should be shown on the "web" index.html page.["vis/edit.html", "vis/index.html"]or[{"link": "vis/edit.html", "name": "Vis editor", "img": "vis/img/edit.png", "color": "blue"}, "vis/index.html"]common.wwwDontUpload- Do not upload into the database the www directory. Used only for the admin. You can just name your directory something else and OK.protectedNative- array of config attributes which will only be accessible by the own adapter, e.g.["password"]encryptedNative- array of config attributes which will be automatically encrypted when stored via Admin configuration page and automatically decrypted at adapter runtime, e.g.["password", "token"]native- predefined attributes which are accessible inindex_m.htmland at runtime viaadapter.config.<attribute>, e.g.{"port": 1234, "password": "secret"}
Conditional Messages (common.messages)
You can define conditional messages that are shown to the user when updating an adapter. These messages can depend on the old version, new version, or even the presence of other adapters.
Structure
"messages": {
"condition": {
"operand": "and", // "and" = all rules must be true, "or" = at least one must be true
"rules": [
"oldVersion<=1.0.44", // condition using the old version
"newVersion>=1.0.45" // condition using the new version
]
},
"title": {
"en": "Important notice"
},
"text": {
"en": "Main text shown to the user"
},
"link": "https://iobroker.net/www/pricing", // optional
"buttons": ["agree", "cancel", "ok"], // optional. If missing, the message only appears in the changelog
"linkText": {
"en": "More info" // optional text for the link
},
"level": "warn" // one of: "info", "warn", "error"
}
Supported Rules
Rules are strings inside the rules array. Examples:
-
Version checks
"oldVersion<=1.0.44"– old version is less than or equal to 1.0.44"newVersion>=1.0.45"– new version is greater than or equal to 1.0.45 (operators:<,>,<=,>=,==,!=)
-
Installed state
"installed"– true if the adapter was already installed"not-installed"or"!"– true if the adapter was not installed
-
Other adapters
"vis-2>=1.0.0"– true if adaptervis-2is installed with version ≥ 1.0.0"vis"– true if adaptervisis installed"!vis-2"– true if adaptervis-2is not installed
Rule Reference
| Rule example | Meaning |
|---|---|
oldVersion<=1.0.44 | The currently installed version is ≤ 1.0.44 |
oldVersion>=1.2.0 | The currently installed version is ≥ 1.2.0 |
newVersion>=1.0.45 | The version being installed is ≥ 1.0.45 |
newVersion==2.0.0 | The version being installed is exactly 2.0.0 |
installed | True if the adapter was already installed (any version) |
not-installed or ! | True if the adapter was not installed before |
vis-2>=1.0.0 | True if adapter vis-2 is installed with version ≥ 1.0.0 |
vis | True if adapter vis is installed (any version) |
!vis-2 | True if adapter vis-2 is not installed |
Operators supported
==– equal!=– not equal<– less than<=– less than or equal>– greater than>=– greater than or equal
Operand
"and"→ all rules must be true"or"→ at least one rule must be true
Examples
Example 1: Show message only when upgrading from version ≤1.0.44 to ≥1.0.45
{
"messages": {
"condition": {
"operand": "and",
"rules": [
"oldVersion<=1.0.44",
"newVersion>=1.0.45"
]
},
"title": { "en": "Important update" },
"text": { "en": "Please read before continuing." },
"level": "warn"
}
}
Example 2: Show message if adapter is newly installed
{
"messages": {
"condition": {
"operand": "or",
"rules": ["not-installed"]
},
"title": { "en": "Welcome!" },
"text": { "en": "Thanks for installing this adapter." },
"level": "info"
}
}
Example 3: Show message if another adapter is required
{
"messages": {
"condition": {
"operand": "and",
"rules": ["vis-2>=1.0.0"]
},
"title": { "en": "Dependency notice" },
"text": { "en": "This adapter requires vis-2 version 1.0.0 or higher." },
"link": "https://example.com/setup-guide",
"linkText": { "en": "Setup guide" },
"level": "error"
}
}
Test and debugging
To test the messages and their rules in, for example, a "dev server" environment, the following steps must be implemented:
- Identify the future version number under which the message should be displayed. This version number will later be selected during the release process.
- Add the
common.messagesobject to theio-packages.jsonfile according to the description. - Include the previously identified version number in the
common.messagesobject, if necessary. - Add the changelog entry to the
common.newsobject, using the identified version number. This changelog information will later be displayed in the update dialog, along with the information from thecommon.messagesobject. - Enable expert mode in the iobroker of the test environment.
- In the object view, open the following data point:
system.repositories. - For security reasons, and because the object is very large, it is recommended to copy the content and edit it in a JSON editor (e.g., VS Code or Notepad++).
- In the editor, locate the existing adapter object.
- In the found object, modify the following information:
version-> with the version number identified abovenews-> add the changelog entry for the identified version numbermessages-> insert the prepared message object fromio-packages.json.- To prevent problems, the result should be checked in a JSON validator.
- Then copy the result back into the "system.repositories" object and save it.
- Open or reload the adapter tab in the admin interface.
- The updated version should now be displayed as available for update for the adapter.
- After clicking the update button for the adapter, the information from the message object should be displayed in a dialog after a short time.
- Since this version is not yet available on npm, pressing the update button will result in an error, and the dialog should be closed.
instance
ID: system.adapter.<adapter.name>.<instance-number>
common.host- (mandatory) host where the adapter should be started at - objectsystem.host.<host>must existcommon.enabled- (mandatory)common.mode- (mandatory) possible values see below
adapter/instance common.mode
none- this adapter doesn't start a processdaemon- always running process (will be restarted if process exits)subscribe- is started when statesystem.adapter.<adapter-name>.<instance-number>.alivechanges totrue. Is killed when.alivechanges tofalseand sets.alivetofalseif process exits (will not be restarted when process exits)schedule- is started by schedule found insystem.adapter.<adapter-name>.<instance-number>.schedule- reacts on changes of.scheduleby rescheduling with new stateonce- this adapter will be started every time thesystem.adapter.yyy.xobject changed. It will not be restarted after termination.extension- this adapter will be not started byjs-controller, but it will be started by web instance. Web instance can be defined innative.webInstanceas '*' (if in every web) or asweb.xfor specific web instance. (Examples:cameras, proxy). Additionally, incommon.webExtensionthe path to plugin file must be provided.
host
ID: system.host.<host>
common.name- f.e.system.host.bananacommon.processcommon.versioncommon.platformcommon.cmdcommon.hostname- f.e.bananacommon.address- array of ip address strings
config
script
common.platform- (mandatory) possible ValuesJavascript/Node.js(more to come)common.enabled- (mandatory) is a script activated or notcommon.source- (mandatory) the script sourcecommon.engine- (optional) script engine instance that should run this script (e.g. 'javascript.0') - if omitted engine is automatically selected
user
common.name- (mandatory) Name of user (Case sensitive)common.password- (mandatory) MD5 Hash of password
group
common.name- (mandatory) name of the groupcommon.members- (mandatory) array of user-object IDscommon.desc- (optional) group purpose description