Skip to content

Commit

Permalink
Add support of "8°C heating" mode
Browse files Browse the repository at this point in the history
  • Loading branch information
aivus committed Sep 27, 2024
1 parent ffddc1a commit ed5d482
Show file tree
Hide file tree
Showing 9 changed files with 299 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ indent_size = 4
trim_trailing_whitespace = true
max_line_length = 100

[{app.json,.homeychangelog.json}]
[*.json]
indent_size = 2
3 changes: 3 additions & 0 deletions .homeychangelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion .homeycompose/app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "com.gree",
"version": "0.9.3",
"version": "0.9.4",
"compatibility": ">=12.0.1",
"sdk": 3,
"brandColor": "#ff732e",
Expand Down
16 changes: 16 additions & 0 deletions .homeycompose/capabilities/safety_heating.json
Original file line number Diff line number Diff line change
@@ -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"
}
14 changes: 13 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -130,7 +143,6 @@ class GreeHVAC extends Homey.App {
});
});
}

Check failure on line 145 in app.js

View workflow job for this annotation

GitHub Actions / build (16)

Block must be padded by blank lines

}

function onoffToBoolean(value) {
Expand Down
153 changes: 136 additions & 17 deletions app.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -1281,6 +1383,7 @@
"thermostat_mode",
"fan_speed",
"turbo_mode",
"safety_heating",
"lights",
"xfan_mode",
"vertical_swing",
Expand Down Expand Up @@ -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": {
Expand Down
24 changes: 24 additions & 0 deletions drivers/gree_cooper_hunter_hvac/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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() {
Expand Down
Loading

0 comments on commit ed5d482

Please sign in to comment.