Skip to content

Commit

Permalink
Merge pull request #64 from aaronsb/return-to-krupa
Browse files Browse the repository at this point in the history
Thank you for bringing this up to date. And sorry for the long wait!
  • Loading branch information
arthurkrupa committed Aug 10, 2021
2 parents 6ab6695 + a15be4a commit 0774aba
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 54 deletions.
72 changes: 47 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bridge service for communicating with Gree air conditioners using MQTT broadcast

## Requirements

- NodeJS (>=8.11.0) with NPM
- NodeJS (>=11.0.0) with NPM
- An MQTT broker and Gree smart HVAC device on the same network
- Docker (for building Hass.io addon)

Expand Down Expand Up @@ -124,36 +124,42 @@ docker build \
docker run --rm -v "$PWD/data":/data gree-hvac-mqtt-bridge
```

### Multiple devices

As of 1.2.0 the Hassio addon supports multiple devices by running paralell NodeJS processes in PM2. Old configurations will work, but are deprecated.
### Run single device as a service

Deprecated config example:
To run it when the PC starts, a systemd service has to be created by following the following commands.

```json
"hvac_host": "192.168.0.255",
"mqtt": {
"broker_url": "mqtt:https://localhost",
"topic_prefix": "/my/topic/prefix",
}
```shell
sudo cp /opt/gree-hvac-mqtt-bridge/gree-bridge.service /etc/systemd/system/gree-bridge.service
sudo chmod +x /etc/systemd/system/gree-bridge.service
sudo systemctl enable gree-bridge
sudo systemctl start gree-bridge
```

Correct config example:
### Multiple devices

As of 1.2.0 the Hassio addon supports multiple devices by running paralell NodeJS processes in PM2. Old configurations will work, but will run without PM2.

config example:

```json
"mqtt": {
"broker_url": "mqtt:https://localhost",
},
"devices": [
{
"hvac_host": "192.168.0.255",
"mqtt_topic_prefix": "/home/hvac01"
},
{
"hvac_host": "192.168.0.254",
"mqtt_topic_prefix": "/home/hvac02"
}
]
{
"mqtt": {
"broker_url": "mqtt:https://localhost",
"username": "user",
"password": "pass",
"retain": false
},
"devices": [
{
"hvac_host": "192.168.0.255",
"mqtt_topic_prefix": "/home/hvac01"
},
{
"hvac_host": "192.168.0.254",
"mqtt_topic_prefix": "/home/hvac02"
}
]
}
```

## Configuring HVAC WiFi
Expand All @@ -170,6 +176,19 @@ Note: This command may vary depending on your OS (e.g. Linux, macOS, CygWin). If

## Changelog

[1.2.4]
- Updated NPM dependency versions to more current (~2 years old!)
- Defined fsevents as optional for linux based platforms
- as of 4/26/2021 "found 0 vulnerabilities"
- UDP Datagram warning is fixed with later versions


[1.2.3]

- Fix run script for single device with same configuration
- Run single device as a systemd service
- Add option to MQTT for retain flag

[1.2.2]

- Fix incorrect state checks
Expand Down Expand Up @@ -229,3 +248,6 @@ This project is licensed under the GNU GPLv3 - see the [LICENSE.md](LICENSE.md)

- [tomikaa87](https://github.com/tomikaa87) for reverse-engineering the Gree protocol
- [oroce](https://github.com/oroce) for inspiration
- [arthurkrupa](https://https://github.com/arthurkrupa) for the actual service
- [bkbilly](https://github.com/bkbilly) for service improvements to MQTT
- [aaronsb](https://github.com/aaronsb) for sweeping the Node floor
9 changes: 6 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "Gree HVAC MQTT bridge",
"version": "1.2.2",
"version": "1.2.3",
"slug": "gree_hvac_mqtt_bridge",
"description": "Hass.io addon for controlling Gree air conditioners using the MQTT climate platform",
"url": "https://github.com/aaronsb/gree-hvac-mqtt-bridge",
"arch": [ "aarch64", "amd64", "armhf", "armv7", "i386" ],
"startup": "application",
"boot": "auto",
Expand All @@ -12,7 +13,8 @@
"mqtt": {
"broker_url": "mqtt:https://localhost",
"username": "",
"password": ""
"password": "",
"retain": ""
},
"devices": [
{
Expand All @@ -27,7 +29,8 @@
"broker_url": "str",
"topic_prefix": "str?",
"username": "str?",
"password": "str?"
"password": "str?",
"retain": "str?"
},
"devices": [
{
Expand Down
13 changes: 13 additions & 0 deletions gree-bridge.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Gree HVAC MQTT Bridge
After=network.target

[Service]
User=root
WorkingDirectory=/opt/gree-hvac-mqtt-bridge
ExecStart=/opt/gree-hvac-mqtt-bridge/run.sh
Restart=always

[Install]
WantedBy=multi-user.target

8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ const deviceState = {
* @param {string} mqttTopic Topic (without prefix) to send with new value
*/
const publishIfChanged = function (stateProp, newValue, mqttTopic) {
const pubmqttOptions = {
retain: false
}
if (argv['mqtt-retain']) {
pubmqttOptions.retain = (argv['mqtt-retain'] == "true")
}
if (newValue !== deviceState[stateProp]) {
deviceState[stateProp] = newValue
client.publish(mqttTopicPrefix + mqttTopic, newValue)
client.publish(mqttTopicPrefix + mqttTopic, newValue, pubmqttOptions)
}
}

Expand Down
43 changes: 31 additions & 12 deletions package-lock.json

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

21 changes: 15 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
{
"name": "gree-hvac-mqtt-bridge",
"version": "1.2.2",
"version": "1.2.4",
"description": "MQTT Bridge for controlling Gree smart air conditioners",
"main": "index.js",
"scripts": {
"test": "standard"
},
"keywords": [],
"author": "Arthur Krupa <[email protected]>",
"contributors": [
"Aaron Bockelie <[email protected]> (https://github.com/aaronsb)",
"Róbert Oroszi <[email protected]> (https://github.com/oroce)",
"Tamas Karpati <[email protected]> (https://github.com/otmikaa87)",
"Vasilis Koulis <[email protected]> (https://github.com/bkbilly)"
],
"license": "MIT",
"dependencies": {
"minimist": "^1.2.0",
"mqtt": "^2.15.0",
"pm2": "^3.5.0"
"minimist": "^1.2.5",
"mqtt": "^4.2.6",
"pm2": "^4.5.6"
},
"optionalDependencies": {
"fsevents": ">=2.3.1"
},
"engines": {
"node": ">=8.11.0"
"node": ">=11.0.0"
},
"os": [
"darwin",
"linux"
],
"private": true,
"devDependencies": {
"standard": "^12.0.1"
"standard": "^16.0.3"
}
}
2 changes: 1 addition & 1 deletion repository.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"name": "Gree HVAC MQTT bridge",
"url": "https://github.com/arthurkrupa/gree-hvac-mqtt-bridge",
"maintainer": "Arthur Krupa <[email protected]>"
}
}
Loading

0 comments on commit 0774aba

Please sign in to comment.