After restarting Home Assistant, the AC entity correctly restores its previous state (e.g. HEAT mode at a given temperature).
However, changing any setting (temperature, fan speed, or swing mode) caused the device to switch back to AUTO mode.
Root cause
The settings command was being sent with partially initialized parameters after a restart.
When only a single value (e.g. temperature) was updated, other parameters such as machMode and onOffStatus were implicitly sent with their default values, which for many devices means AUTO mode.
Solution
Before sending the settings command, the current machMode and onOffStatus are now explicitly copied from the device state into the command parameters.
This ensures that changing temperature, fan mode, or swing mode does not unintentionally reset the HVAC mode.
Result
The AC keeps the selected HVAC mode (HEAT/COOL/etc.) after a Home Assistant restart.
Updating temperature, fan speed, or swing no longer forces the device back to AUTO.
No change in behavior when explicitly changing HVAC mode or presets.
Add a new binary sensor to monitor the defrost status of air conditioning
units. The sensor uses the 'defrostStatus' key and displays when the AC
is in defrost mode with a snowflake-melt icon.
This PR introduces a new binary sensor for Haier ovens based on the preheatStatus attribute. While implementing this feature, I discovered that the integration does not correctly evaluate certain appliance attributes, which caused binary sensors to always report off even when the underlying value indicated they should be on.
Issue Identified
Attributes such as preheatStatus and onOffStatus are not returned as raw integers. Instead, the integration receives them as HonAttribute objects. Because the existing logic compares the object itself directly against the expected value, the expression value == on_value always evaluates to False.
Fix Implemented
To ensure proper evaluation, the binary sensor logic has been updated so that when an attribute is a HonAttribute instance, the sensor extracts its actual value using:
value = attr.value if hasattr(attr, "value") else attr
This fix has been applied to both:
is_on()
_handle_coordinator_update()
As a result, the newly added preheatStatus sensor works correctly, and the previously existing onOffStatus binary sensor now functions reliably as well.
Potential Impact on Other Sensors
This change may also correct the behavior of other binary sensors that rely on attributes following the same pattern. I cannot verify all of them because I only have access to a single Haier oven, but the patch is safe, backward-compatible, and should improve the accuracy of any affected entities.