Skip to content

Commit

Permalink
Add Turbo mode
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkrupa committed Jan 12, 2019
1 parent 312d004 commit 7f91a2c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Note: _boolean_ values are set using 0 or 1
| **blow** | _0_, _1_ | Keeps the fan running for a while after shutting down (also called "X-Fan", only usable in Dry and Cool mode) |
| **air** | _off_, _inside_, _outside_ | Fresh air valve |
| **sleep** | _0_, _1_ | Sleep mode |
| **turbo** | _0_, _1_ | Turbo mode |

## Hass.io addon

Expand Down Expand Up @@ -136,6 +137,10 @@ Note: This command may vary depending on your OS (e.g. Linux, macOS, CygWin). If
## Changelog
[1.1.1]
- Add Turbo mode
[1.1.0]
- Add support for MQTT authentication
Expand Down
39 changes: 39 additions & 0 deletions app/deviceFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,54 +279,93 @@ class Device {
);
};

/**
* Set power save mode
* @param {boolean} value on/off
*/
setPowerSave (value) {
this._sendCommand(
[cmd.energySave.code],
[value ? 1 : 0]
)
};

/**
* Set lights on/off
* @param {boolean} value on/off
*/
setLights (value) {
this._sendCommand(
[cmd.lights.code],
[value ? 1 : 0]
)
};

/**
* Set health mode
* @param {boolean} value on/off
*/
setHealthMode (value) {
this._sendCommand(
[cmd.health.code],
[value ? 1 : 0]
);
}

/**
* Set quiet mode
* @param {boolean} value on/off
*/
setQuietMode (value) {
this._sendCommand(
[cmd.quiet.code],
[value ? 1 : 0]
)
};

/**
* Set blow mode
* @param {boolean} value on/off
*/
setBlow (value) {
this._sendCommand(
[cmd.blow.code],
[value ? 1 : 0]
)
};

/**
* Set air valve mode
* @param {boolean} value on/off
*/
setAir (value) {
this._sendCommand(
[cmd.air.code],
[value ? 1 : 0]
)
};

/**
* Set sleep mode
* @param {boolean} value on/off
*/
setSleepMode (value) {
this._sendCommand(
[cmd.sleep.code],
[value ? 1 : 0]
)
};

/**
* Set turbo mode
* @param {boolean} value on/off
*/
setTurbo (value) {
this._sendCommand(
[cmd.turbo.code],
[value ? 1 : 0]
)
};
};

module.exports.connect = function(options) {
Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Gree HVAC MQTT bridge",
"version": "1.1.0",
"version": "1.1.1",
"slug": "gree_hvac_mqtt_bridge",
"description": "Hass.io addon for controlling Gree air conditioners using the MQTT climate platform",
"startup": "application",
Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const deviceOptions = {
client.publish(mqttTopicPrefix + '/blow/get', commands.blow.value.getKeyByValue(deviceModel.props[commands.blow.code]).toString());
client.publish(mqttTopicPrefix + '/air/get', commands.air.value.getKeyByValue(deviceModel.props[commands.air.code]).toString());
client.publish(mqttTopicPrefix + '/sleep/get', commands.sleep.value.getKeyByValue(deviceModel.props[commands.sleep.code]).toString());
client.publish(mqttTopicPrefix + '/turbo/get', commands.turbo.value.getKeyByValue(deviceModel.props[commands.turbo.code]).toString());

/**
* Handle "off" mode status
Expand Down Expand Up @@ -67,6 +68,7 @@ const deviceOptions = {
client.subscribe(mqttTopicPrefix + '/blow/set');
client.subscribe(mqttTopicPrefix + '/air/set');
client.subscribe(mqttTopicPrefix + '/sleep/set');
client.subscribe(mqttTopicPrefix + '/turbo/set');
}
};

Expand Down Expand Up @@ -139,6 +141,9 @@ client.on('message', (topic, message) => {
case mqttTopicPrefix + '/sleep/set':
hvac.setSleepMode(parseInt(message));
return;
case mqttTopicPrefix + '/turbo/set':
hvac.setTurbo(parseInt(message));
return;
}
console.log('[MQTT] No handler for topic %s', topic)
});
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gree-hvac-mqtt-bridge",
"version": "1.1.0",
"version": "1.1.1",
"description": "MQTT Bridge for controlling Gree smart air conditioners",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 7f91a2c

Please sign in to comment.