MIELHVAC New features and bug fixes#24660
Merged
arendst merged 2 commits intoarendst:developmentfrom Apr 21, 2026
Merged
Conversation
## Changelog ### Bug Fixes **Memory leak in `miel_hvac_pre_init()`** — `goto del` jumped past the `free(sc)` label, leaking the allocated struct on serial init failure. Replaced with explicit `delete`/`free`/`return`. **`remotetemp_clear` semantics inverted** — variable was `true` on boot causing a CLR frame to be sent before any sensor registered. Renamed to `remotetemp_active`, initialised `false`. **`HVACSetPurify` used wrong map** — `airdirection_map` was passed instead of `purifier_map`. **`0x08` Set Run State flags wrong byte order** — flags are little-endian on the wire (ref: muart-group/muart-group.github.io#17). Removed `htons()` from all `0x08` flag assignments. **`widevane_isee` false positives** — values like `0x84`/`0x85`/`0x8c` (ISEE bit + position nibble) incorrectly reported `AirDirection:"even"`. Reverted to exact-match for `0x80`, `0x28`, `0xaa`. --- ### New Features **`0x42` HVAC Options polling** — added `miel_hvac_data_hvac_options` struct and `MIEL_HVAC_REQUEST_HVAC_OPTIONS` request. The unit is polled for Purifier, NightMode and EconoCool state. Requires short request form (len=1). Results stored in `sc_hvac_options` and published in SENSOR and HVACSETTINGS when `cap_run_state=true`. **Run State commands (`0x41 0x08`)** — new commands `HVACSetPurify`, `HVACSetNightMode`, `HVACSetEconoCool` and `HVACSetAirDirection` sent via `0x08` on units that report `cap_run_state=true`. Optimistic update to `sc_hvac_options` applied before confirmation. **EconoCool** — `0x08` byte 14, flag `0x10`, COOL mode only. Command `HVACSetEconoCool on|off`. **Base Capabilities (`0x5B 0xC9`)** — queried once after connecting. Parsed into `miel_hvac_capabilities`. Results published flat inside `MiElHVAC` as `*Supported` fields. Temperature ranges published as °C. Raw packet in `CapabilitiesHex`. **Capabilities-aware command validation** — commands blocked when unit reports feature unavailable: modes (heat/dry/fan), temperature range from capabilities, fan speeds, run state commands return `NotSupported` or `ControlNotSupported`. **`0x42` polling skip** — skipped on units with `cap_run_state=false`, eliminating recurring timeouts. **`miel_hvac_append_settings_json()`** — shared helper replacing ~80 lines of duplicated JSON code between SENSOR and HVACSETTINGS topics. --- ### JSON Changes - `Power` (W) and `Energy` (kWh) published inside `MiElHVAC` and also in a separate `ENERGY{}` object outside `MiElHVAC` for Home Assistant auto-discovery - `Purifier`, `NightMode`, `EconoCool` shown in SENSOR and HVACSETTINGS when `cap_run_state=true`; otherwise omitted - `AirDirection` always shows current state from `0x62 0x02` regardless of control support - `*Supported` capability fields published flat inside `MiElHVAC`: `HeatSupported`, `DrySupported`, `FanSupported`, `VaneVSupported`, `SwingSupported`, `AutoFanSupported`, `OutdoorTempSupported`, `AirDirectionSupported`, `PurifierSupported`, `NightModeSupported`, `EconoCoolSupported` --- ### Tested on MSZ-LN25VG2W — `cap_run_state=false`, temp ranges 16–31 °C cool/auto, 10–31 °C heat, 5 fan speeds.
### AirDirection — respect i-See sensor presence
`AirDirection` now requires three conditions instead of just the vertical vane capability:
- `cap_vane_v` — unit has a vertical vane
- `sc_has_isee` — i-See sensor observed at runtime (widevane ever seen with bit `0x80`, or value `0x28`/`0xaa`)
- `cap_run_state` — unit supports `0x08` for control
Resulting behaviour:
| `cap_vane_v` | `sc_has_isee` | `cap_run_state` | `AirDirection` visible | `AirDirectionSupported` |
|:-:|:-:|:-:|:-:|:-:|
| ❌ | — | — | hidden | `not_supported` |
| ✅ | ❌ | — | hidden | `not_supported` |
| ✅ | ✅ | ❌ | shown | `control_not_supported` |
| ✅ | ✅ | ✅ | shown | `on` |
Units with vertical + horizontal vanes but no i-See sensor now correctly report `AirDirectionSupported:"not_supported"` and omit `AirDirection` from both `MiElHVAC` and `HVACSettings` JSON.
### Capability field renames
For naming consistency across the `*Supported` fields:
- `cap_heat` → `cap_mode_heat`, `HeatSupported` → `ModeHeatSupported`
- `cap_dry` → `cap_mode_dry`, `DrySupported` → `ModeDrySupported`
- `cap_fan_mode` → `cap_mode_fan`, `FanSupported` → `ModeFanSupported`
- `cap_auto_fan` → `cap_fan_auto`, `AutoFanSupported` → `FanAutoSupported`
- `OutdoorTempSupported` → `OutdoorTemperatureSupported`
- `TempCool` / `TempHeat` / `TempAuto` → `SetTemperatureCoolMinMax` / `SetTemperatureHeatMinMax` / `SetTemperatureAutoMinMax`
### Energy values
- `Power` (W) and `Energy` (kWh) published both inside `MiElHVAC` and in a standard Tasmota `ENERGY{}` sub-object (`Power`/`Total`) for Home Assistant auto-discovery.
- Added Web UI rows via `FUNC_WEB_SENSOR` showing instantaneous power (W) and cumulative total (kWh) on the Tasmota main page.
### Runtime i-See detection
New `sc_has_isee` flag in `miel_hvac_softc`, set in `miel_hvac_input_settings` on the first widevane value indicating i-See state. Once set, stays set for the session.
**Practical note:** after boot, the flag starts `false`. Units with i-See that has never been activated since Tasmota started will show `AirDirection` as hidden until i-See is first used (via IR remote or `HVACSetAirDirection`). Safe default — prevents showing misleading values on units without i-See.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Fixes
Memory leak in
miel_hvac_pre_init()— on serial init failure,goto deljumped pastfree(sc), leaking the allocated state struct. Replaced with explicitdelete sc->sc_serial; free(sc); return;.remotetemp_clearsemantics inverted — the variable was initialisedtrueand caused a CLR frame to be sent on boot before any sensor had registered. Renamed toremotetemp_active, initialisedfalse, and CLR is only sent after an active SET.HVACSetPurifyused wrong map — was passingairdirection_mapinstead ofpurifier_map.0x08Set Run State flags byte order — flags are little-endian on the wire (ref: muart-group/muart-group.github.io#17). Removedhtons()from all0x08flag operations.widevane_iseefalse positives — values like0x84/0x85/0x8c(ISEE bit + physical position nibble) were incorrectly reported asAirDirection:"even". Reverted to exact-match for known active values (0x80,0x28,0xaa).New Features
Base Capabilities query (
0x5B 0xC9) — after connecting, the driver sends an Identify Request and parses the0x7B 0xC9response into a capability struct. Exposed as*Supportedfields in theMiElHVACJSON object.HVAC Options polling (
0x42) — newmiel_hvac_data_hvac_optionsstruct and request type. Polls Purifier, NightMode and EconoCool state. Sent withlen=1(short request form). Units withoutcap_run_stateskip this slot entirely to avoid timeouts.Run State commands (
0x41 0x08) — addedHVACSetPurify,HVACSetNightMode,HVACSetEconoCoolandHVACSetAirDirectionrouted through command0x08on units that reportcap_run_state=true. Optimistic local update applied before confirmation.EconoCool —
0x08byte 14, flag0x10, COOL mode only. CommandHVACSetEconoCool on|off.i-See runtime detection — new
sc_has_iseeflag set when widevane shows i-See state (0x80bit or values0x28/0xaa). Used to distinguish units with vertical vane + i-See from units with vane only.Capabilities-aware command validation — commands are blocked before send when the unit reports a feature unavailable:
HVACSetMode/HVACSetHAMode— blocks heat/dry/fan when unsupported (ISEE variants share parent mode bit)HVACSetTemp— narrows range using unit-reported min/max per modeHVACSetFanSpeed— blocks AUTO withoutcap_fan_auto, QUIET without 5 speeds, FAN_4 without 4 speedsHVACSetPurify/HVACSetNightMode/HVACSetEconoCool— returnNotSupportedwithoutcap_run_stateHVACSetAirDirection— returnsControlNotSupportedwhen vane+i-See present but no run stateWeb UI rows for Power and Energy — added
FUNC_WEB_SENSORhandler viaWSContentSend_PDshowing instantaneous power (W) and cumulative total (kWh) on the Tasmota main page.miel_hvac_append_settings_json()— shared JSON builder used by bothHVACSETTINGSandSENSORtopics.JSON Changes
Power(W) andEnergy(kWh) now published both insideMiElHVACand in a standard TasmotaENERGY{}sub-object (Power/Total) for Home Assistant auto-discovery.Purifier,NightMode,EconoCoolshown inMiElHVACandHVACSettingswhencap_run_state=true, otherwise omitted.AirDirectionhidden fromMiElHVACandHVACSettingswhen the unit lacks a vertical vane or has no observed i-See sensor.MiElHVACfrom Base Capabilities:ModeHeatSupported,ModeDrySupported,ModeFanSupported,VaneVSupported,SwingSupported,FanAutoSupported,OutdoorTemperatureSupported,AirDirectionSupported,PurifierSupported,NightModeSupported,EconoCoolSupported,SetTemperatureCoolMinMax,SetTemperatureHeatMinMax,SetTemperatureAutoMinMax,CapabilitiesHex.on/off/not_supported/control_not_supported.AirDirectionSupportedreports:not_supported— no vertical vane, or no i-See observedcontrol_not_supported— vane + i-See present but unit does not support0x08Set Run Stateon— full supportOptionsHexadded for the0x42HVAC Options packet.Tested on
MSZ-LN25VG2W —
cap_run_state=false, temperature ranges 16–31 °C (cool/auto) and 10–31 °C (heat), 5 fan speeds, outdoor temperature reporting confirmed.Checklist:
NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass