diff --git a/admin/i18n/de/translations.json b/admin/i18n/de/translations.json index 3865913..603d473 100644 --- a/admin/i18n/de/translations.json +++ b/admin/i18n/de/translations.json @@ -19,16 +19,18 @@ "Manufacturer": "Hersteller", "Model ID": "Modell-ID", "Name": "Name", - "Name of the new group:": "Name der neuen Gruppe:", + "Name of the new group": "Name der neuen Gruppe", "OR": "oder mit Anmeldedaten", "Ok": "Ok", "Open Network": "Neue Geräte anlernen", "Settings": "Einstellungen", "Type": "Typ", "deConz Address": "deConz Adresse", - "deConz REST API Version": "deConz REST API Version", + "deConz REST-API Version": "deConz REST-API Version", "deConz Version": "deConz Version", "deConz adapter settings": "deConz Adapter Einstellungen", - "error creating API key: ": "Fehler beim API key erstellen: ", - "link button not pressed": "Bitte zuerst \"Unlock Gateway\" in der Web App Klicken" + "error creating API key": "Fehler beim API key erstellen", + "link button not pressed": "Bitte zuerst \"Unlock Gateway\" in der Web App Klicken", + "Hide switch groups": "Schaltergruppen ausblenden", + "Hide virtual sensors": "Virtuelle Sensoren ausblenden" } \ No newline at end of file diff --git a/admin/i18n/en/translations.json b/admin/i18n/en/translations.json index 4626646..8bf7534 100644 --- a/admin/i18n/en/translations.json +++ b/admin/i18n/en/translations.json @@ -19,16 +19,18 @@ "Manufacturer": "Manufacturer", "Model ID": "Model ID", "Name": "Name", - "Name of the new group:": "Name of the new group:", + "Name of the new group": "Name of the new group", "OR": "or with credentials", "Ok": "Ok", "Open Network": "Open Network", "Settings": "Settings", "Type": "Type", "deConz Address": "deConz Address", - "deConz REST API Version": "deConz REST API Version", + "deConz REST-API Version": "deConz REST-API Version", "deConz Version": "deConz Version", "deConz adapter settings": "deConz adapter settings", - "error creating API key: ": "error creating API key: ", - "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app" + "error creating API key": "error creating API key", + "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app", + "Hide switch groups": "Hide switch groups", + "Hide virtual sensors": "Hide virtual sensors" } diff --git a/admin/i18n/es/translations.json b/admin/i18n/es/translations.json index 476d36b..8b978c2 100644 --- a/admin/i18n/es/translations.json +++ b/admin/i18n/es/translations.json @@ -19,16 +19,18 @@ "Manufacturer": "Fabricante", "Model ID": "ID de modelo", "Name": "Nombre", - "Name of the new group:": "Nombre del nuevo grupo:", + "Name of the new group": "Nombre del nuevo grupo", "OR": "o", "Ok": "Ok", "Open Network": "Red abierta", "Settings": "Settings", "Type": "Tipo", "deConz Address": "deConz Address", - "deConz REST API Version": "Versión de la API REST deConz", + "deConz REST-API Version": "Versión de la API-REST deConz", "deConz Version": "Versión deConz", "deConz adapter settings": "deConz adapter settings", - "error creating API key: ": "error creating API key: ", - "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app" + "error creating API key": "error creating API key", + "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app", + "Hide switch groups": "Ocultar grupos de interruptores", + "Hide virtual sensors": "Ocultar sensores virtuales" } \ No newline at end of file diff --git a/admin/i18n/fr/translations.json b/admin/i18n/fr/translations.json index 8aaa8f3..3470f39 100644 --- a/admin/i18n/fr/translations.json +++ b/admin/i18n/fr/translations.json @@ -19,16 +19,18 @@ "Manufacturer": "Fabricant", "Model ID": "ID du modèle", "Name": "prénom", - "Name of the new group:": "Nom du nouveau groupe:", + "Name of the new group": "Nom du nouveau groupe", "OR": "ou", "Ok": "Ok", "Open Network": "Réseau ouvert", "Settings": "Settings", "Type": "Type", "deConz Address": "deConz Address", - "deConz REST API Version": "Version de l'API REST deConz", + "deConz REST-API Version": "Version de l'API-REST deConz", "deConz Version": "Version deConz", "deConz adapter settings": "deConz adapter settings", - "error creating API key: ": "error creating API key: ", - "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app" + "error creating API key": "error creating API key", + "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app", + "Hide switch groups": "Masquer les groupes de commutateurs", + "Hide virtual sensors": "Masquer les capteurs virtuels" } \ No newline at end of file diff --git a/admin/i18n/it/translations.json b/admin/i18n/it/translations.json index 8319d1d..7d1eb1f 100644 --- a/admin/i18n/it/translations.json +++ b/admin/i18n/it/translations.json @@ -19,16 +19,18 @@ "Manufacturer": "fabbricante", "Model ID": "ID modello", "Name": "Nome", - "Name of the new group:": "Nome del nuovo gruppo:", + "Name of the new group": "Nome del nuovo gruppo", "OR": "o", "Ok": "Ok", "Open Network": "Apri la rete", "Settings": "Settings", "Type": "genere", "deConz Address": "deConz Address", - "deConz REST API Version": "Versione dell'API REST deConz", + "deConz REST-API Version": "Versione dell'REST-API deConz", "deConz Version": "versione deConz", "deConz adapter settings": "deConz adapter settings", - "error creating API key: ": "error creating API key: ", - "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app" + "error creating API key": "error creating API key", + "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app", + "Hide switch groups": "Nascondi gruppi di commutazione", + "Hide virtual sensors": "Nascondi sensori virtuali" } \ No newline at end of file diff --git a/admin/i18n/nl/translations.json b/admin/i18n/nl/translations.json index d7e9b74..def02e3 100644 --- a/admin/i18n/nl/translations.json +++ b/admin/i18n/nl/translations.json @@ -19,16 +19,18 @@ "Manufacturer": "Fabrikant", "Model ID": "Model ID", "Name": "Naam", - "Name of the new group:": "Naam van de nieuwe groep:", + "Name of the new group": "Naam van de nieuwe groep", "OR": "of", "Ok": "Ok", "Open Network": "Open netwerk", "Settings": "Settings", "Type": "Type", "deConz Address": "deConz Address", - "deConz REST API Version": "deConz REST API-versie", + "deConz REST-API Version": "deConz REST-API-versie", "deConz Version": "deConz-versie", "deConz adapter settings": "deConz adapter instellingen", - "error creating API key: ": "fout bij aanmaken API key: ", - "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app" + "error creating API key": "fout bij aanmaken API key", + "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app", + "Hide switch groups": "Schakelgroepen verbergen", + "Hide virtual sensors": "Verberg virtuele sensoren" } \ No newline at end of file diff --git a/admin/i18n/pl/translations.json b/admin/i18n/pl/translations.json index 2824f0b..ec292bc 100644 --- a/admin/i18n/pl/translations.json +++ b/admin/i18n/pl/translations.json @@ -19,16 +19,18 @@ "Manufacturer": "Producent", "Model ID": "ID modelu", "Name": "Nazwa", - "Name of the new group:": "Nazwa nowej grupy:", + "Name of the new group": "Nazwa nowej grupy", "OR": "lub", "Ok": "Ok", "Open Network": "Otwórz sieć", "Settings": "Ustawienia", "Type": "Typ", "deConz Address": "deConz Address", - "deConz REST API Version": "Wersja programu REST API deConz", + "deConz REST-API Version": "Wersja programu REST-API deConz", "deConz Version": "Wersja deConz", "deConz adapter settings": "deConz adapter settings", - "error creating API key: ": "error creating API key: ", - "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app" + "error creating API key": "error creating API key", + "link button not pressed": "Please first click on \"Unlock Gateway\" in the web app", + "Hide switch groups": "Ukryj grupy przełączników", + "Hide virtual sensors": "Ukryj wirtualne czujniki" } \ No newline at end of file diff --git a/admin/i18n/pt/translations.json b/admin/i18n/pt/translations.json index 5beaec1..afa17d6 100644 --- a/admin/i18n/pt/translations.json +++ b/admin/i18n/pt/translations.json @@ -19,16 +19,18 @@ "Manufacturer": "Fabricante", "Model ID": "ID do modelo", "Name": "Nome", - "Name of the new group:": "Nome do novo grupo:", + "Name of the new group": "Nome do novo grupo", "OR": "ou", "Ok": "Ok", "Open Network": "Rede Aberta", "Settings": "Configurações", "Type": "Tipo", "deConz Address": "deConz Address", - "deConz REST API Version": "Versão da API deConz REST", + "deConz REST-API Version": "Versão da REST-API deConz", "deConz Version": "Versão do deConz", "deConz adapter settings": "Configurações do adaptador deConz", - "error creating API key: ": "Erro ao criar chave API: ", - "link button not pressed": "Clique primeiro em \"Unlock Gateway\" no aplicativo da web" + "error creating API key": "Erro ao criar chave API", + "link button not pressed": "Clique primeiro em \"Unlock Gateway\" no aplicativo da web", + "Hide switch groups": "Ocultar grupos de troca", + "Hide virtual sensors": "Ocultar sensores virtuais" } \ No newline at end of file diff --git a/admin/i18n/ru/translations.json b/admin/i18n/ru/translations.json index 2840372..b98a915 100644 --- a/admin/i18n/ru/translations.json +++ b/admin/i18n/ru/translations.json @@ -19,16 +19,18 @@ "Manufacturer": "производитель", "Model ID": "ID модели", "Name": "Имя", - "Name of the new group:": "Название новой группы:", + "Name of the new group": "Название новой группы", "OR": "или же", "Ok": "Ok", "Open Network": "Открытая сеть", "Settings": "Настройки", "Type": "Тип", "deConz Address": "Адрес deConz", - "deConz REST API Version": "Версия API REST deConz", + "deConz REST-API Version": "Версия REST-API deConz", "deConz Version": "Версия deConz", "deConz adapter settings": "Настройки драйвера deConz", - "error creating API key: ": "ошибка создания ключа API: ", - "link button not pressed": "Сначала нажмите «Разблокировать шлюз» в веб-приложении." + "error creating API key": "ошибка создания ключа API", + "link button not pressed": "Сначала нажмите «Разблокировать шлюз» в веб-приложении.", + "Hide switch groups": "Скрыть группы переключателей", + "Hide virtual sensors": "Скрыть виртуальные датчики" } \ No newline at end of file diff --git a/admin/i18n/uk/translations.json b/admin/i18n/uk/translations.json index 5e6cd8f..7c23d52 100644 --- a/admin/i18n/uk/translations.json +++ b/admin/i18n/uk/translations.json @@ -19,16 +19,18 @@ "Manufacturer": "Виробник", "Model ID": "ID моделі", "Name": "Ім'я", - "Name of the new group:": "Назва нової групи:", + "Name of the new group": "Назва нової групи", "OR": "або", "Ok": "В порядку", "Open Network": "Відкрийте мережу", "Settings": "Налаштування", "Type": "Тип", "deConz Address": "deConz Адреса", - "deConz REST API Version": "Версія deConz REST API", + "deConz REST-API Version": "Версія deConz REST-API", "deConz Version": "Версія deConz", "deConz adapter settings": "налаштування адаптера deConz", - "error creating API key: ": "помилка створення ключа API:", - "link button not pressed": "Спочатку натисніть «Розблокувати шлюз» у веб-програмі" + "error creating API key": "помилка створення ключа API", + "link button not pressed": "Спочатку натисніть «Розблокувати шлюз» у веб-програмі", + "Hide switch groups": "Приховати групи перемикачів", + "Hide virtual sensors": "Приховати віртуальні датчики" } \ No newline at end of file diff --git a/admin/i18n/zh-cn/translations.json b/admin/i18n/zh-cn/translations.json index 1759db2..83d7555 100644 --- a/admin/i18n/zh-cn/translations.json +++ b/admin/i18n/zh-cn/translations.json @@ -19,16 +19,18 @@ "Manufacturer": "制造商", "Model ID": "型号编号", "Name": "名称", - "Name of the new group:": "新组名称:", + "Name of the new group": "新组名称", "OR": "要么", "Ok": "确定", "Open Network": "开放网络", "Settings": "设置", "Type": "类型", "deConz Address": "德康兹地址", - "deConz REST API Version": "deConz REST API 版本", + "deConz REST-API Version": "deConz REST-API 版本", "deConz Version": "deConz版本", "deConz adapter settings": "deConz 适配器设置", - "error creating API key: ": "创建 API 密钥时出错:", - "link button not pressed": "请先点击网络应用程序中的“解锁网关”" + "error creating API key": "创建 API 密钥时出错", + "link button not pressed": "请先点击网络应用程序中的“解锁网关”", + "Hide switch groups": "隱藏開關組", + "Hide virtual sensors": "隱藏虛擬感測器" } \ No newline at end of file diff --git a/admin/jsonConfig.json b/admin/jsonConfig.json index 8d8ef53..6ee3dad 100644 --- a/admin/jsonConfig.json +++ b/admin/jsonConfig.json @@ -161,6 +161,32 @@ "md": 4, "sm": 12, "xs": 12 + }, + "_header2": { + "newLine": true, + "text": "Settings", + "type": "header", + "size": 3 + }, + "switchGroups": { + "newLine": true, + "type": "checkbox", + "label": "Hide switch groups", + "xs": 12, + "sm": 12, + "md": 6, + "lg": 4, + "xl": 4 + }, + "virtualSensors": { + "newLine": true, + "type": "checkbox", + "label": "Hide virtual sensors", + "xs": 12, + "sm": 12, + "md": 6, + "lg": 4, + "xl": 4 } } } \ No newline at end of file diff --git a/io-package.json b/io-package.json index 0912758..fa28060 100755 --- a/io-package.json +++ b/io-package.json @@ -126,7 +126,9 @@ "websocketport": 443, "user": "", "username": "", - "password": "" + "password": "", + "switchGroups": false, + "virtualSensors": false }, "instanceObjects": [ { diff --git a/main.js b/main.js index 08d7612..f534eda 100755 --- a/main.js +++ b/main.js @@ -506,7 +506,7 @@ async function main() { heartbeat(); - if (adapter.config.ip === "undefined") { + if (adapter.config.bridge === "") { //only on first start autoDiscovery(); } else { @@ -1000,28 +1000,56 @@ async function getAllGroups() { //Changed check if is helper group, if skip it let regex = new RegExp("helper[0-9]+ for group [0-9]+"); - if (!regex.test(objectName)) { - adapter.setObjectNotExists( - `Groups.${groupID}`, - { - type: "device", - common: { - name: list[keyName]["name"], - role: "group", - }, - native: { - devicemembership: list[keyName]["devicemembership"], - etag: list[keyName]["etag"], - id: list[keyName]["id"], - hidden: list[keyName]["hidden"], - type: "group", - }, - }, - () => { - getGroupAttributes(list[keyName]["id"]); - getGroupScenes(`Groups.${groupID}`, list[keyName]["scenes"]); + if (adapter.config.switchGroups == true) { + if (!list[keyName]["uniqueid"]) { + if (!regex.test(objectName)) { + adapter.setObjectNotExists( + `Groups.${groupID}`, + { + type: "device", + common: { + name: list[keyName]["name"], + role: "group", + }, + native: { + devicemembership: list[keyName]["devicemembership"], + etag: list[keyName]["etag"], + id: list[keyName]["id"], + hidden: list[keyName]["hidden"], + type: "group", + }, + }, + () => { + getGroupAttributes(list[keyName]["id"]); + getGroupScenes(`Groups.${groupID}`, list[keyName]["scenes"]); + } + ); } - ); + } + } else { + if (!regex.test(objectName)) { + adapter.setObjectNotExists( + `Groups.${groupID}`, + { + type: "device", + common: { + name: list[keyName]["name"], + role: "group", + }, + native: { + devicemembership: list[keyName]["devicemembership"], + etag: list[keyName]["etag"], + id: list[keyName]["id"], + hidden: list[keyName]["hidden"], + type: "group", + }, + }, + () => { + getGroupAttributes(list[keyName]["id"]); + getGroupScenes(`Groups.${groupID}`, list[keyName]["scenes"]); + } + ); + } } } } @@ -1065,6 +1093,7 @@ async function getGroupAttributes(groupId) { lights: list["lights"], lightsequence: list["lightsequence"], multideviceids: list["multideviceids"], + uniqueid: list["uniqueid"], }, }); let count2 = Object.keys(list["action"]).length - 1; @@ -1078,13 +1107,15 @@ async function getGroupAttributes(groupId) { stateName, list["action"][stateName] ); - await SetObjectAndState( - groupId, - list["name"], - "Groups", - "transitiontime", - null - ); + if (!list["uniqueid"]) { + await SetObjectAndState( + groupId, + list["name"], + "Groups", + "transitiontime", + null + ); + } } let count3 = Object.keys(list["state"]).length - 1; //create states for light device @@ -1097,64 +1128,68 @@ async function getGroupAttributes(groupId) { stateName, list["state"][stateName] ); + if (!list["uniqueid"]) { + await SetObjectAndState( + groupId, + list["name"], + "Groups", + "transitiontime", + null + ); + } + } + if (!list["uniqueid"]) { await SetObjectAndState( groupId, list["name"], "Groups", - "transitiontime", + "level", null ); + adapter.setObjectNotExists(`Groups.${groupId}.dimspeed`, { + type: "state", + common: { + name: list["name"] + " " + "dimspeed", + type: "number", + role: "level.dimspeed", + min: 0, + max: 255, + read: false, + write: true, + }, + native: {}, + }); + adapter.setObjectNotExists(`Groups.${groupId}.dimup`, { + type: "state", + common: { + name: list["name"] + " " + "dimup", + role: "button", + type: "boolean", + read: false, + write: true, + }, + }); + adapter.setObjectNotExists(`Groups.${groupId}.dimdown`, { + type: "state", + common: { + name: list["name"] + " " + "dimdown", + role: "button", + type: "boolean", + read: false, + write: true, + }, + }); + adapter.setObjectNotExists(`Groups.${groupId}.action`, { + type: "state", + common: { + name: list["name"] + " " + "action", + role: "argument", + type: "string", + read: false, + write: true, + }, + }); } - await SetObjectAndState( - groupId, - list["name"], - "Groups", - "level", - null - ); - adapter.setObjectNotExists(`Groups.${groupId}.dimspeed`, { - type: "state", - common: { - name: list["name"] + " " + "dimspeed", - type: "number", - role: "level.dimspeed", - min: 0, - max: 255, - read: false, - write: true, - }, - native: {}, - }); - adapter.setObjectNotExists(`Groups.${groupId}.dimup`, { - type: "state", - common: { - name: list["name"] + " " + "dimup", - role: "button", - type: "boolean", - read: false, - write: true, - }, - }); - adapter.setObjectNotExists(`Groups.${groupId}.dimdown`, { - type: "state", - common: { - name: list["name"] + " " + "dimdown", - role: "button", - type: "boolean", - read: false, - write: true, - }, - }); - adapter.setObjectNotExists(`Groups.${groupId}.action`, { - type: "state", - common: { - name: list["name"] + " " + "action", - role: "argument", - type: "string", - read: false, - write: true, - }, - }); } getGroupScenes(`Groups.${groupID}`, list["scenes"]); } @@ -1455,55 +1490,110 @@ async function getAllSensors() { //Get each Sensor let keyName = Object.keys(list)[i]; let sensorID = keyName; + let typS = list[keyName]["type"]; //create object for sensor device let regex = new RegExp("CLIP-Sensor TOOGLE-"); - if (!regex.test(list[keyName]["name"])) { - adapter.setObjectNotExists(`Sensors.${sensorID}`, { - type: "device", - common: { - name: list[keyName]["name"], - role: "sensor", - }, - native: { - ep: list[keyName]["ep"], - etag: list[keyName]["etag"], - id: keyName, - group: - list[keyName]["config"] !== undefined - ? list[keyName]["config"]["group"] - : "", - manufacturername: list[keyName]["manufacturername"], - modelid: list[keyName]["modelid"], - swversion: list[keyName]["swversion"], - type: list[keyName]["type"], - uniqueid: list[keyName]["uniqueid"], - }, - }); - let count2 = Object.keys(list[keyName]["state"]).length - 1; - - //create states for sensor device - for (let z = 0; z <= count2; z++) { - let stateName = Object.keys(list[keyName]["state"])[z]; - await SetObjectAndState( - sensorID, - list[keyName]["name"], - "Sensors", - stateName, - list[keyName]["state"][stateName] - ); + if (adapter.config.virtualSensors == true) { + if (typS.substring(0, 4) !== "CLIP") { + if (!regex.test(list[keyName]["name"])) { + adapter.setObjectNotExists(`Sensors.${sensorID}`, { + type: "device", + common: { + name: list[keyName]["name"], + role: "sensor", + }, + native: { + ep: list[keyName]["ep"], + etag: list[keyName]["etag"], + id: keyName, + group: + list[keyName]["config"] !== undefined + ? list[keyName]["config"]["group"] + : "", + manufacturername: list[keyName]["manufacturername"], + modelid: list[keyName]["modelid"], + swversion: list[keyName]["swversion"], + type: list[keyName]["type"], + uniqueid: list[keyName]["uniqueid"], + }, + }); + let count2 = Object.keys(list[keyName]["state"]).length - 1; + + //create states for sensor device + for (let z = 0; z <= count2; z++) { + let stateName = Object.keys(list[keyName]["state"])[z]; + await SetObjectAndState( + sensorID, + list[keyName]["name"], + "Sensors", + stateName, + list[keyName]["state"][stateName] + ); + } + let count3 = Object.keys(list[keyName]["config"]).length - 1; + + //create config states for sensor device + for (let x = 0; x <= count3; x++) { + let stateName = Object.keys(list[keyName]["config"])[x]; + await SetObjectAndState( + sensorID, + list[keyName]["name"], + "Sensors", + stateName, + list[keyName]["config"][stateName] + ); + } + } } - let count3 = Object.keys(list[keyName]["config"]).length - 1; - - //create config states for sensor device - for (let x = 0; x <= count3; x++) { - let stateName = Object.keys(list[keyName]["config"])[x]; - await SetObjectAndState( - sensorID, - list[keyName]["name"], - "Sensors", - stateName, - list[keyName]["config"][stateName] - ); + } else { + if (!regex.test(list[keyName]["name"])) { + adapter.setObjectNotExists(`Sensors.${sensorID}`, { + type: "device", + common: { + name: list[keyName]["name"], + role: "sensor", + }, + native: { + ep: list[keyName]["ep"], + etag: list[keyName]["etag"], + id: keyName, + group: + list[keyName]["config"] !== undefined + ? list[keyName]["config"]["group"] + : "", + manufacturername: list[keyName]["manufacturername"], + modelid: list[keyName]["modelid"], + swversion: list[keyName]["swversion"], + type: list[keyName]["type"], + uniqueid: list[keyName]["uniqueid"], + }, + }); + let count2 = Object.keys(list[keyName]["state"]).length - 1; + + //create states for sensor device + for (let z = 0; z <= count2; z++) { + let stateName = Object.keys(list[keyName]["state"])[z]; + await SetObjectAndState( + sensorID, + list[keyName]["name"], + "Sensors", + stateName, + list[keyName]["state"][stateName] + ); + } + let count3 = Object.keys(list[keyName]["config"]).length - 1; + + //create config states for sensor device + for (let x = 0; x <= count3; x++) { + let stateName = Object.keys(list[keyName]["config"])[x]; + await SetObjectAndState( + sensorID, + list[keyName]["name"], + "Sensors", + stateName, + list[keyName]["config"][stateName] + ); + } } } } @@ -1527,32 +1617,59 @@ async function getSensor(sensorId) { } else { if (await logging(res, body, "get sensor " + sensorId)) { let list = JSON.parse(body); + let typS = list["type"]; - //create object for sensor - adapter.setObjectNotExists(`Sensors.${sensorId}`, { - type: "device", - common: { - name: list["name"], - role: "sensor", - }, - native: { - ep: list["ep"], - etag: list["etag"], - id: sensorId, - group: list["config"]["group"], - manufacturername: list["manufacturername"], - mode: list["mode"], - modelid: list["modelid"], - swversion: list["swversion"], - type: list["type"], - uniqueid: list["uniqueid"], - }, - }); + if (adapter.config.virtualSensors == true) { + if (typS.substring(0, 4) !== "CLIP") { + //create object for sensor + adapter.setObjectNotExists(`Sensors.${sensorId}`, { + type: "device", + common: { + name: list["name"], + role: "sensor", + }, + native: { + ep: list["ep"], + etag: list["etag"], + id: sensorId, + group: list["config"]["group"], + manufacturername: list["manufacturername"], + mode: list["mode"], + modelid: list["modelid"], + swversion: list["swversion"], + type: list["type"], + uniqueid: list["uniqueid"], + }, + }); + } + } else { + //create object for sensor + adapter.setObjectNotExists(`Sensors.${sensorId}`, { + type: "device", + common: { + name: list["name"], + role: "sensor", + }, + native: { + ep: list["ep"], + etag: list["etag"], + id: sensorId, + group: list["config"]["group"], + manufacturername: list["manufacturername"], + mode: list["mode"], + modelid: list["modelid"], + swversion: list["swversion"], + type: list["type"], + uniqueid: list["uniqueid"], + }, + }); + } let count2 = Object.keys(list["state"]).length - 1; //create states for sensor device for (let z = 0; z <= count2; z++) { let stateName = Object.keys(list["state"])[z]; + let typS = list["type"]; if (stateName === "buttonevent" && (list["modelid"] === "lumi.sensor_switch" || list["modelid"] === "lumi.sensor_switch.aq2")) { let LastUpdate = Number(new Date(list["state"]["lastupdated"])); @@ -1572,26 +1689,50 @@ async function getSensor(sensorId) { adapter.log.info("buttonevent NOT updated for " + list["name"] + ", too old: " + (Now - LastUpdate + TimeOffset) / 1000 + "sec time difference update to now"); } } else { - await SetObjectAndState( - sensorId, - list["name"], - "Sensors", - stateName, - list["state"][stateName] - ); + if (adapter.config.virtualSensors == true) { + if (typS.substring(0, 4) !== "CLIP") { + await SetObjectAndState( + sensorId, + list["name"], + "Sensors", + stateName, + list["state"][stateName] + ); + } + } else { + await SetObjectAndState( + sensorId, + list["name"], + "Sensors", + stateName, + list["state"][stateName] + ); + } } let count3 = Object.keys(list["config"]).length - 1; //create config for sensor device for (let x = 0; x <= count3; x++) { let stateName = Object.keys(list["config"])[x]; - await SetObjectAndState( - sensorId, - list["name"], - "Sensors", - stateName, - list["config"][stateName] - ); + if (adapter.config.virtualSensors == true) { + if (typS.substring(0, 4) !== "CLIP") { + await SetObjectAndState( + sensorId, + list["name"], + "Sensors", + stateName, + list["config"][stateName] + ); + } + } else { + await SetObjectAndState( + sensorId, + list["name"], + "Sensors", + stateName, + list["config"][stateName] + ); + } } } } @@ -3175,7 +3316,7 @@ async function SetObjectAndState(id, name, type, stateName, value) { if (objMin !== null) { objCommon.min = objMin; } - if (objMin !== null) { + if (objMax !== null) { objCommon.max = objMax; } if (objDefault !== null) {