Only create auto comfort entities for BAF devices that support them (#72948)
This commit is contained in:
parent
43b802252a
commit
f52fa3599f
7 changed files with 40 additions and 28 deletions
|
@ -26,7 +26,7 @@ async def async_setup_entry(
|
|||
) -> None:
|
||||
"""Set up BAF fan auto comfort."""
|
||||
data: BAFData = hass.data[DOMAIN][entry.entry_id]
|
||||
if data.device.has_fan:
|
||||
if data.device.has_fan and data.device.has_auto_comfort:
|
||||
async_add_entities(
|
||||
[BAFAutoComfort(data.device, f"{data.device.name} Auto Comfort")]
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Big Ass Fans",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/baf",
|
||||
"requirements": ["aiobafi6==0.3.0"],
|
||||
"requirements": ["aiobafi6==0.5.0"],
|
||||
"codeowners": ["@bdraco", "@jfroy"],
|
||||
"iot_class": "local_push",
|
||||
"zeroconf": [
|
||||
|
|
|
@ -36,27 +36,7 @@ class BAFNumberDescription(NumberEntityDescription, BAFNumberDescriptionMixin):
|
|||
"""Class describing BAF sensor entities."""
|
||||
|
||||
|
||||
FAN_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="return_to_auto_timeout",
|
||||
name="Return to Auto Timeout",
|
||||
min_value=ONE_MIN_SECS,
|
||||
max_value=HALF_DAY_SECS,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
unit_of_measurement=TIME_SECONDS,
|
||||
value_fn=lambda device: cast(Optional[int], device.return_to_auto_timeout),
|
||||
mode=NumberMode.SLIDER,
|
||||
),
|
||||
BAFNumberDescription(
|
||||
key="motion_sense_timeout",
|
||||
name="Motion Sense Timeout",
|
||||
min_value=ONE_MIN_SECS,
|
||||
max_value=ONE_DAY_SECS,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
unit_of_measurement=TIME_SECONDS,
|
||||
value_fn=lambda device: cast(Optional[int], device.motion_sense_timeout),
|
||||
mode=NumberMode.SLIDER,
|
||||
),
|
||||
AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="comfort_min_speed",
|
||||
name="Auto Comfort Minimum Speed",
|
||||
|
@ -86,6 +66,29 @@ FAN_NUMBER_DESCRIPTIONS = (
|
|||
),
|
||||
)
|
||||
|
||||
FAN_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="return_to_auto_timeout",
|
||||
name="Return to Auto Timeout",
|
||||
min_value=ONE_MIN_SECS,
|
||||
max_value=HALF_DAY_SECS,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
unit_of_measurement=TIME_SECONDS,
|
||||
value_fn=lambda device: cast(Optional[int], device.return_to_auto_timeout),
|
||||
mode=NumberMode.SLIDER,
|
||||
),
|
||||
BAFNumberDescription(
|
||||
key="motion_sense_timeout",
|
||||
name="Motion Sense Timeout",
|
||||
min_value=ONE_MIN_SECS,
|
||||
max_value=ONE_DAY_SECS,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
unit_of_measurement=TIME_SECONDS,
|
||||
value_fn=lambda device: cast(Optional[int], device.motion_sense_timeout),
|
||||
mode=NumberMode.SLIDER,
|
||||
),
|
||||
)
|
||||
|
||||
LIGHT_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="light_return_to_auto_timeout",
|
||||
|
@ -125,6 +128,8 @@ async def async_setup_entry(
|
|||
descriptions.extend(FAN_NUMBER_DESCRIPTIONS)
|
||||
if device.has_light:
|
||||
descriptions.extend(LIGHT_NUMBER_DESCRIPTIONS)
|
||||
if device.has_auto_comfort:
|
||||
descriptions.extend(AUTO_COMFORT_NUMBER_DESCRIPTIONS)
|
||||
async_add_entities(BAFNumber(device, description) for description in descriptions)
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class BAFSensorDescription(
|
|||
"""Class describing BAF sensor entities."""
|
||||
|
||||
|
||||
BASE_SENSORS = (
|
||||
AUTO_COMFORT_SENSORS = (
|
||||
BAFSensorDescription(
|
||||
key="temperature",
|
||||
name="Temperature",
|
||||
|
@ -103,10 +103,12 @@ async def async_setup_entry(
|
|||
"""Set up BAF fan sensors."""
|
||||
data: BAFData = hass.data[DOMAIN][entry.entry_id]
|
||||
device = data.device
|
||||
sensors_descriptions = list(BASE_SENSORS)
|
||||
sensors_descriptions: list[BAFSensorDescription] = []
|
||||
for description in DEFINED_ONLY_SENSORS:
|
||||
if getattr(device, description.key):
|
||||
sensors_descriptions.append(description)
|
||||
if device.has_auto_comfort:
|
||||
sensors_descriptions.extend(AUTO_COMFORT_SENSORS)
|
||||
if device.has_fan:
|
||||
sensors_descriptions.extend(FAN_SENSORS)
|
||||
async_add_entities(
|
||||
|
|
|
@ -48,13 +48,16 @@ BASE_SWITCHES = [
|
|||
),
|
||||
]
|
||||
|
||||
FAN_SWITCHES = [
|
||||
AUTO_COMFORT_SWITCHES = [
|
||||
BAFSwitchDescription(
|
||||
key="comfort_heat_assist_enable",
|
||||
name="Auto Comfort Heat Assist",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(Optional[bool], device.comfort_heat_assist_enable),
|
||||
),
|
||||
]
|
||||
|
||||
FAN_SWITCHES = [
|
||||
BAFSwitchDescription(
|
||||
key="fan_beep_enable",
|
||||
name="Beep",
|
||||
|
@ -120,6 +123,8 @@ async def async_setup_entry(
|
|||
descriptions.extend(FAN_SWITCHES)
|
||||
if device.has_light:
|
||||
descriptions.extend(LIGHT_SWITCHES)
|
||||
if device.has_auto_comfort:
|
||||
descriptions.extend(AUTO_COMFORT_SWITCHES)
|
||||
async_add_entities(BAFSwitch(device, description) for description in descriptions)
|
||||
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ aioasuswrt==1.4.0
|
|||
aioazuredevops==1.3.5
|
||||
|
||||
# homeassistant.components.baf
|
||||
aiobafi6==0.3.0
|
||||
aiobafi6==0.5.0
|
||||
|
||||
# homeassistant.components.aws
|
||||
aiobotocore==2.1.0
|
||||
|
|
|
@ -109,7 +109,7 @@ aioasuswrt==1.4.0
|
|||
aioazuredevops==1.3.5
|
||||
|
||||
# homeassistant.components.baf
|
||||
aiobafi6==0.3.0
|
||||
aiobafi6==0.5.0
|
||||
|
||||
# homeassistant.components.aws
|
||||
aiobotocore==2.1.0
|
||||
|
|
Loading…
Add table
Reference in a new issue