Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions custom_components/gree/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ def _prop_supported(device, prop: str) -> bool:
missing as "not supported" so we don't expose non-functional switches.

While the device is offline / not yet synced we can't tell, so mirror the
device's online state (as the base entity does) instead of hiding.
climate entity's availability instead of hiding. That also honours
"Disable Available Check", which leaves ``_device_online`` unset.
"""
value = device._acOptions.get(prop, "")
if value in ("", None):
# Unknown until the first successful sync populates _acOptions. If we
# have synced at least once and the value is still empty, the unit
# genuinely doesn't support this property.
if getattr(device, "_firstTimeRun", False):
return getattr(device, "_device_online", True)
return bool(device.available)
return False
return getattr(device, "_device_online", True) if hasattr(device, "_device_online") else True
return bool(device.available)


@dataclass
Expand Down