From ae7582baa643343f642d08b0235e45b5f286de79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rene=20Gla=C3=9F?= Date: Mon, 8 Jul 2019 20:42:53 +0200 Subject: [PATCH] V0.0.5 support of max!cube thermostats see issue #5 --- README.md | 7 ++- io-package.json | 14 ++++- main.js | 136 ++++++++++++++++++++++++++---------------------- package.json | 2 +- 4 files changed, 94 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 8a2be6f..b169fc6 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Adapter for controlling thermostats. Features: * Control the setpoint temperature levels of all thermostats per schedules * Configure multiple heating periods for each day and night -* Supports various homematic thermostats +* Supports various homematic and max!cube thermostats * supports multiple profiles (to do) * If there is no direct connection between the thermostat and the actuator, the actuator can be switched directly out of the adapter * Currently, the actuator is switched off directly when the setpoint temperature is reached. As soon as the setpoint temperature is below the actual temperature, the actuator will be switched on. (To do: implement improved control) @@ -50,7 +50,10 @@ Features: ## Changelog -### 0.0.4 (2019-mm-dd) +### 0.0.5 (2019-07-08) +* (René) support for max!cube thermostats + +### 0.0.4 (2019-06-23) * (René) debugging ### 0.0.3 (2019-06-02) diff --git a/io-package.json b/io-package.json index ef72fdc..0dc6e6c 100644 --- a/io-package.json +++ b/io-package.json @@ -1,8 +1,20 @@ { "common": { "name": "heatingcontrol", - "version": "0.0.4", + "version": "0.0.5", "news": { + "0.0.5": { + "en": "support for max!cube thermostats", + "de": "Unterstützung für max! cube-Thermostate", + "ru": "поддержка термостатов max! cube", + "pt": "suporte para termostatos max! cube", + "nl": "ondersteuning voor max! cube-thermostaten", + "fr": "support pour les thermostats max! cube", + "it": "supporto per i termostati max! cube", + "es": "soporte para termostatos max! cube", + "pl": "obsługa termostatów max! cube", + "zh-cn": "支持max!cube恒温器" + }, "0.0.3": { "en": "ready for first publish", "pt": "pronto para primeiro publicar", diff --git a/main.js b/main.js index d6d8734..31ebc29 100644 --- a/main.js +++ b/main.js @@ -38,7 +38,8 @@ const bDebug = false; // Die ThermostatTypeTab definiert die Thermostat Typen. const ThermostatTypeTab = []; -ThermostatTypeTab[0] = ['HM-TC-IT-WM-W-EU', 'Wandthermostat (neu)', '.2.SET_TEMPERATURE', '.1.TEMPERATURE', '2.CONTROL_MODE' ]; +//Homematic +ThermostatTypeTab[0] = ['HM-TC-IT-WM-W-EU', 'Wandthermostat (neu)', '.2.SET_TEMPERATURE', '.1.TEMPERATURE', '2.CONTROL_MODE']; ThermostatTypeTab[1] = ['HM-CC-TC', 'Wandthermostat (alt)', '.2.SETPOINT', '.1.TEMPERATURE', false ]; ThermostatTypeTab[2] = ['HM-CC-RT-DN', 'Heizkoerperthermostat(neu)', '.4.SET_TEMPERATURE', '.4.ACTUAL_TEMPERATURE', '4.CONTROL_MODE' ]; ThermostatTypeTab[3] = ['HMIP-eTRV', 'Heizkoerperthermostat(HMIP)', '.1.SET_POINT_TEMPERATURE', '.1.ACTUAL_TEMPERATURE', '1.CONTROL_MODE' ]; @@ -48,12 +49,24 @@ ThermostatTypeTab[6] = ['HMIP-STH', 'Wandthermostat(HMIP)', ThermostatTypeTab[7] = ['HMIP-STHD', 'Wandthermostat(HMIP)', '.1.SET_POINT_TEMPERATURE', '.1.ACTUAL_TEMPERATURE', '1.CONTROL_MODE' ]; ThermostatTypeTab[8] = ['HMIP-eTRV-2', 'Heizkoerperthermostat(HMIP)', '.1.SET_POINT_TEMPERATURE', '.1.ACTUAL_TEMPERATURE', '1.CONTROL_MODE' ]; ThermostatTypeTab[9] = ['HMIP-eTRV-B', 'Heizkoerperthermostat(HMIP)', '.1.SET_POINT_TEMPERATURE', '.1.ACTUAL_TEMPERATURE', '1.SET_POINT_MODE' ]; +const MaxHomematicThermostatType = 9; +//MaxCube +const MinMaxcubeThermostatType = 10; +ThermostatTypeTab[10] = ['max!', 'Thermostat', '.setpoint', '.temp', '.mode']; +/* +MAX! Heizkörperthermostat basic +MAX! Heizkörperthermostat +MAX! Heizkörperthermostat + +MAX! Wandthermostat + +*/ +const MaxMaxcubeThermostatType = 10; + const ActorTypeTab = []; ActorTypeTab[0] = ['HM-LC-Sw4-PCB', 'Funk-Schaltaktor 4-fach, Platine', '.STATE' ]; ActorTypeTab[1] = ['HM-LC-Sw4-DR', 'Funk-Schaltaktor 4-fach, Hutschienenmontage', '.STATE' ]; ActorTypeTab[2] = ['HM-LC-Sw4-SM', 'Funk-Schaltaktor 4-fach, Aufputzmontage', '.STATE' ]; - +const MaxHomematicActorType = 2; var HeizungGewerk = "Heizung"; @@ -256,54 +269,9 @@ async function ListDevices(obj) { adapter.log.debug("checking room " + rooms[e].common.name); } -/* - * - * todo: - * - * 2019-06-30 20:02:27.330 - warn: heatingcontrol.0 not supported type {"type":"state","common":{"type":"number","unit":"°C","min":10,"max":35,"read":true,"write":true,"role":"level.temperature","name":"Cooling Threshold Temperature"},"native":{"UUID":"0000000D-0000-1000-8000-0026BB765291","displayName":"Cooling Threshold Temperature"},"from":"system.adapter.ham.0","user":"system.user.admin","ts":1561823566903,"_id":"ham.0.Büro.Büro-Thermo.Cooling-Threshold-Temperature","acl":{"object":1636,"state":1636,"owner":"system.user.admin","ownerGroup":"system.group.administrator"}} - - * -heatingcontrol.0 2019-07-03 19:44:05.475 debug checking room [object Object] -heatingcontrol.0 2019-07-03 19:44:05.475 warn not supported type {"type":"state","common":{"type":"number","unit":"°C","min":5,"max":25,"read":true,"write":true,"role":"level.temperature","name":"Target Temperature"},"native":{"UUID":"00000035-00 -heatingcontrol.0 2019-07-03 19:44:05.474 debug found as Heating Gewerk 4 ham.0.Bad.Bad-Thermo.Target-Temperature -heatingcontrol.0 2019-07-03 19:44:05.474 debug member{"type":"state","common":{"type":"number","unit":"°C","min":5,"max":25,"read":true,"write":true,"role":"level.temperature","name":"Target Temperature"},"native":{"UUID":"00000035-0000-1000-8000- -heatingcontrol.0 2019-07-03 19:44:05.465 warn not supported type {"type":"state","common":{"type":"number","min":0,"max":3,"read":true,"write":true,"role":"level","name":"Target Heating Cooling State","unit":""},"native":{"UUID":"00000033-0000-10 -heatingcontrol.0 2019-07-03 19:44:05.465 debug found as Heating Gewerk 3 ham.0.Bad.Bad-Thermo.Target-Heating-Cooling-State -heatingcontrol.0 2019-07-03 19:44:05.464 debug member{"type":"state","common":{"type":"number","min":0,"max":3,"read":true,"write":true,"role":"level","name":"Target Heating Cooling State","unit":""},"native":{"UUID":"00000033-0000-1000-8000-0026B -heatingcontrol.0 2019-07-03 19:44:05.464 warn not supported type {"type":"state","common":{"type":"number","unit":"°C","min":-100,"max":100,"read":true,"write":false,"role":"value.temperature","name":"Current Temperature"},"native":{"UUID":"00000 -heatingcontrol.0 2019-07-03 19:44:05.464 debug found as Heating Gewerk 2 ham.0.Bad.Bad-Thermo.Current-Temperature -heatingcontrol.0 2019-07-03 19:44:05.463 debug member{"type":"state","common":{"type":"number","unit":"°C","min":-100,"max":100,"read":true,"write":false,"role":"value.temperature","name":"Current Temperature"},"native":{"UUID":"00000011-0000-1000 -heatingcontrol.0 2019-07-03 19:44:05.452 warn not supported type {"type":"state","common":{"type":"number","unit":"°C","min":10,"max":35,"read":true,"write":true,"role":"level.temperature","name":"Cooling Threshold Temperature"},"native":{"UUID": -heatingcontrol.0 2019-07-03 19:44:05.452 debug found as Heating Gewerk 1 ham.0.Bad.Bad-Thermo.Cooling-Threshold-Temperature -heatingcontrol.0 2019-07-03 19:44:05.451 debug member{"type":"state","common":{"type":"number","unit":"°C","min":10,"max":35,"read":true,"write":true,"role":"level.temperature","name":"Cooling Threshold Temperature"},"native":{"UUID":"0000000D-000 -heatingcontrol.0 2019-07-03 19:44:05.445 warn not supported type {"type":"state","common":{"type":"number","min":0,"max":3,"read":true,"write":false,"role":"value","name":"Current Heating Cooling State","unit":""},"native":{"UUID":"0000000F-0000- -heatingcontrol.0 2019-07-03 19:44:05.445 debug found as Heating Gewerk 0 ham.0.Bad.Bad-Thermo.Current-Heating-Cooling-State -heatingcontrol.0 2019-07-03 19:44:05.444 debug member{"type":"state","common":{"type":"number","min":0,"max":3,"read":true,"write":false,"role":"value","name":"Current Heating Cooling State","unit":""},"native":{"UUID":"0000000F-0000-1000-8000-002 -heatingcontrol.0 2019-07-03 19:44:05.438 debug member{"_id":"mihome.0.devices.sensor_ht_158d00023d23bb.temperature","common":{"name":"Temperature","role":"value.temperature","write":false,"read":true,"type":"number","unit":"°C","smartName":{"smart -heatingcontrol.0 2019-07-03 19:44:05.434 debug member{"_id":"mihome.0.devices.sensor_ht_158d00023d23bb.humidity","common":{"name":"Humidity","role":"value.humidity","write":false,"read":true,"type":"number","unit":"%","min":0,"max":100},"type":"st -heatingcontrol.0 2019-07-03 19:44:05.417 debug checking room Bad -heatingcontrol.0 2019-07-03 19:44:05.417 warn not supported type {"type":"state","common":{"type":"number","unit":"°C","min":5,"max":25,"read":true,"write":true,"role":"level.temperature","name":"Target Temperature"},"native":{"UUID":"00000035-00 -heatingcontrol.0 2019-07-03 19:44:05.416 debug found as Heating Gewerk 5 ham.0.Büro.Büro-Thermo.Target-Temperature -heatingcontrol.0 2019-07-03 19:44:05.415 debug member{"type":"state","common":{"type":"number","unit":"°C","min":5,"max":25,"read":true,"write":true,"role":"level.temperature","name":"Target Temperature"},"native":{"UUID":"00000035-0000-1000-8000- -heatingcontrol.0 2019-07-03 19:44:05.410 warn not supported type {"type":"state","common":{"type":"number","min":0,"max":3,"read":true,"write":true,"role":"level","name":"Target Heating Cooling State","unit":""},"native":{"UUID":"00000033-0000-10 -heatingcontrol.0 2019-07-03 19:44:05.410 debug found as Heating Gewerk 6 ham.0.Büro.Büro-Thermo.Target-Heating-Cooling-State -heatingcontrol.0 2019-07-03 19:44:05.410 debug member{"type":"state","common":{"type":"number","min":0,"max":3,"read":true,"write":true,"role":"level","name":"Target Heating Cooling State","unit":""},"native":{"UUID":"00000033-0000-1000-8000-0026B -heatingcontrol.0 2019-07-03 19:44:05.405 warn not supported type {"type":"state","common":{"type":"number","unit":"°C","min":-100,"max":100,"read":true,"write":false,"role":"value.temperature","name":"Current Temperature"},"native":{"UUID":"00000 -heatingcontrol.0 2019-07-03 19:44:05.405 debug found as Heating Gewerk 9 ham.0.Büro.Büro-Thermo.Current-Temperature -heatingcontrol.0 2019-07-03 19:44:05.404 debug member{"type":"state","common":{"type":"number","unit":"°C","min":-100,"max":100,"read":true,"write":false,"role":"value.temperature","name":"Current Temperature"},"native":{"UUID":"00000011-0000-1000 -heatingcontrol.0 2019-07-03 19:44:05.396 warn not supported type {"type":"state","common":{"type":"number","min":0,"max":3,"read":true,"write":false,"role":"value","name":"Current Heating Cooling State","unit":""},"native":{"UUID":"0000000F-0000- -heatingcontrol.0 2019-07-03 19:44:05.396 debug found as Heating Gewerk 8 ham.0.Büro.Büro-Thermo.Current-Heating-Cooling-State -heatingcontrol.0 2019-07-03 19:44:05.395 debug member{"type":"state","common":{"type":"number","min":0,"max":3,"read":true,"write":false,"role":"value","name":"Current Heating Cooling State","unit":""},"native":{"UUID":"0000000F-0000-1000-8000-002 -heatingcontrol.0 2019-07-03 19:44:05.389 warn not supported type {"type":"state","common":{"type":"number","unit":"°C","min":10,"max":35,"read":true,"write":true,"role":"level.temperature","name":"Cooling Threshold Temperature"},"native":{"UUID": -*/ - - var ids = rooms[e].common.members; for (var n in ids) { - - - var adapterObj; if (bDebug) { adapterObj = { "_id": "hm-rpc.2.000393C99BC873.1", "type": "channel", "common": { "name": "HMIP-eTRV 000393C99BC873:1" }, "native": { "TYPE": "HEATING_CLIMATECONTROL_TRANSCEIVER", "SUBTYPE": "", "ADDRESS": "000393C99BC873:1", "RF_ADDRESS": 0, "CHILDREN": [], "PARENT": "000393C99BC873", "PARENT_TYPE": "HMIP-eTRV", "INDEX": 1, "AES_ACTIVE": 1, "PARAMSETS": ["MASTER", "VALUES", "LINK", "SERVICE"], "FIRMWARE": "", "AVAILABLE_FIRMWARE": "", "UPDATABLE": true, "FIRMWARE_UPDATE_STATE": "", "VERSION": 3, "FLAGS": 1, "LINK_SOURCE_ROLES": "CLIMATE_CONTROL", "LINK_TARGET_ROLES": "", "DIRECTION": 1, "GROUP": "", "TEAM": "", "TEAM_TAG": "", "TEAM_CHANNELS": [], "INTERFACE": "", "ROAMING": 0, "RX_MODE": 0 }, "from": "system.adapter.hm-rega.0", "user": "system.user.admin", "ts": 1560770787248, "acl": { "object": 1636, "owner": "system.user.admin", "ownerGroup": "system.group.administrator" } }; @@ -326,24 +294,52 @@ heatingcontrol.0 2019-07-03 19:44:05.389 warn not supported type {"type":"state" } //check if member is a supported RT var supportedRT = -1; - for (var x1 = 0; x1 < ThermostatTypeTab.length; x1++) { - if (bDebug) { - adapter.log.debug("check " + adapterObj.native.PARENT_TYPE + " === " + ThermostatTypeTab[x1][0]); + + if (adapter.config.PathThermostats.includes("hm-rpc")) { // Homematic + adapter.log.debug("check thermostat for homematic"); + for (var x1 = 0; x1 <= MaxHomematicThermostatType; x1++) { + if (bDebug) { + adapter.log.debug("check " + adapterObj.native.PARENT_TYPE + " === " + ThermostatTypeTab[x1][0]); + } + if (adapterObj.native.PARENT_TYPE === ThermostatTypeTab[x1][0]) { + supportedRT = x1; + } } - if (adapterObj.native.PARENT_TYPE === ThermostatTypeTab[x1][0]) { - supportedRT = x1; + } + else if (adapter.config.PathThermostats.includes("maxcube")) { + adapter.log.debug("check thermostat for maxcube"); + + /* + * not supported type {"_id":"maxcube.0.devices.thermostat_06aebc", + * "common":{"name":"ThermostatSchlafzimmer","role":"thermostat"}, + * "type":"channel", + * "native":{"rf_address":"06aebc","device_type":1}, + * "vals":{"setpoint":20,"mode":"MANUAL"},"from":"system.adapter.maxcube.0","user":"system.user.admin","ts":1562513637920,"acl":{"object":1636,"owner":"system.user.admin","ownerGroup":"system.group.administrator"}} + + */ + + if (adapterObj.common.role === "thermostat") { + supportedRT = MinMaxcubeThermostatType; + adapter.log.debug("maxcube thermostat found... " + supportedRT); } } var supportedActor = -1; - for (var x2 = 0; x2 < ActorTypeTab.length; x2++) { - if (bDebug) { - adapter.log.debug("check " + adapterObj.native.PARENT_TYPE + " === " + ActorTypeTab[x2][0]); - } - if (adapterObj.native.PARENT_TYPE === ActorTypeTab[x2][0]) { - supportedActor = x2; + if (adapter.config.PathActors.includes("hm-rpc")) { // Homematic + adapter.log.debug("check actor for homematic"); + for (var x2 = 0; x2 <= MaxHomematicActorType; x2++) { + if (bDebug) { + adapter.log.debug("check " + adapterObj.native.PARENT_TYPE + " === " + ActorTypeTab[x2][0]); + } + if (adapterObj.native.PARENT_TYPE === ActorTypeTab[x2][0]) { + supportedActor = x2; + } } } + else if (adapter.config.PathThermostats.includes("maxcube")) { + adapter.log.debug("check actor for maxcube"); + } + var address = ""; if (supportedActor > -1) { @@ -353,7 +349,17 @@ heatingcontrol.0 2019-07-03 19:44:05.389 warn not supported type {"type":"state" if (supportedRT > -1) { - address = adapterObj.native.PARENT; + + if (supportedRT >= 0 && supportedRT <= MaxHomematicThermostatType) { + address = adapterObj.native.PARENT; + } + else if (supportedRT >= MinMaxcubeThermostatType && supportedRT <= MaxMaxcubeThermostatType) { + // adapter.log.debug("###" + JSON.stringify( adapterObj)); + //"_id":"maxcube.0.devices.thermostat_06aebc" + var temp = adapterObj._id; + var _id = temp.split('.'); // + address = _id[3]; + } adapter.log.debug("supported thermostat found " + address + " " + JSON.stringify(adapterObj)); } @@ -1266,8 +1272,16 @@ async function CheckTemperatureChange(CheckOurOnly=false) { let nextSetTemperature = nextTemperature.val - AbsentDecrease + GuestIncrease - PartyDecrease - VacationAbsentDecrease; //adapter.log.debug("*3 " + adapter.config.PathThermostats + " " + adapter.config.devices[rooms].thermostat + " " + ThermostatTypeTab[adapter.config.devices[rooms].thermostatTypeID][2]); - const state = adapter.config.PathThermostats + adapter.config.devices[rooms].thermostat + ThermostatTypeTab[adapter.config.devices[rooms].thermostatTypeID][2]; - //adapter.log.debug("*4 " + state); + var state = 20; + if (adapter.config.devices[rooms].thermostatTypeID >= 0 && adapter.config.devices[rooms].thermostatTypeID <= MaxHomematicThermostatType) { + //Homematic + state = adapter.config.PathThermostats + adapter.config.devices[rooms].thermostat + ThermostatTypeTab[adapter.config.devices[rooms].thermostatTypeID][2]; + } + if (adapter.config.devices[rooms].thermostatTypeID >= MinMaxcubeThermostatType && adapter.config.devices[rooms].thermostatTypeID <= MaxMaxcubeThermostatType) { + //max!Cube + state = adapter.config.PathThermostats + "devices." + adapter.config.devices[rooms].thermostat + ThermostatTypeTab[adapter.config.devices[rooms].thermostatTypeID][2]; + } + //adapter.log.debug("*4 " + state); await adapter.setForeignStateAsync(state, nextSetTemperature ); adapter.log.debug('room ' + adapter.config.devices[rooms].room + " Thermostate " + state + " set to " + nextSetTemperature); diff --git a/package.json b/package.json index 1faa95f..cfb3dd4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iobroker.heatingcontrol", - "version": "0.0.4", + "version": "0.0.5", "description": "HeatingControl Adapter", "author": { "name": "Ren G.",