arthurkrupa / gree-hvac-mqtt-bridge

MQTT Bridge for controlling Gree smart air conditioners, e.g. with Home Assistant or OpenHAB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

RobHofmann opened this issue · comments

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?

There are a couple problems with your config, which result in no communication between the 3 components (Gree addon, MQTT broker, Hass.io).

You need to have a working MQTT broker with anonymous access. You can use the Hass.io Mosquitto Broker addon for that. For initial testing, try to use this minimal config:

{
  "plain": true,
  "ssl": false,
  "anonymous": true,
  "logins": [],
  "customize": {
    "active": false,
    "folder": "mosquitto"
  }
}

Next, change the MQTT config in your Hass.io configuration.yaml to this:

mqtt:
  broker: localhost
  port: 1883
  client_id: hassio
  keepalive: 60

Finally, put this in the Gree addon config (replace with correct IPs):

{
  "hvac_host": "YOUR.HVAC.IP.HERE",
  "mqtt": {
    "broker_url": "mqtt://YOUR.HASSIO.IP.HERE"
    "topic_prefix": "home/greehvac"
  }
}

EDIT: It worked!
I'm not going to delete the post as someone might find the configuration below useful but it seems that a restart of the plugin did the trick. I restarted hassio before that many times but... idk.. something ticked this time.
In meantime I installed mqttlens and was able to see the mqtt messages going to the proper queues.

---original post---
I feel bad for writing about it here but I too can't get this to work and not much shows up googling it.
In hassio on a raspberry pi 3 I installed this plugin and Mosquitto. I currently have the configuration as down below. Only thing I'm not so sure about is the "Configuring HVAC WiFi" from the README.md steps. I have the AC configured trough the gree app. I did not run the command:
echo -n "{"psw": "YOUR_WIFI_PASSWORD","ssid": "YOUR_WIFI_SSID","t": "wlan"}" | nc -cu 192.168.1.1 7000
Not sure if this has any effect. I can put the AC in AP mode but hassio on rpi connects to the network via ethernet, and I simply can't think of a way to follow this step trough.

192.168.31.217 is the IP of hassio and Mosquitto on my LAN
192.168.31.214 is the IP of my AC

Gree HVAC MQTT bridge log:

added 61 packages in 11.643s
[MQTT] Connected to broker on mqtt://192.168.31.217
[UDP] Connected to device at 192.168.31.214

Looks to me that the Gree HVAC MQTT bridge successfully connected to both the AC and MQTT broker.
In hassio if I go to services(in the developer tools), I see the climate.xxxx services listed there but when I try to call any of them, nothing happens. i.e.
service: climate.set_swing_mode
entity: climate.gree_hvac
service data:

{
  "entity_id": "climate.gree_hvac",
"swing_mode":"fixedBottom"
}

I've tried almost all: temperature, on, off, fan mode... but none worked.

I would be grateful if anyone can point me to a way of troubleshooting the issue (any more logs I can look at?).

configuration.yaml

mqtt:
  broker: localhost
  port: 1883
  client_id: hassio
  keepalive: 60

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: "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

MQTT broker plugin settings:

{
  "plain": true,
  "plain_websockets": false,
  "ssl": false,
  "ssl_websockets": false,
  "anonymous": true,
  "logins": [],
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
}

Gree HVAC MQTT bridge settings:

{
  "hvac_host": "192.168.31.214",
  "mqtt": {
    "broker_url": "mqtt://192.168.31.217",
    "topic_prefix": "home/greehvac"
  }
}

@alshark It looks like the connection itself is working, but nothing beyond that. I wonder if your AC could use a different protocol...

What should happen is as follows:

  1. Establish a socket connection with the HVAC (this works)
  2. The HVAC should answer with a response (this probably doesn't happen)
  3. The response should trigger a binding request.

If you know any JS, I'd suggest you run the service locally in Docker (see Readme). Then you can easily debug the messages (e.g. by placing more console.log() inside app/deviceFactory.js ).

BTW could you give me the exact model of your AC? I want to add a list of supported/unsupported devices to the Readme.

@arthurkrupa now everything seems to be working fine. I didn't do anything special, just restarted the plugin in hassio(without completely restarting hassio this time) and all started working just fine.

Regarding the AC model, it is marketed as Hansol -20 in my country. Model number: GWH12TB-S3DNA2D.

What I can confirm works is setting the mode, setting temperature, set fan speed, fan swing. Probably the rest works fine as well but I havn't had the chance to test it.

@arthurkrupa I fixed the issue writing my own HomeAssistant component from scratch. I took out the MQTT component to simplify the setup.

If you want to see, its located here:
https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent

Thanks for helping out. In the end i didn't get it to work with your component.

PS. Don't be to hard on me, its my first Python script ever :)

I have done all that has been done but i always get error like this.
I have mqtt on which i can log in without username and password

added 61 packages from 47 contributors and audited 208 packages in 10.537s
found 0 vulnerabilities
events.js:167
      throw er; // Unhandled 'error' event
      ^
Error: Connection refused: Not authorized
    at MqttClient._handleConnack (/usr/src/app/node_modules/mqtt/lib/client.js:871:15)
    at MqttClient._handlePacket (/usr/src/app/node_modules/mqtt/lib/client.js:319:12)
    at work (/usr/src/app/node_modules/mqtt/lib/client.js:261:12)
    at Writable.writable._write (/usr/src/app/node_modules/mqtt/lib/client.js:271:5)
    at doWrite (/usr/src/app/node_modules/readable-stream/lib/_stream_writable.js:406:64)
    at writeOrBuffer (/usr/src/app/node_modules/readable-stream/lib/_stream_writable.js:395:5)
    at Writable.write (/usr/src/app/node_modules/readable-stream/lib/_stream_writable.js:322:11)
    at Socket.ondata (_stream_readable.js:666:20)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
Emitted 'error' event at:
    at MqttClient._handleConnack (/usr/src/app/node_modules/mqtt/lib/client.js:873:10)
    at MqttClient._handlePacket (/usr/src/app/node_modules/mqtt/lib/client.js:319:12)
    [... lines matching original stack trace ...]
    at addChunk (_stream_readable.js:283:12)