feat: gateway sub-device discovery (VRF / multi-split support) - #148
feat: gateway sub-device discovery (VRF / multi-split support)#148meirlo wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #148 +/- ##
==========================================
+ Coverage 95.71% 96.57% +0.85%
==========================================
Files 8 8
Lines 770 846 +76
==========================================
+ Hits 737 817 +80
+ Misses 33 29 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@cmroche when you have a moment, could you take a look at this PR? 🙏 This adds VRF / multi-split support (multiple indoor units behind a single Wi-Fi gateway), which a lot of people have been waiting for — it comes up regularly in issues and in the Home Assistant community. A few things that should make review easier:
Happy to make any changes you'd like. Thanks for maintaining this library! |
Adds support for Gree gateway modules that front multiple indoor units (VRF / multi-split systems). Each indoor unit is surfaced as a regular DeviceInfo and flows through the existing Discovery -> Device pipeline, so consumers get one device per indoor unit with no API changes required. Protocol (network.py) - Add subList command/response and create_sublist_message - Add handle_sublist_response and resolve response type from a top-level 't' field (subList replies place it outside the pack) - Make the packet handler registry per-instance. A gateway, its sub-devices and any standalone units coexist as separate DeviceProtocol2 instances; a shared class-level dict cross-dispatched callbacks between them and broke bind/state handling. Device (device.py) - Add get_sub_devices() to enumerate a gateway's indoor units via subList - bind() auto-inherits the gateway's key and cipher from DeviceInfo, so a sub-device binds without a separate handshake - target_temperature: tolerate a missing/None/'' TemRec (sub-devices and command acknowledgements omit the 0.5-degree bit); default it to 0 instead of dropping the whole setpoint - Harden temperature/version parsing against non-numeric values Discovery (discovery.py) - Parse subCnt; auto-query gateways for sub-devices during scan() - Add include_gateways flag (default False) to hide the gateway shell DeviceInfo (deviceinfo.py) - Add sub_count, plus gateway_key and gateway_cipher (the parent gateway's bound key and live cipher instance) so a sub-device reuses the session All new parameters are optional and keyword-only; existing callers are unaffected.
|
Closes #101 (which contains the maintainer's own protocol notes for Also relevant: #172 addresses mixed-case |
Summary
Adds support for Gree gateway modules that front multiple indoor units (VRF / multi-split systems). A single Wi-Fi gateway exposes several indoor units, each addressed by its own internal MAC inside the encrypted
packwhile all traffic is routed to the gateway MAC.With this change, each indoor unit is discovered and surfaced as an ordinary
DeviceInfo, so it flows through the existingDiscovery -> Devicepipeline and can be controlled independently — no API changes are required for existing consumers, and downstream integrations (e.g. Home Assistant) get one device per indoor unit without any integration-side changes.Closes the "multiple units behind a single Wi-Fi controller" request.
How it works
scan(), a gateway is identified bysubCnt > 0in its discovery response.subListquery, which returns the list of indoor units (each with its own internal MAC).DeviceInfocarrying the gateway's key/cipher, so it binds by reusing the gateway session (no separate handshake).pack, while the packet is routed to the gateway MAC.Changes
Protocol (
network.py)subListcommand/response andcreate_sublist_message.handle_sublist_response; resolve the response type from a top-leveltfield (subList replies place it outside thepack).DeviceProtocol2instances; the previous shared class-level dict cross-dispatched callbacks between them and broke bind/state handling once more than one device existed.Device (
device.py)get_sub_devices()to enumerate a gateway's indoor units viasubList.bind()auto-inherits the gateway's key and cipher fromDeviceInfo.target_temperature: tolerate a missing /None/""TemRec. Sub-devices and command acknowledgements omit the 0.5° rounding bit; default it to0instead of dropping the whole setpoint.Discovery (
discovery.py)subCnt; auto-query gateways for their sub-devices duringscan().include_gatewaysflag (defaultFalse) so the gateway "shell" isn't surfaced as a device.Device info (
deviceinfo.py)sub_count, plusgateway_keyandgateway_cipher(the parent gateway's bound key and live cipher instance) so a sub-device reuses the session.All new parameters are optional and keyword-only; existing callers are unaffected.
Tests
get_sub_devices()success and timeout paths.target_temperaturesurviving a missing/NoneTemRec.subCntparsing, gateway querying, and theinclude_gatewaysflag.Notes
greeclimateversion bump in the integration'smanifest.jsononce released.