1.0.0-beta.7 • Published 1 year ago

homebridge-gree-ac-adapter v1.0.0-beta.7

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

Homebridge Gree AC Adapter

Features

  • Turning the Gree AC on or off
  • Mode setting
  • Temperature units setting
  • Target temperature setting
  • Current temperature display
  • Setting the wind speed (setting it to 0, sets the AC to Auto; can only be set if both Quiet and Turbo are off)
  • Setting the wind direction (switching from predefined fixed to predefined swinging and vice versa, both based on the current operating mode)
  • Turning Quiet on or off (setting Quiet to on, sets Turbo to off, if it is set to on)
  • Turning Turbo on or off (setting Turbo to on, sets Quiet to off, if it is set to on; can only be set to on if the current operating mode is not Heat)
  • Turning Light on or off
  • Turning X-Fan on or off
  • Turning Sleep on or off
  • Turning Health on or off

Configuration

For an easier configuration process, check out Homebridge Config UI X. If you do not wish to use the previous method of configuring the plugin, you must manually edit the config.json file. The following table shows the necessary properties, along with their recommended values and a short description of what the property is for.

KeyDefaultDescription
port7000Port used for communicating with the device.
scanPort7000Port used for scanning for devices.
scanAddressThe IPv4 address to be used for local network device scanning.
scanInterval1000Time in milliseconds between two consecutive scans.
scanMaxRetries3Maximum number of retries before stopping the scan process.
refreshInterval1000Time in milliseconds between device` status update requests.
debugfalse

Limitations

  • Because there are not supported by HAP Specification, the following modes are not available: Dry, Fan
  • Temperature display units only affects and reflects the display and operating units on the device. HAP Specification clearly stands: "Celsius is the only temperature unit in the HomeKit Accessory Protocol. Unit conversion is always done on the client side e.g. on the iPhone in the Home App depending on the configured unit on the device itself."
  • HAP Specification doesn't offer a way for fine-tuning the swinging (as the Gree remote and app do). Swing mode only describes if swinging is enabled or disabled. Such, predefined settings are used for both values of this characteristic, these predefined settings being adapted to the current operating mode.
  • Turbo cannot be turned on if the current operating mode is Heat. This is a constraint of the Gree Air Conditioner itself.

Gree Air Conditioner API

There are 2 message types for the communication between the implemented application and the Gree device: 1. scan 2. pack

There are 4 request types which can be sent to the Gree device: 1. scan 2. bind 3. status 4. cmd

There are 4 response types which can be received from the Gree device: 1. dev 2. bindok 3. dat 4. res

Each line in the following table shows the corresponding response type for each request type along with their associated individual message types (request message type and response message type):

RequestMessage TypeRequestTypeResponseMessage TypeResponseType
scanscanpackdev
packbindpackbindok
packstatuspackdat
packcmdpackres

Scanning for devices

  • request (sent as a broadcast message to the local network)
{
  "t": "scan"
}
  • response
{
  "t":    "pack",
  "i":    1,
  "uid":  0,
  "cid":  "<MAC>",
  "tcid": "",
  "pack": {
    "t":       "dev",
    "bc":      "gree",
    "brand":   "gree",
    "catalog": "gree",
    "cid":     "<MAC>",
    "mac":     "<MAC>",
    "mid":     "10001",
    "model":   "gree",
    "name":    "<FRIENDLY NAME>",
    "series":  "gree",
    "vendor":  "1",
    "ver":     "<VERSION>",
    "lock":    0
  }
}

Binding to a device

  • request
{
  "t":    "pack",
  "i":    1,
  "uid":  0,
  "cid":  "app",
  "tcid": "<MAC>",
  "pack": {
    "t":   "bind",
    "uid": 0,
    "mac": "<MAC>"
  }
}
  • response
{
  "t":    "pack",
  "i":    1,
  "uid":  0,
  "cid":  "<MAC>",
  "tcid": "app",
  "pack": {
    "r":   200,
    "t":   "bindok",
    "mac": "<MAC>",
    "key": "<KEY>"
  }
}

Requesting the status of a device

  • request
{
  "t":    "pack",
  "i":    0,
  "uid":  0,
  "cid":  "app",
  "tcid": "<MAC>",
  "pack": {
    "t":    "status",
    "mac":  "<MAC>",
    "cols": [
      "Pow",
      "Mod",
      "SetTem",
      "TemRec",
      "TemUn",
      "WdSpd",
      "SwingLfRig",
      "SwUpDn",
      "Blo",
      "Health",
      "Lig",
      "SwhSlp",
      "Quiet",
      "Tur",
      "StHt",
      "SvSt",
      "HeatCoolType"
    ]
  }
}
  • response
{
  "t":    "pack",
  "i":    0,
  "uid":  0,
  "cid":  "<MAC>",
  "tcid": "",
  "pack": {
    "r":    200,
    "t":    "dat",
    "mac":  "<MAC>",
    "cols": [
      "Pow",
      "Mod",
      "SetTem",
      "TemRec",
      "TemUn",
      "WdSpd",
      "SwingLfRig",
      "SwUpDn",
      "Blo",
      "Health",
      "Lig",
      "SwhSlp",
      "Quiet",
      "Tur",
      "StHt",
      "SvSt",
      "HeatCoolType"
    ],
    "dat":  [1, 1, 25, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]
  }
}

Sending commands to a device

  • request
{
  "t":    "pack",
  "i":    0,
  "uid":  0,
  "cid":  "app",
  "tcid": "<MAC>",
  "pack": {
    "t":   "cmd",
    "opt": ["Pow", "Mod", "SetTem", "WdSpd"],
    "p":   [1, 0, 27, 0]
  }
}
  • response
{
  "t":    "pack",
  "i":    0,
  "uid":  0,
  "cid":  "<MAC>",
  "tcid": "",
  "pack": {
    "r":   200,
    "t":   "res",
    "mac": "<MAC>",
    "opt": ["Pow", "Mod", "SetTem", "WdSpd"],
    "val": [1, 0, 27, 0],
    "p":   [1, 0, 27, 0]
  }
}

Sending the target temperature in Fahrenheit

Fahrenheit (F)Celsius (C)TemSetTemRec
6116.1161
6216.7170
6317.2171
6417.8180
6518.3181
6618.9190
6719.4191
6820.0201
6920.6210
7021.1211
7121.7220
7222.2221
7322.8230
7423.3231
7523.9240
7624.4241
7725.0251
7825.6260
7926.1261
8026.7270
8127.2271
8227.8280
8328.3281
8428.9290
8529.4291
8630.0301

C = (F - 32.0) / 1.8
TemSet = round(C)
TemRec = (C - TemSet) < 0 ? 0 : 1


Reading the target temperature in Fahrenheit

TemSetTemRecFahrenheit (F1)Fahrenheit (F2)
16160.861
17062.662
17162.663
18064.464
18164.465
19066.266
19166.267
2016868
21069.869
21169.870
22071.671
22171.672
23073.473
23173.474
24075.275
24175.276
2517777
26078.878
26178.879
27080.680
27180.681
28082.482
28182.483
29084.284
29184.285
3018686

F1 = TemSet * 1.8 + 32
F2 = (F1 % 1 == 0) ? F1 : (floor(F1) + TemRec)