From ed5d482d57b971c5793147d64ec1236eb9ed97a4 Mon Sep 17 00:00:00 2001 From: Illia Antypenko Date: Fri, 27 Sep 2024 22:14:38 +0200 Subject: [PATCH] =?UTF-8?q?Add=20support=20of=20"8=C2=B0C=20heating"=20mod?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 2 +- .homeychangelog.json | 3 + .homeycompose/app.json | 2 +- .../capabilities/safety_heating.json | 16 ++ app.js | 14 +- app.json | 153 ++++++++++++++++-- drivers/gree_cooper_hunter_hvac/device.js | 24 +++ .../driver.compose.json | 3 +- .../driver.flow.compose.json | 120 ++++++++++++-- 9 files changed, 299 insertions(+), 38 deletions(-) create mode 100644 .homeycompose/capabilities/safety_heating.json diff --git a/.editorconfig b/.editorconfig index 55ebf56..04fc4bb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,5 +9,5 @@ indent_size = 4 trim_trailing_whitespace = true max_line_length = 100 -[{app.json,.homeychangelog.json}] +[*.json] indent_size = 2 diff --git a/.homeychangelog.json b/.homeychangelog.json index c5db8b0..229a8e1 100644 --- a/.homeychangelog.json +++ b/.homeychangelog.json @@ -65,5 +65,8 @@ }, "0.9.3": { "en": "Minor connection improvements.\r\nDisable error collecting" + }, + "0.9.4": { + "en": "Add support of \"8°C heating\" mode" } } diff --git a/.homeycompose/app.json b/.homeycompose/app.json index a5591ee..5e98f2d 100644 --- a/.homeycompose/app.json +++ b/.homeycompose/app.json @@ -1,6 +1,6 @@ { "id": "com.gree", - "version": "0.9.3", + "version": "0.9.4", "compatibility": ">=12.0.1", "sdk": 3, "brandColor": "#ff732e", diff --git a/.homeycompose/capabilities/safety_heating.json b/.homeycompose/capabilities/safety_heating.json new file mode 100644 index 0000000..787f743 --- /dev/null +++ b/.homeycompose/capabilities/safety_heating.json @@ -0,0 +1,16 @@ +{ + "type": "boolean", + "title": { + "en": "8°C heating", + "nl": "8°C verwarming", + "de": "8°C Heizung" + }, + "desc": { + "en": "The air conditioner keeps the room temperature at 8°C to prevent freezing", + "nl": "De airconditioner houdt de kamertemperatuur op 8°C om bevriezing te voorkomen.", + "de": "Die Klimaanlage hält die Raumtemperatur auf 8°C, um ein Einfrieren zu verhindern." + }, + "getable": true, + "setable": true, + "uiComponent": "toggle" +} diff --git a/app.js b/app.js index 595852a..d2d34d8 100644 --- a/app.js +++ b/app.js @@ -38,6 +38,13 @@ class GreeHVAC extends Homey.App { return onoffToBoolean(args.mode) === turboMode; }); + this.homey.flow.getConditionCard('safety_heating_is') + .registerRunListener((args, state) => { + const safetyHeating = args.device.getCapabilityValue('safety_heating'); + args.device.log('[condition]', '[current safety heating]', safetyHeating); + return onoffToBoolean(args.mode) === safetyHeating; + }); + this.homey.flow.getConditionCard('lights_is') .registerRunListener((args, state) => { const lightsMode = args.device.getCapabilityValue('lights'); @@ -94,6 +101,12 @@ class GreeHVAC extends Homey.App { return args.device.triggerCapabilityListener('turbo_mode', onoffToBoolean(args.mode), {}); }); }); + this.homey.flow.getActionCard('set_safety_heating') + .registerRunListener((args, state) => { + return args.device.setCapabilityValue('safety_heating', onoffToBoolean(args.mode)).then(() => { + return args.device.triggerCapabilityListener('safety_heating', onoffToBoolean(args.mode), {}); + }); + }); this.homey.flow.getActionCard('set_lights') .registerRunListener((args, state) => { @@ -130,7 +143,6 @@ class GreeHVAC extends Homey.App { }); }); } - } function onoffToBoolean(value) { diff --git a/app.json b/app.json index 6bb7fc1..e28584f 100644 --- a/app.json +++ b/app.json @@ -1,7 +1,7 @@ { "_comment": "This file is generated. Please edit .homeycompose/app.json instead.", "id": "com.gree", - "version": "0.9.3", + "version": "0.9.4", "compatibility": ">=12.0.1", "sdk": 3, "brandColor": "#ff732e", @@ -151,6 +151,33 @@ } ] }, + { + "id": "safety_heating_changed", + "title": { + "en": "8°C heating changed", + "nl": "8°C verwarming veranderd", + "de": "8°C Heizung geändert" + }, + "args": [ + { + "type": "device", + "name": "device", + "filter": "driver_id=gree_cooper_hunter_hvac" + } + ], + "tokens": [ + { + "name": "safety_heating", + "type": "boolean", + "title": { + "en": "8°C heating", + "nl": "8°C verwarming", + "de": "8°C Heizung" + }, + "example": "true" + } + ] + }, { "id": "lights_changed", "title": { @@ -282,10 +309,10 @@ "id": "hvac_mode_is", "deprecated": true, "title": { - "en": "Current HVAC mode !{{is|isn't}} ..." + "en": "HVAC mode !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current HVAC mode !{{is|isn't}} [[mode]]" + "en": "HVAC mode !{{is|isn't}} [[mode]]" }, "args": [ { @@ -352,10 +379,10 @@ { "id": "fan_speed_is", "title": { - "en": "Current fan speed !{{is|isn't}} ..." + "en": "Fan speed !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current fan speed !{{is|isn't}} [[speed]]" + "en": "Fan speed !{{is|isn't}} [[speed]]" }, "args": [ { @@ -422,10 +449,48 @@ { "id": "turbo_mode_is", "title": { - "en": "Current turbo mode !{{is|isn't}} ..." + "en": "Turbo mode !{{is|isn't}} ..." + }, + "titleFormatted": { + "en": "Turbo mode !{{is|isn't}} [[mode]]" + }, + "args": [ + { + "type": "device", + "name": "device", + "filter": "driver_id=gree_cooper_hunter_hvac" + }, + { + "name": "mode", + "type": "dropdown", + "values": [ + { + "id": "on", + "label": { + "en": "On", + "nl": "Aan", + "de": "Einschalten" + } + }, + { + "id": "off", + "label": { + "en": "Off", + "nl": "Uit", + "de": "Ausschalten" + } + } + ] + } + ] + }, + { + "id": "safety_heating_is", + "title": { + "en": "8°C heating !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current turbo mode !{{is|isn't}} [[mode]]" + "en": "8°C heating !{{is|isn't}} [[mode]]" }, "args": [ { @@ -460,10 +525,10 @@ { "id": "lights_is", "title": { - "en": "Current lights !{{is|isn't}} ..." + "en": "Lights !{{are|aren't}} ..." }, "titleFormatted": { - "en": "Current lights !{{is|isn't}} [[mode]]" + "en": "Lights !{{are|aren't}} [[mode]]" }, "args": [ { @@ -498,10 +563,10 @@ { "id": "xfan_mode_is", "title": { - "en": "Current X-Fan mode !{{is|isn't}} ..." + "en": "X-Fan mode !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current X-Fan mode !{{is|isn't}} [[mode]]" + "en": "X-Fan mode !{{is|isn't}} [[mode]]" }, "args": [ { @@ -536,10 +601,10 @@ { "id": "vertical_swing_is", "title": { - "en": "Current vertical swing !{{is|isn't}} ..." + "en": "Vertical swing !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current vertical swing !{{is|isn't}} [[vertical_swing]]" + "en": "Vertical swing !{{is|isn't}} [[vertical_swing]]" }, "args": [ { @@ -638,10 +703,10 @@ { "id": "horizontal_swing_is", "title": { - "en": "Current horizontal swing !{{is|isn't}} ..." + "en": "Horizontal swing !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current horizontal swing !{{is|isn't}} [[horizontal_swing]]" + "en": "Horizontal swing !{{is|isn't}} [[horizontal_swing]]" }, "args": [ { @@ -724,10 +789,10 @@ { "id": "quiet_mode_is", "title": { - "en": "Current quiet mode !{{is|isn't}} ..." + "en": "Quiet mode !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current quiet mode !{{is|isn't}} [[mode]]" + "en": "Quiet mode !{{is|isn't}} [[mode]]" }, "args": [ { @@ -953,6 +1018,43 @@ } ] }, + { + "id": "set_safety_heating", + "title": { + "en": "Set 8°C heating", + "nl": "Stel 8°C verwarming in", + "de": "8°C Heizung einstellen" + }, + "args": [ + { + "type": "device", + "name": "device", + "filter": "driver_id=gree_cooper_hunter_hvac" + }, + { + "name": "mode", + "type": "dropdown", + "values": [ + { + "id": "on", + "label": { + "en": "On", + "nl": "Aan", + "de": "Einschalten" + } + }, + { + "id": "off", + "label": { + "en": "Off", + "nl": "Uit", + "de": "Ausschalten" + } + } + ] + } + ] + }, { "id": "set_lights", "title": { @@ -1281,6 +1383,7 @@ "thermostat_mode", "fan_speed", "turbo_mode", + "safety_heating", "lights", "xfan_mode", "vertical_swing", @@ -1631,6 +1734,22 @@ "setable": true, "uiComponent": "picker" }, + "safety_heating": { + "type": "boolean", + "title": { + "en": "8°C heating", + "nl": "8°C verwarming", + "de": "8°C Heizung" + }, + "desc": { + "en": "The air conditioner keeps the room temperature at 8°C to prevent freezing", + "nl": "De airconditioner houdt de kamertemperatuur op 8°C om bevriezing te voorkomen.", + "de": "Die Klimaanlage hält die Raumtemperatur auf 8°C, um ein Einfrieren zu verhindern." + }, + "getable": true, + "setable": true, + "uiComponent": "toggle" + }, "turbo_mode": { "type": "boolean", "title": { diff --git a/drivers/gree_cooper_hunter_hvac/device.js b/drivers/gree_cooper_hunter_hvac/device.js index 0fd4f5d..f4a0b0b 100644 --- a/drivers/gree_cooper_hunter_hvac/device.js +++ b/drivers/gree_cooper_hunter_hvac/device.js @@ -41,6 +41,7 @@ class GreeHVACDevice extends Homey.Device { this._flowTriggerHvacFanSpeedChanged = this.homey.flow.getDeviceTriggerCard('fan_speed_changed'); this._flowTriggerHvacModeChanged = this.homey.flow.getDeviceTriggerCard('hvac_mode_changed'); this._flowTriggerTurboModeChanged = this.homey.flow.getDeviceTriggerCard('turbo_mode_changed'); + this._flowTriggerSafetyHeatingChanged = this.homey.flow.getDeviceTriggerCard('safety_heating_changed'); this._flowTriggerHvacLightsChanged = this.homey.flow.getDeviceTriggerCard('lights_changed'); this._flowTriggerXFanModeChanged = this.homey.flow.getDeviceTriggerCard('xfan_mode_changed'); this._flowTriggerVerticalSwingChanged = this.homey.flow.getDeviceTriggerCard('vertical_swing_changed'); @@ -192,6 +193,15 @@ class GreeHVACDevice extends Homey.Device { return Promise.resolve(); }); + this.registerCapabilityListener('safety_heating', (value) => { + const rawValue = value ? HVAC.VALUE.safetyHeating.on : HVAC.VALUE.safetyHeating.off; + this.log('[safety heating change]', `Value: ${value}`, `Raw value: ${rawValue}`); + this._setClientProperty(HVAC.PROPERTY.safetyHeating, rawValue); + this._flowTriggerSafetyHeatingChanged.trigger(this, { safety_heating: value }); + + return Promise.resolve(); + }); + this.registerCapabilityListener('lights', (value) => { const rawValue = value ? HVAC.VALUE.lights.on : HVAC.VALUE.lights.off; this.log('[lights change]', `Value: ${value}`, `Raw value: ${rawValue}`); @@ -367,6 +377,14 @@ class GreeHVACDevice extends Homey.Device { }).catch(this.error); } + if (this._checkBoolPropertyChanged(updatedProperties, HVAC.PROPERTY.safetyHeating, 'safety_heating')) { + const value = updatedProperties[HVAC.PROPERTY.safetyHeating] === HVAC.VALUE.safetyHeating.on; + this.setCapabilityValue('safety_heating', value).then(() => { + this.log('[update properties]', '[safety_heating]', value); + return this._flowTriggerSafetyHeatingChanged.trigger(this, { safety_heating: value }); + }).catch(this.error); + } + if (this._checkBoolPropertyChanged(updatedProperties, HVAC.PROPERTY.lights, 'lights')) { const value = updatedProperties[HVAC.PROPERTY.lights] === HVAC.VALUE.lights.on; this.setCapabilityValue('lights', value).then(() => { @@ -623,6 +641,12 @@ class GreeHVACDevice extends Homey.Device { this.log('[migration v0.8.1]', 'Adding "thermostat_mode" capability'); await this.addCapability('thermostat_mode'); } + + // Added in v0.9.4 + if (!this.hasCapability('safety_heating')) { + this.log('[migration v0.9.4]', 'Adding "safety_heating" capability'); + await this.addCapability('safety_heating'); + } } async _executeDeviceClassMigration() { diff --git a/drivers/gree_cooper_hunter_hvac/driver.compose.json b/drivers/gree_cooper_hunter_hvac/driver.compose.json index 4848c6b..0f02fee 100644 --- a/drivers/gree_cooper_hunter_hvac/driver.compose.json +++ b/drivers/gree_cooper_hunter_hvac/driver.compose.json @@ -10,6 +10,7 @@ "thermostat_mode", "fan_speed", "turbo_mode", + "safety_heating", "lights", "xfan_mode", "vertical_swing", @@ -142,4 +143,4 @@ "large": "/drivers/gree_cooper_hunter_hvac/assets/images/large.png", "small": "/drivers/gree_cooper_hunter_hvac/assets/images/small.png" } -} \ No newline at end of file +} diff --git a/drivers/gree_cooper_hunter_hvac/driver.flow.compose.json b/drivers/gree_cooper_hunter_hvac/driver.flow.compose.json index 6dc6ba8..f3c91ca 100644 --- a/drivers/gree_cooper_hunter_hvac/driver.flow.compose.json +++ b/drivers/gree_cooper_hunter_hvac/driver.flow.compose.json @@ -58,6 +58,27 @@ } ] }, + { + "id": "safety_heating_changed", + "title": { + "en": "8°C heating changed", + "nl": "8°C verwarming veranderd", + "de": "8°C Heizung geändert" + }, + "args": [], + "tokens": [ + { + "name": "safety_heating", + "type": "boolean", + "title": { + "en": "8°C heating", + "nl": "8°C verwarming", + "de": "8°C Heizung" + }, + "example": "true" + } + ] + }, { "id": "lights_changed", "title": { @@ -159,10 +180,10 @@ "id": "hvac_mode_is", "deprecated": true, "title": { - "en": "Current HVAC mode !{{is|isn't}} ..." + "en": "HVAC mode !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current HVAC mode !{{is|isn't}} [[mode]]" + "en": "HVAC mode !{{is|isn't}} [[mode]]" }, "args": [ { @@ -224,10 +245,10 @@ { "id": "fan_speed_is", "title": { - "en": "Current fan speed !{{is|isn't}} ..." + "en": "Fan speed !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current fan speed !{{is|isn't}} [[speed]]" + "en": "Fan speed !{{is|isn't}} [[speed]]" }, "args": [ { @@ -289,10 +310,43 @@ { "id": "turbo_mode_is", "title": { - "en": "Current turbo mode !{{is|isn't}} ..." + "en": "Turbo mode !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current turbo mode !{{is|isn't}} [[mode]]" + "en": "Turbo mode !{{is|isn't}} [[mode]]" + }, + "args": [ + { + "name": "mode", + "type": "dropdown", + "values": [ + { + "id": "on", + "label": { + "en": "On", + "nl": "Aan", + "de": "Einschalten" + } + }, + { + "id": "off", + "label": { + "en": "Off", + "nl": "Uit", + "de": "Ausschalten" + } + } + ] + } + ] + }, + { + "id": "safety_heating_is", + "title": { + "en": "8°C heating !{{is|isn't}} ..." + }, + "titleFormatted": { + "en": "8°C heating !{{is|isn't}} [[mode]]" }, "args": [ { @@ -322,10 +376,10 @@ { "id": "lights_is", "title": { - "en": "Current lights !{{is|isn't}} ..." + "en": "Lights !{{are|aren't}} ..." }, "titleFormatted": { - "en": "Current lights !{{is|isn't}} [[mode]]" + "en": "Lights !{{are|aren't}} [[mode]]" }, "args": [ { @@ -355,10 +409,10 @@ { "id": "xfan_mode_is", "title": { - "en": "Current X-Fan mode !{{is|isn't}} ..." + "en": "X-Fan mode !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current X-Fan mode !{{is|isn't}} [[mode]]" + "en": "X-Fan mode !{{is|isn't}} [[mode]]" }, "args": [ { @@ -388,10 +442,10 @@ { "id": "vertical_swing_is", "title": { - "en": "Current vertical swing !{{is|isn't}} ..." + "en": "Vertical swing !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current vertical swing !{{is|isn't}} [[vertical_swing]]" + "en": "Vertical swing !{{is|isn't}} [[vertical_swing]]" }, "args": [ { @@ -485,10 +539,10 @@ { "id": "horizontal_swing_is", "title": { - "en": "Current horizontal swing !{{is|isn't}} ..." + "en": "Horizontal swing !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current horizontal swing !{{is|isn't}} [[horizontal_swing]]" + "en": "Horizontal swing !{{is|isn't}} [[horizontal_swing]]" }, "args": [ { @@ -566,10 +620,10 @@ { "id": "quiet_mode_is", "title": { - "en": "Current quiet mode !{{is|isn't}} ..." + "en": "Quiet mode !{{is|isn't}} ..." }, "titleFormatted": { - "en": "Current quiet mode !{{is|isn't}} [[mode]]" + "en": "Quiet mode !{{is|isn't}} [[mode]]" }, "args": [ { @@ -775,6 +829,38 @@ } ] }, + { + "id": "set_safety_heating", + "title": { + "en": "Set 8°C heating", + "nl": "Stel 8°C verwarming in", + "de": "8°C Heizung einstellen" + }, + "args": [ + { + "name": "mode", + "type": "dropdown", + "values": [ + { + "id": "on", + "label": { + "en": "On", + "nl": "Aan", + "de": "Einschalten" + } + }, + { + "id": "off", + "label": { + "en": "Off", + "nl": "Uit", + "de": "Ausschalten" + } + } + ] + } + ] + }, { "id": "set_lights", "title": { @@ -1064,4 +1150,4 @@ ] } ] -} \ No newline at end of file +}