Giter VIP home page Giter VIP logo

gree-hvac-mqtt-bridge's Introduction

Gree HVAC MQTT bridge

Bridge service for communicating with Gree air conditioners using MQTT broadcasts. It can also be used as a Hass.io addon.

Requirements

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

Running locally

Make sure you have NodeJS (>=8.11.0) installed and run the following (adjust the arguments to match your setup):

npm install
node index.js \
    --hvac-host="192.168.1.255" \
    --mqtt-broker-url="mqtt://localhost" \
    --mqtt-topic-prefix="home/greehvac" \
    --mqtt-username="" \
    --mqtt-password=""

Supported commands

MQTT topic scheme:

  • MQTT_TOPIC_PREFIX/COMMAND/get Get value
  • MQTT_TOPIC_PREFIX/COMMAND/set Set value

Note: boolean values are set using 0 or 1

Command Values Description
temperature any integer In degrees Celsius by default
mode off, auto, cool, heat, dry, fan_only Operation mode
fanspeed auto, low, mediumLow, medium, mediumHigh, high Fan speed
swinghor default, full, fixedLeft, fixedMidLeft, fixedMid, fixedMidRight, fixedRight Horizontal Swing
swingvert default, full, fixedTop, fixedMidTop, fixedMid, fixedMidBottom, fixedBottom, swingBottom, swingMidBottom, swingMid, swingMidTop, swingTop Vetical swing
power 0, 1 Turn device on/off
health 0, 1 Health ("Cold plasma") mode, only for devices equipped with "anion generator", which absorbs dust and kills bacteria
powersave 0, 1 Power Saving mode
lights 0, 1 Turn on/off device lights
quiet 0, 1, 2, 3 Quiet modes
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, mode3 Fresh air valve
sleep 0, 1 Sleep mode
turbo 0, 1 Turbo mode

Hass.io addon

The service can be used as a 3rd party addon for the Hass.io MQTT climate platform, although not all commands are supported.

  1. Install the addon
  2. Customize addon options (HVAC host, MQTT broker URL, MQTT topic prefix)
  3. Add the following to your configuration.yaml
climate:
  - platform: mqtt

    # Change to whatever you want
    name: Gree HVAC

    # Change MQTT_TOPIC_PREFIX to what you've set in addon options
    current_temperature_topic: "MQTT_TOPIC_PREFIX/temperature/get"
    temperature_command_topic: "MQTT_TOPIC_PREFIX/temperature/set"
    temperature_state_topic: "MQTT_TOPIC_PREFIX/temperature/get"
    mode_state_topic: "MQTT_TOPIC_PREFIX/mode/get"
    mode_command_topic: "MQTT_TOPIC_PREFIX/mode/set"
    fan_mode_state_topic: "MQTT_TOPIC_PREFIX/fanspeed/get"
    fan_mode_command_topic: "MQTT_TOPIC_PREFIX/fanspeed/set"
    swing_mode_state_topic: "MQTT_TOPIC_PREFIX/swingvert/get"
    swing_mode_command_topic: "MQTT_TOPIC_PREFIX/swingvert/set"
    power_state_topic: "MQTT_TOPIC_PREFIX/power/get"
    power_command_topic: "MQTT_TOPIC_PREFIX/power/set"

    # Keep the following as is
    payload_off: 0
    payload_on: 1
    modes:
      - "off"
      - "auto"
      - "cool"
      - "heat"
      - "dry"
      - "fan_only"
    swing_modes:
      - "default"
      - "full"
      - "fixedTop"
      - "fixedMidTop"
      - "fixedMid"
      - "fixedMidBottom"
      - "fixedBottom"
      - "swingBottom"
      - "swingMidBottom"
      - "swingMid"
      - "swingMidTop"
      - "swingTop"
    fan_modes:
      - "auto"
      - "low"
      - "mediumLow"
      - "medium"
      - "mediumHigh"
      - "high"

How to power on/off

Hass.io doesn't supply separate on/off switch. Use the dedicated mode for that.

Running addon locally

Create an ./data/options.json file inside the repo with persistent addon configuration.

docker build \
    --build-arg BUILD_FROM="homeassistant/amd64-base:latest" \
    -t gree-hvac-mqtt-bridge .

docker run --rm -v "$PWD/data":/data gree-hvac-mqtt-bridge

Run single device as a service

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

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

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:

{
    "mqtt": {
        "broker_url": "mqtt://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

  1. Make sure your HVAC is running in AP mode. You can reset the WiFi config by pressing MODE +WIFI (or MODE + TURBO) on the AC remote for 5s.
  2. Connect with the AP wifi network (the SSID name should be a 8-character alfanumeric, e.g. "u34k5l166").
  3. Run the following in your UNIX terminal:
echo -n "{\"psw\": \"YOUR_WIFI_PASSWORD\",\"ssid\": \"YOUR_WIFI_SSID\",\"t\": \"wlan\"}" | nc -cu 192.168.1.1 7000

Note: This command may vary depending on your OS (e.g. Linux, macOS, CygWin). If facing problems, please consult the appropriate netcat manual.

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

[1.2.0]

  • Add multiple device support
  • Update config with supported architectures
  • Fix state being published even if nothing changed

[1.1.2]

  • Discovered codes added for Air and Quiet to avoid errors
  • Added swingHor mode codes

[1.1.1]

  • Add Turbo mode

[1.1.0]

  • Add support for MQTT authentication
  • BREAKING: Update MQTT mode state names to match Hass.io defaults
  • Add support for new modes: Air, Power Save, Lights, Health, Quiet, Sleep, Blow
  • Fix deprecated Buffer() use

[1.0.5]

  • Add Hass.io API security role

[1.0.4]

  • Bump NodeJS version to 8.11.2

[1.0.3]

  • Fix power off command

[1.0.2]

  • Bump NodeJS version to 8.9.3

[1.0.1]

  • Update MQTT version
  • Add UDP error handling
  • Extend Readme

[1.0.0] First release

License

This project is licensed under the GNU GPLv3 - see the LICENSE.md file for details

Acknowledgments

gree-hvac-mqtt-bridge's People

Contributors

aaronsb avatar arthurkrupa avatar bkbilly avatar mrblur avatar oroce avatar roleee avatar wjketting avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gree-hvac-mqtt-bridge's Issues

Is it needed to configure it?

Hello,

First of all, you just saved me a whole lot of time, I was trying to reverse engineer the communication as well to integrate my A/C with Google Home.

The question is, I already "paired" the A/C with the app and I would like the app to continue to function in parallel with this integration. Is it really necessary to reset the WiFi and pair it again?

Thanks,
Mihai

Home Assistant shows "Invalid mode: off"

Hi!

Hass keeps showing me these errors in the log file:
2019-03-14 01:15:44 ERROR (MainThread) [homeassistant.components.mqtt.climate] Invalid mode: off
As you can see it is quite common:
Invalid mode: off
1:24 components/mqtt/climate.py (ERROR) - message first occured at 1:22 and shows up 45 times
this was generated in a couple minutes only.
Could you please look into it?
There is nothing in the add-on's log.

Thanks!
B

Failed to install addon

The command '/bin/ash -o pipefail -c apk add --no-cache jq nodejs nodejs-npm && npm set unsafe-perm true' returned a non-zero code: 2

Wifi setup command doesn't work in CygWin

i read the docs i'm on a windows machine downloaded

cygwin and typed command below

echo -n "{"psw": "YOUR_WIFI_PASSWORD","ssid": "YOUR_WIFI_SSID","t": "wlan"}" | nc -cu 192.168.1.1 7000

as written in the docs replacing my wifi info

it it says there is no such command so i searched netcat docs and indeed there is no cu comand

did i miss something

thanks

dave

Gree Heatpump keeps going into AP mode

Love this app. Works like a treat.
Anyone else having issues with the heatpump going back into AP mode therefor disconnects to my wifi and I can no longer talk to it with gree2mqtt.
Have setup Wifi on Heatpump using the GREE+ android app. Do I have to use the netcat command in the setup?

Thank you.

Missing "arch" key in config.json

Hello, a small update ahead.

19-04-18 16:35:17 WARNING (MainThread) [hassio.addons.data] Can't read /data/addons/git/9b38ba57/config.json: required key not provided @ data['arch']. Got None
you have to add in config.json

"arch": [ "aarch64", "amd64", "armhf", "armv7", "i386" ],

jhqv/hassio-addons@2a575b1

error in homeassistant.log

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 121, in handle_call_service connection.context(msg)) File "/usr/src/homeassistant/homeassistant/core.py", line 1150, in async_call self._execute_service(handler, service_call)) File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service await handler.func(service_call) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 194, in handle_service required_features File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 316, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 337, in _handle_service_platform_call await getattr(entity, func)(**data) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 491, in turn_off raise NotImplementedError() NotImplementedError

my config:

name: Gree AC

current_temperature_topic: "home/gree/temperature/get"
temperature_command_topic: "home/gree/temperature/set"
temperature_state_topic: "home/gree/temperature/get"
mode_state_topic: "home/gree/mode/get"
mode_command_topic: "home/gree/mode/set"
fan_mode_state_topic: "home/gree/fanspeed/get"
fan_mode_command_topic: "home/gree/fanspeed/set"
swing_mode_state_topic: "home/gree/swingvert/get"
swing_mode_command_topic: "home/gree/swingvert/set"
power_state_topic: "home/gree/power/get"
power_command_topic: "home/gree/power/set"

# Keep the following as is
payload_off: 0
payload_on: 1
modes:
  - "off"
  - "auto"
  - "cool"
  - "heat"
  - "dry"
  - "fan_only"
swing_modes:
  - "default"
  - "full"
  - "fixedTop"
  - "fixedMidTop"
  - "fixedMid"
  - "fixedMidBottom"
  - "fixedBottom"
  - "swingBottom"
  - "swingMidBottom"
  - "swingMid"
  - "swingMidTop"
  - "swingTop"
fan_modes:
  - "auto"
  - "low"
  - "mediumLow"
  - "medium"
  - "mediumHigh"
  - "high"

latest hassio 0.94.3

addon config

{
"mqtt": {
"broker_url": "mqtt://10.240.1.240",
"username": "xxx",
"password": "xxx"
},
"devices": [
{
"hvac_host": "10.240.1.216",
"mqtt_topic_prefix": "home/gree"
}
]
}

Invalid Mode

Getting spammed with invalid mode after upgrading to 1.1.0

image

I have added the new configuration.yaml options according to the readme

climate office_ac:
  - platform: mqtt

    # Change to whatever you want
    name: Office AC

    # Change MQTT_TOPIC_PREFIX to what you've set in addon options
    current_temperature_topic: "officeac/temperature/get"
    temperature_command_topic: "officeac/temperature/set"
    temperature_state_topic: "officeac/temperature/get"
    mode_state_topic: "officeac/mode/get"
    mode_command_topic: "officeac/mode/set"
    fan_mode_state_topic: "officeac/fanspeed/get"
    fan_mode_command_topic: "officeac/fanspeed/set"
    swing_mode_state_topic: "officeac/swingvert/get"
    swing_mode_command_topic: "officeac/swingvert/set"
    power_state_topic: "officeac/power/get"
    power_command_topic: "officeac/power/set"

    # Keep the following as is
    payload_off: 0
    payload_on: 1
    mode_state_template: "{{ value_json }}"
    modes:
      - "off"
      - "auto"
      - "cool"
      - "heat"
      - "dry"
      - "fan_only"
    swing_modes:
      - "default"
      - "full"
      - "fixedTop"
      - "fixedMidTop"
      - "fixedMid"
      - "fixedMidBottom"
      - "fixedBottom"
      - "swingBottom"
      - "swingMidBottom"
      - "swingMid"
      - "swingMidTop"
      - "swingTop"
    fan_modes:
      - "auto"
      - "low"
      - "mediumLow"
      - "medium"
      - "mediumHigh"
      - "high"

MQTT connection only works if URL is an IP address

If you use domain name insted of IP address, the addon will stop.

{
  "hvac_host": "192.168.210.80",
  "mqtt": {
    "broker_url": "mqtt://my.home.domain:1883",
    "topic_prefix": "home/greehvac",
    "username": "xxx",
    "password": "***"
  }
}

The addon don't write any error in the log.
After I changed the broker_url to IP address then it worked.

s6-overlay-suexec: fatal: can only run as pid 1

I needed to restore my whole HA from backup due to some issues and after that addon stopped working and when I try to start it message from title is shown in logs. Tried rebuilding, reinstalling, removing and adding repo again, nothing helps. What is going on?

State is not refreshing

Hi,

Thanks for the big work ;)

The state of AC is not refreshing.

I have on AC log:

0|HVAC_0  | [MQTT] Message "fixedTop" received for homeassistant/greehvac/swingvert/set
0|HVAC_0  | [UDP] Status updated on 1e53f1d2
0|HVAC_0  | [MQTT] Message "cool" received for homeassistant/greehvac/mode/set
0|HVAC_0  | [UDP] Status updated on 1e53f1d2
0|HVAC_0  | [MQTT] Message "auto" received for homeassistant/greehvac/mode/set
0|HVAC_0  | [UDP] Status updated on 1e53f1d2
0|HVAC_0  | [MQTT] Message "cool" received for homeassistant/greehvac/mode/set
0|HVAC_0  | [UDP] Status updated on 1e53f1d2
0|HVAC_0  | [MQTT] Message "22.0" received for homeassistant/greehvac/temperature/set
0|HVAC_0  | [UDP] Status updated on 1e53f1d2
0|HVAC_0  | [MQTT] Message "cool" received for homeassistant/greehvac/mode/set
0|HVAC_0  | [UDP] Status updated on 1e53f1d2
0|HVAC_0  | [MQTT] Message "fixedMid" received for homeassistant/greehvac/swingvert/set
0|HVAC_0  | [UDP] Status updated on 1e53f1d2

And on the MQTT log there is nothing.
It works when I change stats, but I'm not receiving any status updates at all.

What could be wrong?

I've also one minor problem with repo readme - it was confusing for me, that hass.io addon manual is on the same level as Running locally, so it looks like you have to do both things to get it work (but it is not the case, I guess?) :)

Extract HVAC logic to a separate package

Hi Arthur and thank you for this great repo.

I'm going to implement integration Gree HVAC with Homey and reuse HVAC logic from this repo. But this repo has not only interaction logic but mqtt bridge as well.

It will be good to have bridge and HVAC interaction logic (from app directory) in separate modules.

I know that I still can use your module and use only deviceFactory in my module but it will have additional not used functional.

What do you think about separating logic?

Mosquitto mqtt broker v3 update

Since Mosquitto got updated to V3 every thing went south. I couldn't boot Hassio, and I had to start the configuration all over again.

I have managed to get my Tasmota devices to work, but I couldn't configure Gree Hvac bridge. I'm not using login info on Mosquitto. Is there a way to configure this addon on V3 Mosquitto update, or is it broken?

Edit: I got it working... Not sure how, but I can confirm it works.

bad decrypt

Hi,

Thanks for this handy utility :) I managed to used it successfully with one of my AC, but then I enabled the WiFi on the second one, and the script can not start up any more. I get this traceback:

$ node index.js --mqtt-broker-url="mqtt://localhost" --mqtt-topic-prefix="home/greehvac" --hvac-host="192.168.88.255"
[MQTT] Connected to broker on mqtt://localhost
[UDP] Connected to device at 192.168.88.255
[UDP] New device registered: Nappali
[UDP] New device registered: Emelet
[UDP] Device Emelet is bound!
crypto.js:183
  var ret = this._handle.final();
                         ^

Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
    at Decipheriv.final (crypto.js:183:26)
    at Object.decrypt (/home/major/Downloads/gree-hvac-mqtt-bridge/app/encryptionService.js:21:56)
    at Device._handleResponse (/home/major/Downloads/gree-hvac-mqtt-bridge/app/deviceFactory.js:150:40)
    at Socket.Device.socket.on (/home/major/Downloads/gree-hvac-mqtt-bridge/app/deviceFactory.js:47:51)
    at emitTwo (events.js:126:13)
    at Socket.emit (events.js:214:7)
    at UDP.onMessage [as onmessage] (dgram.js:659:8)

Does the script support more than one devices at the same time?

Installation help needed - Cannot bind

My friends, how do I deal with this problem?
On the advice of a programmer friend, the log output was increased.
image

[TAILING] Tailing last 15 lines for [/HVAC_/] process (change the value with --lines option),
/root/.pm2/logs/HVAC-0-out.log last 15 lines:,
0|HVAC_0 | [MQTT] Connecting to mqtt://192.168.2.6...,
0|HVAC_0 | [UDP] Connected to device at 192.168.2.235,
0|HVAC_0 | [MQTT] Connected to broker,
0|HVAC_0 | { t: 'pack',,
0|HVAC_0 | i: 1,,
0|HVAC_0 | uid: 0,,
0|HVAC_0 | cid: '',,
0|HVAC_0 | tcid: '',,
0|HVAC_0 | pack:,
0|HVAC_0 | 'LP24Ek0OaYogxs3iQLjL4GkmBNTzMwOtezbnQQvadq+F4Js8mGMCoIEjyN0Y3BfgpqjwKof9L5vI0JQ76AS2tMf4gaQXzcgJ2+74CkMVbRFsaH7s7hYVQ+YB/WaUbx4E0boasj6Z1Xpqyl4z/nH5nphFSaIjJJpCRNwGmJT+oECJymYSz66Z1I82cCtFYs6xqWyYvOKrHQL5tpN9F6TfeX10UcDO1f3eTw/NIuJ/oeE=' },
0|HVAC_0 | [UDP] New device registered: 42720b3a,
0|HVAC_0 | [UDP] Unknown message of type bindok: [object Object], [object Object]

Publish only the changes

Is it necessary to publish 374400 mqtt-message daily? 13 publish every 3 seconds.

Proposal:
[index.zip]
(https://github.com/arthurkrupa/gree-hvac-mqtt-bridge/files/3109528/index.zip)

var last_temperature = '';

if(last_temperature != deviceModel.props[commands.temperature.code].toString()){
client.publish(mqttTopicPrefix + '/temperature/get', deviceModel.props[commands.temperature.code].toString());
last_temperature = deviceModel.props[commands.temperature.code].toString();
}

Several ACs in one network

First, thank you for this mqtt module - It works flawlessly.
I’m a newbie to mqtt stuff, could please give a hint how to establish communication with several ACs at once and control them afterwards by publish commands. I’m controlling them from raspberry pi and do I have to start like several terminals with node.js preferences and unique IPs, prefixes (home/hvacgree1, home/hvacgree2, ...) and control them using this prefixes? Maybe a .sh script should work to automate this process of initialization? Thanks in advance

Adding Light, Health, Sleep to hassio

Is it possible to add the Health, Sleep and Light options to hassio, Iguess they aren't added because they aren't part of the standard climate control. Does that mean it's best to add them as switches?

sleep and quiet

Hello

How I can map all the buttos like quiet, sleep, xfan, mode?
I added in the yaml, but it seems they are not supported.

I think that the missing button are the cause of the wifi issue for which I opened a separated request

Claudio

Can't send action with Home Assistant entity

Hi guys,
I have a Daitsu A / C, and I don't know why, but I think it uses the same hardware wifi as the Gree. I installed the Hassio addon and I think everything is ok. In the log section I have this:

[MQTT] Connected to broker on mqtt://xxx.xxx.xxx.xxx:1883
[UDP] Connected to device at xxx.xxx.xxx.xxx
[UDP] New device registered: xxxxxxxx
[UDP] Device xxxxxxxx is bound!

I created the entity with Home assistant but I can't give it any action. In the section Developers Tools -> Services if I call the service climate.turn_on I have this error in the home-assistant.log:

raceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 122, in handle_call_service connection.context(msg)) File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1138, in async_call self._execute_service(handler, service_call)) File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1160, in _execute_service await handler.func(service_call) File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py", line 188, in handle_service self._platforms.values(), func, call, service_name File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 314, in entity_service_call future.result() # pop exception if have File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 328, in _handle_service_platform_call await getattr(entity, func)(**data) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.7/site-packages/homeassistant/components/climate/__init__.py", line 485, in turn_on raise NotImplementedError() NotImplementedError

I use the Hassio plugin mosquitto for the mqtt broker, this is my entity in configuration.yaml:
`climate:

  • platform: mqtt
    name: Condizionatore Cucina
    current_temperature_topic: "MQTT_TOPIC_PREFIX/temperature/get"
    temperature_command_topic: "MQTT_TOPIC_PREFIX/temperature/set"
    temperature_state_topic: "MQTT_TOPIC_PREFIX/temperature/get"
    mode_state_topic: "MQTT_TOPIC_PREFIX/mode/get"
    mode_command_topic: "MQTT_TOPIC_PREFIX/mode/set"
    fan_mode_state_topic: "MQTT_TOPIC_PREFIX/fanspeed/get"
    fan_mode_command_topic: "MQTT_TOPIC_PREFIX/fanspeed/set"
    swing_mode_state_topic: "MQTT_TOPIC_PREFIX/swingvert/get"
    swing_mode_command_topic: "MQTT_TOPIC_PREFIX/swingvert/set"
    power_state_topic: "MQTT_TOPIC_PREFIX/power/get"
    power_command_topic: "MQTT_TOPIC_PREFIX/power/set"
    payload_off: 0
    payload_on: 1
    modes:
    • "off"
    • "auto"
    • "cool"
    • "heat"
    • "dry"
    • "on"
    • "fan_only"
      swing_modes:
    • "default"
    • "full"
    • "fixedTop"
    • "fixedMidTop"
    • "fixedMid"
    • "fixedMidBottom"
    • "fixedBottom"
    • "swingBottom"
    • "swingMidBottom"
    • "swingMid"
    • "swingMidTop"
    • "swingTop"
      fan_modes:
    • "auto"
    • "low"
    • "mediumLow"
    • "medium"
    • "mediumHigh"
    • "high"`

any idea's?

Thanks,
Daniele

Compatibility

Is this project compatible with the Gree HVAC GWH12ACC and GWH09QB? Each of those have Wi-Fi on board.

Thank you!

Error: "Unknown message of type bindok"

I get an error when starting this stuff.
npm version: 8.18.0
node version: 16.13.0

pi@raspberrypi:~/gree-hvac-mqtt-bridge $ node index.js --hvac-host="192.168.10.71" --mqtt-broker-url="mqtt://192.168.10.2:1883" --mqtt-topic-prefix="domoticz/in" --mqtt-username="" --mqtt-password=""
[MQTT] Connecting to mqtt://192.168.10.2:1883...
[MQTT] Connected to broker
[UDP] Connected to device at 192.168.10.71
[UDP] New device registered:
[UDP] Unknown message of type bindok: {
t: 'pack',
i: 1,
uid: 0,
cid: '',
tcid: 'app',
pack: 'FtZAY6UHKBwtaI55He0IneqJYxO3Vlz4+hb0PtbAybYXlqXCgDxwDeT3Y77VfVElYs+kEFxiRgA9LpeTA16TdA=='
}, { r: 200, t: 'bindok', mac: '', key: 'oxk22YP1uj0S97fd' }

...and then silence.
I think that "bindok" is referring to binding is ok, isn't it?

Installation help needed - Can't communicate with Gree

Hello,
Not an issue, but can't get it to work despite days of trying, reading all the issues in hopes for some clues. Everything seems to run fine, but no communication to the Gree/Crown unit. It seems that the bridge is communicating with the MQTT broker. The bridge also confirms it is connected to the GREE hvac host, but it seems to say that regardless of what IP address it is configured for.

Gree-MQTT Bridge Console:

pi@RPI:~/gree-hvac-mqtt-bridge $ node index.js \
>     --hvac-host="192.168.10.74" \
>     --mqtt-broker-url="mqtt://192.168.10.50" \
>     --mqtt-topic-prefix="home/greehvac" \
>     --mqtt-username="" \
>     --mqtt-password=""
[MQTT] Connecting to mqtt://192.168.10.50...
[MQTT] Connected to broker
[UDP] Connected to device at 192.168.10.74

The above is the only messages from the console, no error or progress, so I'm not sure if it's working.

I'm running Gree-MQTT bridge on a RPI with Node.js version 10.17.0 to a MQTT mosquito broker 1.5.8 on windows. All devices are on the same network and the older Gree G-Life app 1.1.0 for IOS works fine.

Mosquitto Console:

1573863194: New connection from 192.168.10.162 on port 1883.
1573863194: New client connected from 192.168.10.162 as mqttjs_f22da782 (c1, k60).
1573863194: No will message specified.
1573863194: Sending CONNACK to mqttjs_f22da782 (0, 0)
1573863226: Received PINGREQ from mosqsub|6872-CONTROL
1573863226: Sending PINGRESP to mosqsub|6872-CONTROL
1573863232: New connection from ::1 on port 1883.
1573863232: New client connected from ::1 as mosqpub|3800-CONTROL (c1, k60).
1573863232: No will message specified.
1573863232: Sending CONNACK to mosqpub|3800-CONTROL (0, 0)
1573863232: Received PUBLISH from mosqpub|3800-CONTROL (d0, q0, r0, m0, 'home/greehvac/mode/set', ... (3 bytes))
1573863232: Sending PUBLISH to mosqsub|6872-CONTROL (d0, q0, r0, m0, 'home/greehvac/mode/set', ... (3 bytes))
1573863232: Received DISCONNECT from mosqpub|3800-CONTROL
1573863232: Client mosqpub|3800-CONTROL disconnected.
1573863251: New connection from ::1 on port 1883.
1573863251: New client connected from ::1 as mosqpub|13948-CONTROL (c1, k60).
1573863251: No will message specified.
1573863251: Sending CONNACK to mosqpub|13948-CONTROL (0, 0)
1573863251: Received PUBLISH from mosqpub|13948-CONTROL (d0, q0, r0, m0, 'home/greehvac/power/set', ... (1 bytes))
1573863251: Sending PUBLISH to mosqsub|6872-CONTROL (d0, q0, r0, m0, 'home/greehvac/power/set', ... (1 bytes))
1573863251: Received DISCONNECT from mosqpub|13948-CONTROL
1573863251: Client mosqpub|13948-CONTROL disconnected.
1573863254: Received PINGREQ from mqttjs_f22da782
1573863254: Sending PINGRESP to mqttjs_f22da782 

Publish test commands with Mosquitto:

C:\Mos>mosquitto_pub -h localhost -t home/greehvac/mode/set -m "off"
C:\Mos>mosquitto_pub -h localhost -t home/greehvac/power/set -m 0

Unfortunately, I can't tell if the bridge is working or if there's a problem elsewhere. Is there a way to enable a "verbose" mode? I have been using the above mosquitto publish commands to test and see if the Gree reacts. In addition there seems to be no response to other publish/set commands or subscribe/get commands.

I'm sorry to ask for help here as I understand this is not a support forum, but I'm just not getting anywhere. If there were more logs or diagnostic messages I might be able to work it out, but I'm stuck. Any help would be most appreciated!

Can not set up to work in hassio (pi3)

I am trying to make this script to work on hassio on pi3.
But seams like gree air conditioner and this plugin can not work together :/

I get entites climate but when i change any settings gree does not recrive this comand.

This is script that i have instaled on hassio
CONFIG:

{ "hvac_host": "192.168.1.111", "mqtt": { "broker_url": "192.168.1.131:1883", "topic_prefix": "home/greehvac", "username": "homeassistant", "password": "hello" } }

`climate:

  • platform: mqtt

    Change to whatever you want

    name: Gree HVAC

    Change to what you've set in addon options

    current_temperature_topic: "home/greehvac/temperature/get"
    temperature_command_topic: "home/greehvac/temperature/set"
    temperature_state_topic: "home/greehvac/temperature/get"
    mode_state_topic: "home/greehvac/mode/get"
    mode_command_topic: "home/greehvac/mode/set"
    fan_mode_state_topic: "home/greehvac/fanspeed/get"
    fan_mode_command_topic: "home/greehvac/fanspeed/set"
    swing_mode_state_topic: "home/greehvac/swingvert/get"
    swing_mode_command_topic: "home/greehvac/swingvert/set"
    power_state_topic: "home/greehvac/power/get"
    power_command_topic: "home/greehvac/power/set"

    Keep the following as is

    payload_off: 0
    payload_on: 1
    modes:

    • "off"
    • "auto"
    • "cool"
    • "heat"
    • "dry"
    • "fan_only"
      swing_modes:
    • "default"
    • "full"
    • "fixedTop"
    • "fixedMidTop"
    • "fixedMid"
    • "fixedMidBottom"
    • "fixedBottom"
    • "swingBottom"
    • "swingMidBottom"
    • "swingMid"
    • "swingMidTop"
    • "swingTop"
      fan_modes:
    • "auto"
    • "low"
    • "mediumLow"
    • "medium"
    • "mediumHigh"
    • "high"
      `

Quiet mode fails

Hi there,

Gree-hvac-mqtt-bridge works fine, exept when putting the airco in quiet mode.
The next error message pops up in the app log:
afbeelding
curious to know whether it's me doing something wrong or a bug in het bridge?

Can't get it to work. Could use some advice

Hi,

First of all: sorry if this is the wrong place to create this topic.

I'm using hass.io (Raspberry Pi 3) for my Home Automation. I recently bought 2 AC's which support the Gree protocol.

Im trying to get your Module to work. I did the following things:

  1. Install your addon through Hass.io Addon System
  2. Set the settings to:
{
  "hvac_host": "192.168.2.24",
  "mqtt": {
    "broker_url": "mqtt://localhost",
    "topic_prefix": "home/greehvac"
  }
}

Note: 192.168.2.24 is the IP of one of my AC's
Also i'm assuming here that it will use the "embedded" Hassio MQTT broker

Last i added this config:

climate:
  - platform: mqtt

    # Change to whatever you want
    name: Zolderkamer HVAC

    # Change MQTT_TOPIC_PREFIX to what you've set in addon options
    current_temperature_topic: "home/greehvac/temperature/get"
    temperature_command_topic: "home/greehvac/temperature/set"
    temperature_state_topic: "home/greehvac/temperature/get"
    mode_state_topic: "home/greehvac/mode/get"
    mode_command_topic: "home/greehvac/mode/set"
    fan_mode_state_topic: "home/greehvac/fanspeed/get"
    fan_mode_command_topic: "home/greehvac/fanspeed/set"
    swing_mode_state_topic: "home/greehvac/swingvert/get"
    swing_mode_command_topic: "home/greehvac/swingvert/set"
    power_state_topic: "home/greehvac/power/get"
    power_command_topic: "home/greehvac/power/set"

    # Keep the following as is
    payload_off: 0
    payload_on: 1
    modes:
      - none
      - auto
      - cool
      - dry
      - fan
      - heat
    swing_modes:
      - default
      - full
      - fixedTop
      - fixedMidTop
      - fixedMid
      - fixedMidBottom
      - fixedBottom
      - swingBottom
      - swingMidBottom
      - swingMid
      - swingMidTop
      - swingTop
    fan_modes:
      - auto
      - low
      - mediumLow
      - medium
      - mediumHigh
      - high

With this first setup i do see the climate.zolderkamer_hvac, but it doesn't actually work.

The second thing i tried is install the Mosquitto broker from the Hass.io Addon system. Then started the Mosquitto broker and finally started your Gree Bridge Addon. In this setup I do not see the climate.zolderkamer_hvac at all.

EDIT: Using the second way I had to add the following to my config (I didn't read this before):

mqtt:
  broker: core-mosquitto

Still no luck though.

Am I missing something?

SwingHor Issue

Just updated to the latest version and it looks like it doesn't like that it can't find swinghor on my model

found 0 vulnerabilities
[MQTT] Connected to broker on mqtt://192.168.1.36
[UDP] Connected to device at 192.168.1.13
[UDP] New device registered: Office AC
[UDP] Device Office AC is bound!
/usr/src/app/index.js:33
    client.publish(mqttTopicPrefix + '/swinghor/get', commands.swingHor.value.getKeyByValue(deviceModel.props[commands.swingHor.code]).toString());
                                                                                                                                      ^
TypeError: Cannot read property 'toString' of undefined
    at Object.onStatus (/usr/src/app/index.js:33:135)
    at Device._handleResponse (/usr/src/app/app/deviceFactory.js:174:26)
    at Socket.Device.socket.on (/usr/src/app/app/deviceFactory.js:47:51)
    at emitTwo (events.js:126:13)
    at Socket.emit (events.js:214:7)
    at UDP.onMessage [as onmessage] (dgram.js:659:8)```

HVAC WiFI Config

Hi, Thanks for developing and sharing the code. I tried to run the wifi command on my macbook while connected to the AC in AP mode.

There was one problem initially when trying to run the nc command. I then realised that when copying the command from GitHub, the quotes are not in the right encoding. Notice the two different kinds of quotes in \”ssid\".

After I fixed that, something interesting happed.

This is what it returns:
{"t":"ret","r":200}

It then stays there with the cursor flashing.
Can you please write in the readme what the output for that command should be.

Regards,

Using an automation, climate always comes on a 20deg auto

I've been trying to automate the AC to pre-heat our living room in the morning, however, it always come on at 20deg Auto mode hear is my code.

- alias: Pre-heat Living Room initial_state: 'on' trigger: platform: time at: '05:45:00' action: - service: climate.set_temperature data: entity_id: climate.living_room_ac temperature: 18 operation_mode: Heat

Not sure if the issue is mqtt-bride, hassio, or possibly the thermostat control I have on my dashboard.

mqtt-bridge crashing when sending commands

Hi,

First of all I want to thank you guys for creating this integration. I have everything up and running and I can read values using my mqtt broker but I have a problem with the sending of the commands.

For some reasons (Unfortunally I'm not good in coding ...) the sending of the commands is working fine and the appliance is receiving the command and also excecuting it.

the problem is that the mqtt bridge is crashing with this output :

[UDP] New device registered: c6d18638
[UDP] Device c6d18638 is bound!
[MQTT] Message "1" received for home/greehvac/power/set
/sinclair/app/deviceFactory.js:178
this.device.props[opt] = pack.val[i]
^

TypeError: Cannot read properties of undefined (reading '0')
at /sinclair/app/deviceFactory.js:178:42
at Array.forEach ()
at Device._handleResponse (/sinclair/app/deviceFactory.js:177:16)
at Socket. (/sinclair/app/deviceFactory.js:45:47)
at Socket.emit (node:events:513:28)
at UDP.onMessage [as onmessage] (node:dgram:930:8)

So in the above example I'm just sending value 1 to turn the system on. The system is receiving this command and is also turning on but somewhere something is going wrong resulting in a crash and not accepting any commands anymore.

I allready tried to debug this myself but so far no luck. Any ideas ?

off command not working

Since you are doing message = message.toString(); when you do it will always translate to 1 (even if you send 0 from mqtt - because toString -> "0" and "0" ? 1 : 0 is 1 always

you need to change hvac.setPower(message) to hvac.setPower(parseInt(message)); in index.js

WiFi disconnected

Hello

I got the two a/c split disconnected from WiFi random if I use this tool.
Do you think is it possible?

Also: I know that on is no support.
Do you have any workaround?
My need is control via Google Home

Regards
Claudio

After HA restart the initial values not accessable

Issue

If the HA started later then the MQTT bridge we don't get the initial values. It's happening often when you touch to HA config files, and restart it because this. It would be great to somehow just load the current values of the climate, without setting a new one.

Temporary solution

To solve it, I added a small solution to my NodeRed, which restart this AddOn, but it's not too elegant. I have a MQTT message when HA started (based on a simple HA automatisation), I can catch that.

image

Extra functionality

Hello, the bridge works great so far but i'd like to see support for the extra AC functionality

Extra functionality includes:

  • Turbo
  • Air (Pulls air from outside)
  • Dry/X-Fan (Keeps the AC fan on for a few mins to dry the AC after running in cooling mode for a while)
  • Health (Enables the ioniser)
  • Power Saving (Not exactly sure what this does)

The people at OpenHAB have already made a binding with all the extras i've mentioned above

Forum link: https://community.openhab.org/t/new-gree-air-conditioner-binding/36429
OpenHAB Binding: https://github.com/jllcunha/openhab-greeair-binding/

Would be great if we could get this functionality on HA :)

Edit: i just realised that there's already a pull request for this functionality ( #13 ) but it hasn't been updated since 22 Jul

Gree VRF Support

Hi,

Tried the project but did not work for me and I am assuming it's because I have a Gree VRF system with 1 compressor and 4 internal units. They are exposed by a single IP.

I wiresharked the commans and what i foudn was that after the scan request {"t": "scan"} the JSON response has an extra field that seems to report how many internal units the unit has - the pack of the JSON return below:

{

			"t": "dev",
			"cid": "",
			"bc": "",
			"brand": "",
			"catalog": "",
			"mac": "b4430dd50fd2",
			"mid": "60",
			"model": "",
			"name": "格�空�",
			"lock": 0,
			"series": "",
			"vender": "",
			"ver": "",
			"subCnt": 4  (does this mean  it has 4 internal units)? seems to imply 
		}

The Gree Mobile App will then send the bind request as per the pack below:

{ "mac": "b4430dd50fd2",
"t": "bind",
"uid": 0
}

and return the unique key as per the below pack:

**{
			"r": 200,
			"t": "bindOk",
			"mac": "b4430dd50fd2",
			"key": "<UNIQUE KEY>"
		}**

The app then sends the JSON request below:

{"cid":"app","i":0,"pack":"huCTfZr+tmfrmjj5cppWoTuRTSHPH07rvUULx9II4CbtaD8c5Kb1s8De+taRtAFLGRthyav6ml/pLwGix91Arw==","t":"pack","tcid":"b4430dd50fd2","uid":1677840}

and the A/C responds with a JSON request with the pack below that clearly shows the 4 internal units that form part of the VRF.

**{
			"t": "subList",
			"c": 4,
			"i": 0,
			"list": [
				{
					"mac": "5259911b000000", 
					"name": "格�空�",
					"mid": "604b",
					"model": "",
					"lock": 0
				},
				{
					"mac": "fa7ad91a000000",
					"name": "格�空�",
					"mid": "604b",
					"model": "",
					"lock": 0
				},
				{
					"mac": "61fed31a000000",
					"name": "格�空�",
					"mid": "604b",
					"model": "",
					"lock": 0
				},
				{ 
					"mac": "dcecd31a000000", 
					"name": "格�空�",
					"mid": "604b",
					"model": "",
					"lock": 0
				}
			],
			"r": 200
		}**

From them on to get set command I will need to use the relevant mac of the sub ac for the A/C to work.

By any chance; are there any plans to support VRF systems? I would be happy to help with debugging etc. I don't use Home Assistant but can test via MQTT.

Thank you.

New Multiple ACs version, getting error

I've setup my 4 units, but I'm getting the following errors repeatedly at the moment. I get the feeling I'm missing a config or similiar.

[UDP] Device 1e4837fc is bound!
0|HVAC_0 | TypeError: Cannot read property 'toString' of undefined
0|HVAC_0 | at Object.onStatus (/usr/src/app/index.js:57:96)
0|HVAC_0 | at Device._handleResponse (/usr/src/app/app/deviceFactory.js:171:20)
0|HVAC_0 | at Socket.Device.socket.on (/usr/src/app/app/deviceFactory.js:45:47)
0|HVAC_0 | at Socket.emit (events.js:182:13)
0|HVAC_0 | at UDP.onMessage [as onmessage] (dgram.js:628:8)
0|HVAC_0 | [MQTT] Connecting to mqtt://192.168.1.3 as "local-user"...
0|HVAC_0 |

Here is my config

{ "mqtt": { "broker_url": "mqtt://192.168.1.3", "username": "local-user", "password": "xxxxxxxxxxx" }, "devices": [ { "hvac_host": "192.168.1.157", "mqtt_topic_prefix": "home/greehvacbedroomup" }, { "hvac_host": "192.168.1.97", "mqtt_topic_prefix": "home/greehvac-bedroom-down" }, { "hvac_host": "192.168.1.112", "mqtt_topic_prefix": "home/greehvac-kitchen" }, { "hvac_host": "192.168.1.83", "mqtt_topic_prefix": "home/greehvac" } ] }

Adding multiple ACs

Let me start by thanking you for this absolutely great add-on, which was my reason for buying Gree ACs. I have managed to add one of the ACs and it's working great, but I'm trying to figure out the configuration for adding three ACs ?

Your help is much appreciated..

Thanks,

Working with a dynamic IP address on the AC

My router appears to change the IP address for the AC after a reboot, my problem is that the add-on uses the ip address to identify the aircon, rather than a hostname (not sure the ac units have one) or a mac addresss.

My router doesn't allow me to allocate static ip addresses, can anyone suggest a solution?

template update configuration needed

configuration.yaml has:

# Change MQTT_TOPIC_PREFIX to what you've set in addon options

and addon configuration template is:

"mqtt": {
    "broker_url": "mqtt://localhost",
},
"devices": [
  {
    "hvac_host": "192.168.0.255",
    "mqtt_topic_prefix": "/home/hvac01"
  },
  {
    "hvac_host": "192.168.0.254",
    "mqtt_topic_prefix": "/home/hvac02"
  }
]

so if there are multiple devices, topic prefix is different for each device, so what should the global configuration prefix be?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.