hOn/custom_components/hon
danyrd92 e01d19efd6
Add Preheat Binary Sensor for Ovens + Fix Attribute Handling for Binary Sensors (#17)
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.
2025-12-16 17:37:03 +01:00
..
translations Update translations 2024-03-17 21:52:54 +01:00
__init__.py Fix incompatibility with HA 2025.6 2025-06-26 01:00:29 +02:00
binary_sensor.py Add Preheat Binary Sensor for Ovens + Fix Attribute Handling for Binary Sensors (#17) 2025-12-16 17:37:03 +01:00
button.py Fix HomeAssistantType deprecation warning 2025-06-26 00:59:54 +02:00
climate.py Fix error message appearing when turning off AC unit. 2025-09-29 13:14:12 +02:00
config_flow.py Fix mypy errors 2023-11-20 16:39:33 +01:00
const.py Change poll to push 2024-03-25 02:26:20 +01:00
entity.py Fix automatic updates of entities 2025-06-26 01:02:47 +02:00
fan.py Fix automatic updates of entities 2025-06-26 01:02:47 +02:00
light.py Fix automatic updates of entities 2025-06-26 01:02:47 +02:00
lock.py Fix automatic updates of entities 2025-06-26 01:02:47 +02:00
manifest.json Bump version v0.16.1 2025-11-10 00:57:04 +01:00
number.py Fix automatic updates of entities 2025-06-26 01:02:47 +02:00
select.py Fix automatic updates of entities 2025-06-26 01:02:47 +02:00
sensor.py Remove 3 of 4 added earlier sensors as they don't show anything 2025-10-24 19:12:57 +02:00
switch.py Fix automatic updates of entities 2025-06-26 01:02:47 +02:00
typedefs.py Fix issues from refactoring 2023-07-24 21:37:48 +02:00
util.py Rebuild to single data coordinator 2024-03-29 01:22:44 +01:00