mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Add entity translations to Big Ass Fans (#95136)
This commit is contained in:
parent
c8430e4557
commit
fa334cf2bd
@ -39,7 +39,6 @@ class BAFBinarySensorDescription(
|
||||
OCCUPANCY_SENSORS = (
|
||||
BAFBinarySensorDescription(
|
||||
key="occupancy",
|
||||
name="Occupancy",
|
||||
device_class=BinarySensorDeviceClass.OCCUPANCY,
|
||||
value_fn=lambda device: cast(bool | None, device.fan_occupancy_detected),
|
||||
),
|
||||
@ -70,7 +69,7 @@ class BAFBinarySensor(BAFEntity, BinarySensorEntity):
|
||||
def __init__(self, device: Device, description: BAFBinarySensorDescription) -> None:
|
||||
"""Initialize the entity."""
|
||||
self.entity_description = description
|
||||
super().__init__(device, f"{device.name} {description.name}")
|
||||
super().__init__(device)
|
||||
self._attr_unique_id = f"{self._device.mac_address}-{description.key}"
|
||||
|
||||
@callback
|
||||
|
@ -27,9 +27,7 @@ async def async_setup_entry(
|
||||
"""Set up BAF fan auto comfort."""
|
||||
data: BAFData = hass.data[DOMAIN][entry.entry_id]
|
||||
if data.device.has_fan and data.device.has_auto_comfort:
|
||||
async_add_entities(
|
||||
[BAFAutoComfort(data.device, f"{data.device.name} Auto Comfort")]
|
||||
)
|
||||
async_add_entities([BAFAutoComfort(data.device)])
|
||||
|
||||
|
||||
class BAFAutoComfort(BAFEntity, ClimateEntity):
|
||||
@ -38,6 +36,7 @@ class BAFAutoComfort(BAFEntity, ClimateEntity):
|
||||
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||
_attr_hvac_modes = [HVACMode.OFF, HVACMode.FAN_ONLY]
|
||||
_attr_translation_key = "auto_comfort"
|
||||
|
||||
@callback
|
||||
def _async_update_attrs(self) -> None:
|
||||
|
@ -13,12 +13,12 @@ class BAFEntity(Entity):
|
||||
"""Base class for baf entities."""
|
||||
|
||||
_attr_should_poll = False
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(self, device: Device, name: str) -> None:
|
||||
def __init__(self, device: Device) -> None:
|
||||
"""Initialize the entity."""
|
||||
self._device = device
|
||||
self._attr_unique_id = format_mac(self._device.mac_address)
|
||||
self._attr_name = name
|
||||
self._attr_device_info = DeviceInfo(
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, self._device.mac_address)},
|
||||
name=self._device.name,
|
||||
|
@ -33,7 +33,7 @@ async def async_setup_entry(
|
||||
"""Set up SenseME fans."""
|
||||
data: BAFData = hass.data[DOMAIN][entry.entry_id]
|
||||
if data.device.has_fan:
|
||||
async_add_entities([BAFFan(data.device, data.device.name)])
|
||||
async_add_entities([BAFFan(data.device)])
|
||||
|
||||
|
||||
class BAFFan(BAFEntity, FanEntity):
|
||||
@ -46,6 +46,7 @@ class BAFFan(BAFEntity, FanEntity):
|
||||
)
|
||||
_attr_preset_modes = [PRESET_MODE_AUTO]
|
||||
_attr_speed_count = SPEED_COUNT
|
||||
_attr_name = None
|
||||
|
||||
@callback
|
||||
def _async_update_attrs(self) -> None:
|
||||
|
@ -63,9 +63,11 @@ class BAFLight(BAFEntity, LightEntity):
|
||||
class BAFFanLight(BAFLight):
|
||||
"""Representation of a Big Ass Fans light on a fan."""
|
||||
|
||||
_attr_name = None
|
||||
|
||||
def __init__(self, device: Device) -> None:
|
||||
"""Init a fan light."""
|
||||
super().__init__(device, device.name)
|
||||
super().__init__(device)
|
||||
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||
self._attr_color_mode = ColorMode.BRIGHTNESS
|
||||
|
||||
@ -75,7 +77,7 @@ class BAFStandaloneLight(BAFLight):
|
||||
|
||||
def __init__(self, device: Device) -> None:
|
||||
"""Init a standalone light."""
|
||||
super().__init__(device, f"{device.name} Light")
|
||||
super().__init__(device)
|
||||
self._attr_supported_color_modes = {ColorMode.COLOR_TEMP}
|
||||
self._attr_color_mode = ColorMode.COLOR_TEMP
|
||||
self._attr_min_mireds = color_temperature_kelvin_to_mired(
|
||||
|
@ -37,7 +37,7 @@ class BAFNumberDescription(NumberEntityDescription, BAFNumberDescriptionMixin):
|
||||
AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="comfort_min_speed",
|
||||
name="Auto Comfort Minimum Speed",
|
||||
translation_key="comfort_min_speed",
|
||||
native_step=1,
|
||||
native_min_value=0,
|
||||
native_max_value=SPEED_RANGE[1] - 1,
|
||||
@ -47,7 +47,7 @@ AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
|
||||
),
|
||||
BAFNumberDescription(
|
||||
key="comfort_max_speed",
|
||||
name="Auto Comfort Maximum Speed",
|
||||
translation_key="comfort_max_speed",
|
||||
native_step=1,
|
||||
native_min_value=1,
|
||||
native_max_value=SPEED_RANGE[1],
|
||||
@ -57,7 +57,7 @@ AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
|
||||
),
|
||||
BAFNumberDescription(
|
||||
key="comfort_heat_assist_speed",
|
||||
name="Auto Comfort Heat Assist Speed",
|
||||
translation_key="comfort_heat_assist_speed",
|
||||
native_step=1,
|
||||
native_min_value=SPEED_RANGE[0],
|
||||
native_max_value=SPEED_RANGE[1],
|
||||
@ -70,7 +70,7 @@ AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
|
||||
FAN_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="return_to_auto_timeout",
|
||||
name="Return to Auto Timeout",
|
||||
translation_key="return_to_auto_timeout",
|
||||
native_step=1,
|
||||
native_min_value=ONE_MIN_SECS,
|
||||
native_max_value=HALF_DAY_SECS,
|
||||
@ -81,7 +81,7 @@ FAN_NUMBER_DESCRIPTIONS = (
|
||||
),
|
||||
BAFNumberDescription(
|
||||
key="motion_sense_timeout",
|
||||
name="Motion Sense Timeout",
|
||||
translation_key="motion_sense_timeout",
|
||||
native_step=1,
|
||||
native_min_value=ONE_MIN_SECS,
|
||||
native_max_value=ONE_DAY_SECS,
|
||||
@ -95,7 +95,7 @@ FAN_NUMBER_DESCRIPTIONS = (
|
||||
LIGHT_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="light_return_to_auto_timeout",
|
||||
name="Light Return to Auto Timeout",
|
||||
translation_key="light_return_to_auto_timeout",
|
||||
native_step=1,
|
||||
native_min_value=ONE_MIN_SECS,
|
||||
native_max_value=HALF_DAY_SECS,
|
||||
@ -106,7 +106,7 @@ LIGHT_NUMBER_DESCRIPTIONS = (
|
||||
),
|
||||
BAFNumberDescription(
|
||||
key="light_auto_motion_timeout",
|
||||
name="Light Motion Sense Timeout",
|
||||
translation_key="light_auto_motion_timeout",
|
||||
native_step=1,
|
||||
native_min_value=ONE_MIN_SECS,
|
||||
native_max_value=ONE_DAY_SECS,
|
||||
@ -144,7 +144,7 @@ class BAFNumber(BAFEntity, NumberEntity):
|
||||
def __init__(self, device: Device, description: BAFNumberDescription) -> None:
|
||||
"""Initialize the entity."""
|
||||
self.entity_description = description
|
||||
super().__init__(device, f"{device.name} {description.name}")
|
||||
super().__init__(device)
|
||||
self._attr_unique_id = f"{self._device.mac_address}-{description.key}"
|
||||
|
||||
@callback
|
||||
|
@ -46,7 +46,6 @@ class BAFSensorDescription(
|
||||
AUTO_COMFORT_SENSORS = (
|
||||
BAFSensorDescription(
|
||||
key="temperature",
|
||||
name="Temperature",
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
@ -57,7 +56,6 @@ AUTO_COMFORT_SENSORS = (
|
||||
DEFINED_ONLY_SENSORS = (
|
||||
BAFSensorDescription(
|
||||
key="humidity",
|
||||
name="Humidity",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
device_class=SensorDeviceClass.HUMIDITY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
@ -68,7 +66,7 @@ DEFINED_ONLY_SENSORS = (
|
||||
FAN_SENSORS = (
|
||||
BAFSensorDescription(
|
||||
key="current_rpm",
|
||||
name="Current RPM",
|
||||
translation_key="current_rpm",
|
||||
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
@ -76,7 +74,7 @@ FAN_SENSORS = (
|
||||
),
|
||||
BAFSensorDescription(
|
||||
key="target_rpm",
|
||||
name="Target RPM",
|
||||
translation_key="target_rpm",
|
||||
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
@ -84,14 +82,14 @@ FAN_SENSORS = (
|
||||
),
|
||||
BAFSensorDescription(
|
||||
key="wifi_ssid",
|
||||
name="WiFi SSID",
|
||||
translation_key="wifi_ssid",
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
value_fn=lambda device: cast(int | None, device.wifi_ssid),
|
||||
),
|
||||
BAFSensorDescription(
|
||||
key="ip_address",
|
||||
name="IP Address",
|
||||
translation_key="ip_address",
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
value_fn=lambda device: cast(str | None, device.ip_address),
|
||||
@ -128,7 +126,7 @@ class BAFSensor(BAFEntity, SensorEntity):
|
||||
def __init__(self, device: Device, description: BAFSensorDescription) -> None:
|
||||
"""Initialize the entity."""
|
||||
self.entity_description = description
|
||||
super().__init__(device, f"{device.name} {description.name}")
|
||||
super().__init__(device)
|
||||
self._attr_unique_id = f"{self._device.mac_address}-{description.key}"
|
||||
|
||||
@callback
|
||||
|
@ -19,5 +19,81 @@
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"climate": {
|
||||
"auto_comfort": {
|
||||
"name": "Auto comfort"
|
||||
}
|
||||
},
|
||||
"number": {
|
||||
"comfort_min_speed": {
|
||||
"name": "Auto Comfort Minimum Speed"
|
||||
},
|
||||
"comfort_max_speed": {
|
||||
"name": "Auto Comfort Maximum Speed"
|
||||
},
|
||||
"comfort_heat_assist_speed": {
|
||||
"name": "Auto Comfort Heat Assist Speed"
|
||||
},
|
||||
"return_to_auto_timeout": {
|
||||
"name": "Return to Auto Timeout"
|
||||
},
|
||||
"motion_sense_timeout": {
|
||||
"name": "Motion Sense Timeout"
|
||||
},
|
||||
"light_return_to_auto_timeout": {
|
||||
"name": "Light Return to Auto Timeout"
|
||||
},
|
||||
"light_auto_motion_timeout": {
|
||||
"name": "Light Motion Sense Timeout"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"current_rpm": {
|
||||
"name": "Current RPM"
|
||||
},
|
||||
"target_rpm": {
|
||||
"name": "Target RPM"
|
||||
},
|
||||
"wifi_ssid": {
|
||||
"name": "Wi-Fi SSID"
|
||||
},
|
||||
"ip_address": {
|
||||
"name": "IP Address"
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
"legacy_ir_remote_enable": {
|
||||
"name": "Legacy IR Remote"
|
||||
},
|
||||
"led_indicators_enable": {
|
||||
"name": "Led Indicators"
|
||||
},
|
||||
"comfort_heat_assist_enable": {
|
||||
"name": "Auto Comfort Heat Assist"
|
||||
},
|
||||
"fan_beep_enable": {
|
||||
"name": "Beep"
|
||||
},
|
||||
"eco_enable": {
|
||||
"name": "Eco Mode"
|
||||
},
|
||||
"motion_sense_enable": {
|
||||
"name": "Motion Sense"
|
||||
},
|
||||
"return_to_auto_enable": {
|
||||
"name": "Return to Auto"
|
||||
},
|
||||
"whoosh_enable": {
|
||||
"name": "Whoosh"
|
||||
},
|
||||
"light_dim_to_warm_enable": {
|
||||
"name": "Dim to Warm"
|
||||
},
|
||||
"light_return_to_auto_enable": {
|
||||
"name": "Light Return to Auto"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,13 +36,13 @@ class BAFSwitchDescription(
|
||||
BASE_SWITCHES = [
|
||||
BAFSwitchDescription(
|
||||
key="legacy_ir_remote_enable",
|
||||
name="Legacy IR Remote",
|
||||
translation_key="legacy_ir_remote_enable",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(bool | None, device.legacy_ir_remote_enable),
|
||||
),
|
||||
BAFSwitchDescription(
|
||||
key="led_indicators_enable",
|
||||
name="Led Indicators",
|
||||
translation_key="led_indicators_enable",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(bool | None, device.led_indicators_enable),
|
||||
),
|
||||
@ -51,7 +51,7 @@ BASE_SWITCHES = [
|
||||
AUTO_COMFORT_SWITCHES = [
|
||||
BAFSwitchDescription(
|
||||
key="comfort_heat_assist_enable",
|
||||
name="Auto Comfort Heat Assist",
|
||||
translation_key="comfort_heat_assist_enable",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(bool | None, device.comfort_heat_assist_enable),
|
||||
),
|
||||
@ -60,31 +60,31 @@ AUTO_COMFORT_SWITCHES = [
|
||||
FAN_SWITCHES = [
|
||||
BAFSwitchDescription(
|
||||
key="fan_beep_enable",
|
||||
name="Beep",
|
||||
translation_key="fan_beep_enable",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(bool | None, device.fan_beep_enable),
|
||||
),
|
||||
BAFSwitchDescription(
|
||||
key="eco_enable",
|
||||
name="Eco Mode",
|
||||
translation_key="eco_enable",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(bool | None, device.eco_enable),
|
||||
),
|
||||
BAFSwitchDescription(
|
||||
key="motion_sense_enable",
|
||||
name="Motion Sense",
|
||||
translation_key="motion_sense_enable",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(bool | None, device.motion_sense_enable),
|
||||
),
|
||||
BAFSwitchDescription(
|
||||
key="return_to_auto_enable",
|
||||
name="Return to Auto",
|
||||
translation_key="return_to_auto_enable",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(bool | None, device.return_to_auto_enable),
|
||||
),
|
||||
BAFSwitchDescription(
|
||||
key="whoosh_enable",
|
||||
name="Whoosh",
|
||||
translation_key="whoosh_enable",
|
||||
# Not a configuration switch
|
||||
value_fn=lambda device: cast(bool | None, device.whoosh_enable),
|
||||
),
|
||||
@ -94,13 +94,13 @@ FAN_SWITCHES = [
|
||||
LIGHT_SWITCHES = [
|
||||
BAFSwitchDescription(
|
||||
key="light_dim_to_warm_enable",
|
||||
name="Dim to Warm",
|
||||
translation_key="light_dim_to_warm_enable",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(bool | None, device.light_dim_to_warm_enable),
|
||||
),
|
||||
BAFSwitchDescription(
|
||||
key="light_return_to_auto_enable",
|
||||
name="Light Return to Auto",
|
||||
translation_key="light_return_to_auto_enable",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(bool | None, device.light_return_to_auto_enable),
|
||||
),
|
||||
@ -134,7 +134,7 @@ class BAFSwitch(BAFEntity, SwitchEntity):
|
||||
def __init__(self, device: Device, description: BAFSwitchDescription) -> None:
|
||||
"""Initialize the entity."""
|
||||
self.entity_description = description
|
||||
super().__init__(device, f"{device.name} {description.name}")
|
||||
super().__init__(device)
|
||||
self._attr_unique_id = f"{self._device.mac_address}-{description.key}"
|
||||
|
||||
@callback
|
||||
|
Loading…
x
Reference in New Issue
Block a user