Skip to content

Add Midea C3 heat pump (0xC3) support with SmartHomeCloud relay#262

Open
xelhark wants to merge 7 commits into
mill1000:mainfrom
xelhark:feature/c3_heatpump
Open

Add Midea C3 heat pump (0xC3) support with SmartHomeCloud relay#262
xelhark wants to merge 7 commits into
mill1000:mainfrom
xelhark:feature/c3_heatpump

Conversation

@xelhark

@xelhark xelhark commented May 21, 2026

Copy link
Copy Markdown

Summary

  • Add DeviceType.HEAT_PUMP = 0xC3 to const.py
  • Add HeatPump device class (device/C3/) with zone1/zone2, run modes (HEAT/COOL/AUTO/DHW), and full query/control command parsing
  • Add SmartHomeCloud class with cloud relay support (appliance_transparent_send) — C3 devices use cloud relay because LAN V3 auth returns error 3004
  • Route commands through cloud relay in base_device._send_command when a cloud instance is set (set_cloud())
  • Add Device.construct() support for DeviceType.HEAT_PUMP
  • Add Discover.probe_device_info(host) for ID-less discovery (sends UDP probe, returns device info without authenticating — needed since C3 uses SmartHomeCloud not NetHomePlusCloud)
  • Stable pushToken (derived from account hash) to avoid "new device" push notifications on re-login
  • Silent auto-re-login in appliance_transparent_send on token expiry (codes 3105/3106/3301/3001)

Notes

  • C3 devices respond to UDP discovery but require SmartHomeCloud credentials (MSmartHome account), not NetHomePlusCloud
  • QueryUnitParametersCommand returns error 3176 ("async reply") via cloud relay — outdoor temperature and power sensors are currently unavailable via this path
  • Java-style signed bytes in relay CSV decoded correctly with & 0xFF

Test plan

  • Tested against a real Midea C3 device (device_id=42880953506840) via cloud relay
  • device.refresh() returns correct zone power state, target temperature, and run mode
  • device.apply() sends control commands successfully via relay
  • UDP probe_device_info() correctly extracts device ID without authentication
  • Token expiry handled transparently with silent re-login

🤖 Generated with Claude Code

xelhark and others added 7 commits May 21, 2026 16:46
- Add DeviceType.HEAT_PUMP = 0xC3 to const.py
- Add msmart/device/C3/ with HeatPump device class, commands and responses
- Add proxy-compatible flat properties (zone1_power_state, zone1_target_temperature, etc.)
- Add cloud relay to SmartHomeCloud: appliance_transparent_send, relay encryption
- Add set_cloud() to base Device; _send_command routes through cloud relay when set
- Add cloud relay fallback in Discover._authenticate_device (after LAN auth failure)
- Add Device.construct support for HEAT_PUMP type
- Add CLI 'heatpump' subcommand for heat pump control with --id bypass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rer token

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lay response

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ate, unit params

- Fix decode_from_csv to handle Java signed bytes (& 0xFF mask)
- Fix Frame.validate call to pass DeviceType.HEAT_PUMP
- Fix tank_temperature: treat values >= 0xF0 as None (error/not-connected codes)
- Add QueryUnitParametersCommand to refresh() for outdoor temp (fails gracefully via relay)
- Fix CLI heatpump --id path to use SmartHomeCloud directly
- Fix Discover._get_async_client not set in CLI --id path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ations on re-login

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When transparent/send fails with auth error codes (3105, 3106, 3301, 3001),
silently call login(force=True) and retry. The pushToken is stable (derived
from account hash) so re-login does not register a new device on the server
and avoids triggering push notifications.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mill1000

Copy link
Copy Markdown
Owner

Thanks for the PR. I'll appreciate the contribution.

I am interested in supporting additional climate device types, but I do not want to integrate additional cloud connectivity. The project is supposed to be for local control to which adding a cloud relay is antithetical.

So it is unlikely I will merge this PR as is.

A possible alternative, the cloud relay could be removed and stood up as a dedicated service that bridges between msmart-ng and your device. As far as msmart-ng would know, its just another device. The relay could even respond to discovery packets making the integration into HA pretty seamless. By using the "V2" packet format any need for key & token between msmart-ng and the relay is eliminated too.

flowchart LR
  A[msmart-ng] <-- UDP --> B
  B[cloud-relay] <-->
  C[Cloud]@{ shape: cloud }
  C <--> D[Device]
Loading

Happy to discuss.

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