Skip to content

Fix hybrid Gree firmware bind and protocol version detection - #13

Open
rasmusbe wants to merge 3 commits into
anaryk:mainfrom
rasmusbe:fix/hybrid-gree-v2-bind-handshake
Open

Fix hybrid Gree firmware bind and protocol version detection#13
rasmusbe wants to merge 3 commits into
anaryk:mainfrom
rasmusbe:fix/hybrid-gree-v2-bind-handshake

Conversation

@rasmusbe

@rasmusbe rasmusbe commented May 29, 2026

Copy link
Copy Markdown

Summary

  • Align V1 bind wire format with greeclimate (tcid, JSON serialization) so encrypted packets match what Gree firmware expects.
  • Add scan_then_bind() on a single UDP session with V1→V2 fallback when bind times out — required for units that reply to scan with a V1-style envelope but only accept bind over AES-GCM (same behaviour as the official Gree integration).
  • Auto-detect and persist protocol_version on encrypted traffic — if status/cmd fails on the stored version (timeout or decrypt error), retry the alternate version and write the working one back to the config entry. Existing integrations upgrade without remove/re-add.
  • Extend tools/probe.py with --bind for standalone setup debugging; fix config-flow error mapping and test fixtures.

Context

Reported setup failure: discovery finds the device, then "Could not reach the device on the supplied IP". Tested against a Gree V3.4.M unit at 192.168.50.196 — scan succeeds, V1 bind times out (~10s), V2 bind returns bindok. Official HA Gree integration works on the same hardware.

Hybrid units also require V2 for all post-bind encrypted traffic (status, commands). Config entries created before this fix may store protocol_version: 1 from the V1 scan envelope; the auto-fallback corrects that on the first successful poll.

Test plan

  • pytest tests/ — 43 passed (includes protocol-version fallback unit test)
  • python tools/probe.py <ip> --bind — V1 timeout then V2 bind OK on live Gree unit
  • EwpeDevice.bind() + get_status() against live device after fix
  • Add integration via HA config flow (discover + manual IP) on affected hardware
  • Existing config entry with stored v1 auto-upgrades to v2 after reload (no re-add)

rasmusbe added 2 commits May 29, 2026 08:34
Some units reply to discovery with a V1-style envelope but only accept bind
over AES-GCM. Match greeclimate by aligning wire-format details and falling
back from V1 to V2 bind on the same UDP session.
Retry encrypted requests on the alternate protocol version when the
stored version times out or fails to decrypt, then write the working
version back to the config entry so existing setups upgrade without
re-adding the device.
@rasmusbe rasmusbe changed the title Fix bind handshake for hybrid Gree firmware (V1 scan, V2 bind) Fix hybrid Gree firmware bind and protocol version detection May 30, 2026
Some Gree units return opt/p on res packets instead of opt/val,
which caused set_state to fail after a successful command.
@neobernad

Copy link
Copy Markdown

I am currently having this issue "Could not reach the device on the supplied IP" with modern Daitsu ACs. Bumping due to interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants