diff --git a/homeassistant/components/actron_air/switch.py b/homeassistant/components/actron_air/switch.py index 8ed50386bd0..c7c9538675b 100644 --- a/homeassistant/components/actron_air/switch.py +++ b/homeassistant/components/actron_air/switch.py @@ -29,30 +29,42 @@ SWITCHES: tuple[ActronAirSwitchEntityDescription, ...] = ( key="away_mode", translation_key="away_mode", is_on_fn=lambda coordinator: coordinator.data.user_aircon_settings.away_mode, - set_fn=lambda coordinator, - enabled: coordinator.data.user_aircon_settings.set_away_mode(enabled), + set_fn=lambda coordinator, enabled: ( + coordinator.data.user_aircon_settings.set_away_mode(enabled) + ), ), ActronAirSwitchEntityDescription( key="continuous_fan", translation_key="continuous_fan", - is_on_fn=lambda coordinator: coordinator.data.user_aircon_settings.continuous_fan_enabled, - set_fn=lambda coordinator, - enabled: coordinator.data.user_aircon_settings.set_continuous_mode(enabled), + is_on_fn=lambda coordinator: ( + coordinator.data.user_aircon_settings.continuous_fan_enabled + ), + set_fn=lambda coordinator, enabled: ( + coordinator.data.user_aircon_settings.set_continuous_mode(enabled) + ), ), ActronAirSwitchEntityDescription( key="quiet_mode", translation_key="quiet_mode", - is_on_fn=lambda coordinator: coordinator.data.user_aircon_settings.quiet_mode_enabled, - set_fn=lambda coordinator, - enabled: coordinator.data.user_aircon_settings.set_quiet_mode(enabled), + is_on_fn=lambda coordinator: ( + coordinator.data.user_aircon_settings.quiet_mode_enabled + ), + set_fn=lambda coordinator, enabled: ( + coordinator.data.user_aircon_settings.set_quiet_mode(enabled) + ), ), ActronAirSwitchEntityDescription( key="turbo_mode", translation_key="turbo_mode", - is_on_fn=lambda coordinator: coordinator.data.user_aircon_settings.turbo_enabled, - set_fn=lambda coordinator, - enabled: coordinator.data.user_aircon_settings.set_turbo_mode(enabled), - is_supported_fn=lambda coordinator: coordinator.data.user_aircon_settings.turbo_supported, + is_on_fn=lambda coordinator: ( + coordinator.data.user_aircon_settings.turbo_enabled + ), + set_fn=lambda coordinator, enabled: ( + coordinator.data.user_aircon_settings.set_turbo_mode(enabled) + ), + is_supported_fn=lambda coordinator: ( + coordinator.data.user_aircon_settings.turbo_supported + ), ), ) diff --git a/homeassistant/components/airgradient/select.py b/homeassistant/components/airgradient/select.py index f288055ebf4..987c110c25a 100644 --- a/homeassistant/components/airgradient/select.py +++ b/homeassistant/components/airgradient/select.py @@ -133,8 +133,9 @@ CONTROL_ENTITIES: tuple[AirGradientSelectEntityDescription, ...] = ( value_fn=lambda config: _get_value( config.co2_automatic_baseline_calibration_days, ABC_DAYS ), - set_value_fn=lambda client, - value: client.set_co2_automatic_baseline_calibration(int(value)), + set_value_fn=lambda client, value: ( + client.set_co2_automatic_baseline_calibration(int(value)) + ), ), ) diff --git a/homeassistant/components/ambient_network/config_flow.py b/homeassistant/components/ambient_network/config_flow.py index 44d89db743f..d195db03149 100644 --- a/homeassistant/components/ambient_network/config_flow.py +++ b/homeassistant/components/ambient_network/config_flow.py @@ -77,9 +77,11 @@ class AmbientNetworkConfigFlow(ConfigFlow, domain=DOMAIN): # Filter out indoor stations self._stations = dict( filter( - lambda item: not item[1] - .get(API_STATION_INFO, {}) - .get(API_STATION_INDOOR, False), + lambda item: ( + not item[1] + .get(API_STATION_INFO, {}) + .get(API_STATION_INDOOR, False) + ), self._stations.items(), ) ) diff --git a/homeassistant/components/blue_current/switch.py b/homeassistant/components/blue_current/switch.py index a0848387901..3ca32e34055 100644 --- a/homeassistant/components/blue_current/switch.py +++ b/homeassistant/components/blue_current/switch.py @@ -80,18 +80,16 @@ SWITCHES = ( key=PLUG_AND_CHARGE, translation_key=PLUG_AND_CHARGE, function=set_plug_and_charge, - turn_on_off_fn=lambda evse_id, connector: ( - update_on_value_and_activity(PLUG_AND_CHARGE, evse_id, connector) + turn_on_off_fn=lambda evse_id, connector: update_on_value_and_activity( + PLUG_AND_CHARGE, evse_id, connector ), ), BlueCurrentSwitchEntityDescription( key=LINKED_CHARGE_CARDS, translation_key=LINKED_CHARGE_CARDS, function=set_linked_charge_cards, - turn_on_off_fn=lambda evse_id, connector: ( - update_on_value_and_activity( - PUBLIC_CHARGING, evse_id, connector, reverse_is_on=True - ) + turn_on_off_fn=lambda evse_id, connector: update_on_value_and_activity( + PUBLIC_CHARGING, evse_id, connector, reverse_is_on=True ), ), BlueCurrentSwitchEntityDescription( diff --git a/homeassistant/components/bmw_connected_drive/binary_sensor.py b/homeassistant/components/bmw_connected_drive/binary_sensor.py index 01cdbbdc94d..b96450c3b5a 100644 --- a/homeassistant/components/bmw_connected_drive/binary_sensor.py +++ b/homeassistant/components/bmw_connected_drive/binary_sensor.py @@ -148,8 +148,10 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = ( device_class=BinarySensorDeviceClass.LOCK, # device class lock: On means unlocked, Off means locked # Possible values: LOCKED, SECURED, SELECTIVE_LOCKED, UNLOCKED - value_fn=lambda v: v.doors_and_windows.door_lock_state - not in {LockState.LOCKED, LockState.SECURED}, + value_fn=lambda v: ( + v.doors_and_windows.door_lock_state + not in {LockState.LOCKED, LockState.SECURED} + ), attr_fn=lambda v, u: { "door_lock_state": v.doors_and_windows.door_lock_state.value }, @@ -189,9 +191,11 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = ( BMWBinarySensorEntityDescription( key="is_pre_entry_climatization_enabled", translation_key="is_pre_entry_climatization_enabled", - value_fn=lambda v: v.charging_profile.is_pre_entry_climatization_enabled - if v.charging_profile - else False, + value_fn=lambda v: ( + v.charging_profile.is_pre_entry_climatization_enabled + if v.charging_profile + else False + ), is_available=lambda v: v.has_electric_drivetrain, ), ) diff --git a/homeassistant/components/bmw_connected_drive/button.py b/homeassistant/components/bmw_connected_drive/button.py index 726c3ff3f6e..250b54100dd 100644 --- a/homeassistant/components/bmw_connected_drive/button.py +++ b/homeassistant/components/bmw_connected_drive/button.py @@ -40,7 +40,9 @@ BUTTON_TYPES: tuple[BMWButtonEntityDescription, ...] = ( BMWButtonEntityDescription( key="light_flash", translation_key="light_flash", - remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_light_flash(), + remote_function=lambda vehicle: ( + vehicle.remote_services.trigger_remote_light_flash() + ), ), BMWButtonEntityDescription( key="sound_horn", @@ -50,18 +52,24 @@ BUTTON_TYPES: tuple[BMWButtonEntityDescription, ...] = ( BMWButtonEntityDescription( key="activate_air_conditioning", translation_key="activate_air_conditioning", - remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_air_conditioning(), + remote_function=lambda vehicle: ( + vehicle.remote_services.trigger_remote_air_conditioning() + ), ), BMWButtonEntityDescription( key="deactivate_air_conditioning", translation_key="deactivate_air_conditioning", - remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_air_conditioning_stop(), + remote_function=lambda vehicle: ( + vehicle.remote_services.trigger_remote_air_conditioning_stop() + ), is_available=lambda vehicle: vehicle.is_remote_climate_stop_enabled, ), BMWButtonEntityDescription( key="find_vehicle", translation_key="find_vehicle", - remote_function=lambda vehicle: vehicle.remote_services.trigger_remote_vehicle_finder(), + remote_function=lambda vehicle: ( + vehicle.remote_services.trigger_remote_vehicle_finder() + ), ), ) diff --git a/homeassistant/components/bmw_connected_drive/switch.py b/homeassistant/components/bmw_connected_drive/switch.py index cedcf2a7364..44f6eb4bbb0 100644 --- a/homeassistant/components/bmw_connected_drive/switch.py +++ b/homeassistant/components/bmw_connected_drive/switch.py @@ -50,7 +50,9 @@ NUMBER_TYPES: list[BMWSwitchEntityDescription] = [ is_available=lambda v: v.is_remote_climate_stop_enabled, value_fn=lambda v: v.climate.is_climate_on, remote_service_on=lambda v: v.remote_services.trigger_remote_air_conditioning(), - remote_service_off=lambda v: v.remote_services.trigger_remote_air_conditioning_stop(), + remote_service_off=lambda v: ( + v.remote_services.trigger_remote_air_conditioning_stop() + ), ), BMWSwitchEntityDescription( key="charging", diff --git a/homeassistant/components/bring/sensor.py b/homeassistant/components/bring/sensor.py index 88399ea26f7..6a22e35ab32 100644 --- a/homeassistant/components/bring/sensor.py +++ b/homeassistant/components/bring/sensor.py @@ -63,9 +63,9 @@ SENSOR_DESCRIPTIONS: tuple[BringSensorEntityDescription, ...] = ( key=BringSensor.LIST_LANGUAGE, translation_key=BringSensor.LIST_LANGUAGE, value_fn=( - lambda lst, settings: x.lower() - if (x := list_language(lst.lst.listUuid, settings)) - else None + lambda lst, settings: ( + x.lower() if (x := list_language(lst.lst.listUuid, settings)) else None + ) ), entity_category=EntityCategory.DIAGNOSTIC, options=[x.lower() for x in BRING_SUPPORTED_LOCALES], diff --git a/homeassistant/components/cookidoo/sensor.py b/homeassistant/components/cookidoo/sensor.py index 6df41383a75..2e9cbcc05b8 100644 --- a/homeassistant/components/cookidoo/sensor.py +++ b/homeassistant/components/cookidoo/sensor.py @@ -48,9 +48,11 @@ SENSOR_DESCRIPTIONS: tuple[CookidooSensorEntityDescription, ...] = ( key=CookidooSensor.SUBSCRIPTION, translation_key=CookidooSensor.SUBSCRIPTION, value_fn=( - lambda data: SUBSCRIPTION_MAP[data.subscription.type] - if data.subscription - else SUBSCRIPTION_MAP["NONE"] + lambda data: ( + SUBSCRIPTION_MAP[data.subscription.type] + if data.subscription + else SUBSCRIPTION_MAP["NONE"] + ) ), entity_category=EntityCategory.DIAGNOSTIC, options=list(SUBSCRIPTION_MAP.values()), @@ -60,9 +62,11 @@ SENSOR_DESCRIPTIONS: tuple[CookidooSensorEntityDescription, ...] = ( key=CookidooSensor.EXPIRES, translation_key=CookidooSensor.EXPIRES, value_fn=( - lambda data: dt_util.parse_datetime(data.subscription.expires) - if data.subscription - else None + lambda data: ( + dt_util.parse_datetime(data.subscription.expires) + if data.subscription + else None + ) ), entity_category=EntityCategory.DIAGNOSTIC, device_class=SensorDeviceClass.TIMESTAMP, diff --git a/homeassistant/components/derivative/sensor.py b/homeassistant/components/derivative/sensor.py index 39df5fcf648..8599f64b8e3 100644 --- a/homeassistant/components/derivative/sensor.py +++ b/homeassistant/components/derivative/sensor.py @@ -220,8 +220,8 @@ class DerivativeSensor(RestoreSensor, SensorEntity): if max_sub_interval is None or max_sub_interval.total_seconds() == 0 else max_sub_interval ) - self._cancel_max_sub_interval_exceeded_callback: CALLBACK_TYPE = ( - lambda *args: None + self._cancel_max_sub_interval_exceeded_callback: CALLBACK_TYPE = lambda *args: ( + None ) def _derive_and_set_attributes_from_state(self, source_state: State | None) -> None: diff --git a/homeassistant/components/dormakaba_dkey/binary_sensor.py b/homeassistant/components/dormakaba_dkey/binary_sensor.py index a8870ed224b..719afb03b58 100644 --- a/homeassistant/components/dormakaba_dkey/binary_sensor.py +++ b/homeassistant/components/dormakaba_dkey/binary_sensor.py @@ -36,8 +36,10 @@ BINARY_SENSOR_DESCRIPTIONS = ( key="security_locked", translation_key="deadbolt", device_class=BinarySensorDeviceClass.LOCK, - is_on=lambda state: state.unlock_status - not in (UnlockStatus.SECURITY_LOCKED, UnlockStatus.UNLOCKED_SECURITY_LOCKED), + is_on=lambda state: ( + state.unlock_status + not in (UnlockStatus.SECURITY_LOCKED, UnlockStatus.UNLOCKED_SECURITY_LOCKED) + ), ), ) diff --git a/homeassistant/components/epic_games_store/coordinator.py b/homeassistant/components/epic_games_store/coordinator.py index 0653a3da9b3..cd9f83a71fd 100644 --- a/homeassistant/components/epic_games_store/coordinator.py +++ b/homeassistant/components/epic_games_store/coordinator.py @@ -51,13 +51,15 @@ class EGSCalendarUpdateCoordinator( data = raw_data["data"]["Catalog"]["searchStore"]["elements"] discount_games = filter( - lambda game: game.get("promotions") - and ( - # Current discount(s) - game["promotions"]["promotionalOffers"] - or - # Upcoming discount(s) - game["promotions"]["upcomingPromotionalOffers"] + lambda game: ( + game.get("promotions") + and ( + # Current discount(s) + game["promotions"]["promotionalOffers"] + or + # Upcoming discount(s) + game["promotions"]["upcomingPromotionalOffers"] + ) ), data, ) diff --git a/homeassistant/components/eq3btsmart/number.py b/homeassistant/components/eq3btsmart/number.py index c9601a4437e..c6f0c129322 100644 --- a/homeassistant/components/eq3btsmart/number.py +++ b/homeassistant/components/eq3btsmart/number.py @@ -47,7 +47,9 @@ NUMBER_ENTITY_DESCRIPTIONS = [ Eq3NumberEntityDescription( key=ENTITY_KEY_COMFORT, value_func=lambda presets: presets.comfort_temperature, - value_set_func=lambda thermostat: thermostat.async_configure_comfort_temperature, + value_set_func=lambda thermostat: ( + thermostat.async_configure_comfort_temperature + ), translation_key=ENTITY_KEY_COMFORT, native_min_value=EQ3_MIN_TEMP, native_max_value=EQ3_MAX_TEMP, @@ -69,7 +71,9 @@ NUMBER_ENTITY_DESCRIPTIONS = [ Eq3NumberEntityDescription( key=ENTITY_KEY_WINDOW_OPEN_TEMPERATURE, value_func=lambda presets: presets.window_open_temperature, - value_set_func=lambda thermostat: thermostat.async_configure_window_open_temperature, + value_set_func=lambda thermostat: ( + thermostat.async_configure_window_open_temperature + ), translation_key=ENTITY_KEY_WINDOW_OPEN_TEMPERATURE, native_min_value=EQ3_MIN_TEMP, native_max_value=EQ3_MAX_TEMP, @@ -90,7 +94,9 @@ NUMBER_ENTITY_DESCRIPTIONS = [ ), Eq3NumberEntityDescription( key=ENTITY_KEY_WINDOW_OPEN_TIMEOUT, - value_set_func=lambda thermostat: thermostat.async_configure_window_open_duration, + value_set_func=lambda thermostat: ( + thermostat.async_configure_window_open_duration + ), value_func=lambda presets: presets.window_open_time.total_seconds() / 60, translation_key=ENTITY_KEY_WINDOW_OPEN_TIMEOUT, native_min_value=0, diff --git a/homeassistant/components/eq3btsmart/sensor.py b/homeassistant/components/eq3btsmart/sensor.py index 22fb53c8d51..83187aff379 100644 --- a/homeassistant/components/eq3btsmart/sensor.py +++ b/homeassistant/components/eq3btsmart/sensor.py @@ -39,7 +39,7 @@ SENSOR_ENTITY_DESCRIPTIONS = [ Eq3SensorEntityDescription( key=ENTITY_KEY_AWAY_UNTIL, translation_key=ENTITY_KEY_AWAY_UNTIL, - value_func=lambda status: (status.away_until or None), + value_func=lambda status: status.away_until or None, device_class=SensorDeviceClass.DATE, ), ] diff --git a/homeassistant/components/freebox/binary_sensor.py b/homeassistant/components/freebox/binary_sensor.py index 3b262309361..0952af2b415 100644 --- a/homeassistant/components/freebox/binary_sensor.py +++ b/homeassistant/components/freebox/binary_sensor.py @@ -126,7 +126,7 @@ class FreeboxCoverSensor(FreeboxHomeBinarySensor): """Initialize a cover for another device.""" cover_node = next( filter( - lambda x: (x["name"] == self._sensor_name and x["ep_type"] == "signal"), + lambda x: x["name"] == self._sensor_name and x["ep_type"] == "signal", node["type"]["endpoints"], ), None, diff --git a/homeassistant/components/freebox/camera.py b/homeassistant/components/freebox/camera.py index ea352416f37..af816b31024 100644 --- a/homeassistant/components/freebox/camera.py +++ b/homeassistant/components/freebox/camera.py @@ -118,7 +118,7 @@ class FreeboxCamera(FreeboxHomeEntity, FFmpegCamera): # Parse all endpoints values for endpoint in filter( - lambda x: (x["ep_type"] == "signal"), node["show_endpoints"] + lambda x: x["ep_type"] == "signal", node["show_endpoints"] ): self._attr_extra_state_attributes[endpoint["name"]] = endpoint["value"] diff --git a/homeassistant/components/freebox/entity.py b/homeassistant/components/freebox/entity.py index 17cd30f40ea..e29ffb071e9 100644 --- a/homeassistant/components/freebox/entity.py +++ b/homeassistant/components/freebox/entity.py @@ -96,7 +96,7 @@ class FreeboxHomeEntity(Entity): def get_command_id(self, nodes, ep_type: str, name: str) -> int | None: """Get the command id.""" node = next( - filter(lambda x: (x["name"] == name and x["ep_type"] == ep_type), nodes), + filter(lambda x: x["name"] == name and x["ep_type"] == ep_type, nodes), None, ) if not node: diff --git a/homeassistant/components/fully_kiosk/media_player.py b/homeassistant/components/fully_kiosk/media_player.py index f6333a2941d..c7b48759233 100644 --- a/homeassistant/components/fully_kiosk/media_player.py +++ b/homeassistant/components/fully_kiosk/media_player.py @@ -102,8 +102,10 @@ class FullyMediaPlayer(FullyKioskEntity, MediaPlayerEntity): return await media_source.async_browse_media( self.hass, media_content_id, - content_filter=lambda item: item.media_content_type.startswith("audio/") - or item.media_content_type.startswith("video/"), + content_filter=lambda item: ( + item.media_content_type.startswith("audio/") + or item.media_content_type.startswith("video/") + ), ) @callback diff --git a/homeassistant/components/goodwe/sensor.py b/homeassistant/components/goodwe/sensor.py index b5fd70f7a29..110e26ae5e2 100644 --- a/homeassistant/components/goodwe/sensor.py +++ b/homeassistant/components/goodwe/sensor.py @@ -79,11 +79,11 @@ _ICONS: dict[SensorKind, str] = { class GoodweSensorEntityDescription(SensorEntityDescription): """Class describing Goodwe sensor entities.""" - value: Callable[[GoodweUpdateCoordinator, str], Any] = ( - lambda coordinator, sensor: coordinator.sensor_value(sensor) + value: Callable[[GoodweUpdateCoordinator, str], Any] = lambda coordinator, sensor: ( + coordinator.sensor_value(sensor) ) - available: Callable[[GoodweUpdateCoordinator], bool] = ( - lambda coordinator: coordinator.last_update_success + available: Callable[[GoodweUpdateCoordinator], bool] = lambda coordinator: ( + coordinator.last_update_success ) diff --git a/homeassistant/components/greeneye_monitor/sensor.py b/homeassistant/components/greeneye_monitor/sensor.py index 7cfc0e40fc0..b2a16ded0bc 100644 --- a/homeassistant/components/greeneye_monitor/sensor.py +++ b/homeassistant/components/greeneye_monitor/sensor.py @@ -55,8 +55,9 @@ async def async_setup_platform( def on_new_monitor(monitor: greeneye.monitor.Monitor) -> None: monitor_config = next( filter( - lambda monitor_config: monitor_config[CONF_SERIAL_NUMBER] - == monitor.serial_number, + lambda monitor_config: ( + monitor_config[CONF_SERIAL_NUMBER] == monitor.serial_number + ), monitor_configs, ), None, diff --git a/homeassistant/components/habitica/button.py b/homeassistant/components/habitica/button.py index de8920deb77..e4a60452f9a 100644 --- a/homeassistant/components/habitica/button.py +++ b/homeassistant/components/habitica/button.py @@ -68,8 +68,9 @@ BUTTON_DESCRIPTIONS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.BUY_HEALTH_POTION, press_fn=lambda habitica: habitica.buy_health_potion(), available_fn=( - lambda data: (data.user.stats.gp or 0) >= 25 - and (data.user.stats.hp or 0) < 50 + lambda data: ( + (data.user.stats.gp or 0) >= 25 and (data.user.stats.hp or 0) < 50 + ) ), entity_picture="shop_potion.png", ), @@ -78,8 +79,10 @@ BUTTON_DESCRIPTIONS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.ALLOCATE_ALL_STAT_POINTS, press_fn=lambda habitica: habitica.allocate_stat_points(), available_fn=( - lambda data: data.user.preferences.automaticAllocation is True - and (data.user.stats.points or 0) > 0 + lambda data: ( + data.user.preferences.automaticAllocation is True + and (data.user.stats.points or 0) > 0 + ) ), ), HabiticaButtonEntityDescription( @@ -97,8 +100,9 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.MPHEAL, press_fn=lambda habitica: habitica.cast_skill(Skill.ETHEREAL_SURGE), available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 12 - and (data.user.stats.mp or 0) >= 30 + lambda data: ( + (data.user.stats.lvl or 0) >= 12 and (data.user.stats.mp or 0) >= 30 + ) ), class_needed=HabiticaClass.MAGE, entity_picture="shop_mpheal.png", @@ -108,8 +112,9 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.EARTH, press_fn=lambda habitica: habitica.cast_skill(Skill.EARTHQUAKE), available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 13 - and (data.user.stats.mp or 0) >= 35 + lambda data: ( + (data.user.stats.lvl or 0) >= 13 and (data.user.stats.mp or 0) >= 35 + ) ), class_needed=HabiticaClass.MAGE, entity_picture="shop_earth.png", @@ -120,9 +125,11 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( press_fn=lambda habitica: habitica.cast_skill(Skill.CHILLING_FROST), # chilling frost can only be cast once per day (streaks buff is false) available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 14 - and (data.user.stats.mp or 0) >= 40 - and not data.user.stats.buffs.streaks + lambda data: ( + (data.user.stats.lvl or 0) >= 14 + and (data.user.stats.mp or 0) >= 40 + and not data.user.stats.buffs.streaks + ) ), class_needed=HabiticaClass.MAGE, entity_picture="shop_frost.png", @@ -132,8 +139,9 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.DEFENSIVE_STANCE, press_fn=lambda habitica: habitica.cast_skill(Skill.DEFENSIVE_STANCE), available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 12 - and (data.user.stats.mp or 0) >= 25 + lambda data: ( + (data.user.stats.lvl or 0) >= 12 and (data.user.stats.mp or 0) >= 25 + ) ), class_needed=HabiticaClass.WARRIOR, entity_picture="shop_defensiveStance.png", @@ -143,8 +151,9 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.VALOROUS_PRESENCE, press_fn=lambda habitica: habitica.cast_skill(Skill.VALOROUS_PRESENCE), available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 13 - and (data.user.stats.mp or 0) >= 20 + lambda data: ( + (data.user.stats.lvl or 0) >= 13 and (data.user.stats.mp or 0) >= 20 + ) ), class_needed=HabiticaClass.WARRIOR, entity_picture="shop_valorousPresence.png", @@ -154,8 +163,9 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.INTIMIDATE, press_fn=lambda habitica: habitica.cast_skill(Skill.INTIMIDATING_GAZE), available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 14 - and (data.user.stats.mp or 0) >= 15 + lambda data: ( + (data.user.stats.lvl or 0) >= 14 and (data.user.stats.mp or 0) >= 15 + ) ), class_needed=HabiticaClass.WARRIOR, entity_picture="shop_intimidate.png", @@ -165,8 +175,9 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.TOOLS_OF_TRADE, press_fn=lambda habitica: habitica.cast_skill(Skill.TOOLS_OF_THE_TRADE), available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 13 - and (data.user.stats.mp or 0) >= 25 + lambda data: ( + (data.user.stats.lvl or 0) >= 13 and (data.user.stats.mp or 0) >= 25 + ) ), class_needed=HabiticaClass.ROGUE, entity_picture="shop_toolsOfTrade.png", @@ -178,17 +189,19 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( # Stealth buffs stack and it can only be cast if the amount of # buffs is smaller than the amount of unfinished dailies available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 14 - and (data.user.stats.mp or 0) >= 45 - and (data.user.stats.buffs.stealth or 0) - < len( - [ - r - for r in data.tasks - if r.Type is TaskType.DAILY - and r.isDue is True - and r.completed is False - ] + lambda data: ( + (data.user.stats.lvl or 0) >= 14 + and (data.user.stats.mp or 0) >= 45 + and (data.user.stats.buffs.stealth or 0) + < len( + [ + r + for r in data.tasks + if r.Type is TaskType.DAILY + and r.isDue is True + and r.completed is False + ] + ) ) ), class_needed=HabiticaClass.ROGUE, @@ -199,9 +212,11 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.HEAL, press_fn=lambda habitica: habitica.cast_skill(Skill.HEALING_LIGHT), available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 11 - and (data.user.stats.mp or 0) >= 15 - and (data.user.stats.hp or 0) < 50 + lambda data: ( + (data.user.stats.lvl or 0) >= 11 + and (data.user.stats.mp or 0) >= 15 + and (data.user.stats.hp or 0) < 50 + ) ), class_needed=HabiticaClass.HEALER, entity_picture="shop_heal.png", @@ -211,8 +226,9 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.BRIGHTNESS, press_fn=lambda habitica: habitica.cast_skill(Skill.SEARING_BRIGHTNESS), available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 12 - and (data.user.stats.mp or 0) >= 15 + lambda data: ( + (data.user.stats.lvl or 0) >= 12 and (data.user.stats.mp or 0) >= 15 + ) ), class_needed=HabiticaClass.HEALER, entity_picture="shop_brightness.png", @@ -222,8 +238,9 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.PROTECT_AURA, press_fn=lambda habitica: habitica.cast_skill(Skill.PROTECTIVE_AURA), available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 13 - and (data.user.stats.mp or 0) >= 30 + lambda data: ( + (data.user.stats.lvl or 0) >= 13 and (data.user.stats.mp or 0) >= 30 + ) ), class_needed=HabiticaClass.HEALER, entity_picture="shop_protectAura.png", @@ -233,8 +250,9 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( translation_key=HabiticaButtonEntity.HEAL_ALL, press_fn=lambda habitica: habitica.cast_skill(Skill.BLESSING), available_fn=( - lambda data: (data.user.stats.lvl or 0) >= 14 - and (data.user.stats.mp or 0) >= 25 + lambda data: ( + (data.user.stats.lvl or 0) >= 14 and (data.user.stats.mp or 0) >= 25 + ) ), class_needed=HabiticaClass.HEALER, entity_picture="shop_healAll.png", diff --git a/homeassistant/components/habitica/sensor.py b/homeassistant/components/habitica/sensor.py index 824d5c414fd..e4f32467329 100644 --- a/homeassistant/components/habitica/sensor.py +++ b/homeassistant/components/habitica/sensor.py @@ -220,9 +220,11 @@ SENSOR_DESCRIPTIONS_COMMON: tuple[HabiticaSensorEntityDescription, ...] = ( key=HabiticaSensorEntity.LAST_CHECKIN, translation_key=HabiticaSensorEntity.LAST_CHECKIN, value_fn=( - lambda user, _: dt_util.as_local(last) - if (last := user.auth.timestamps.loggedin) - else None + lambda user, _: ( + dt_util.as_local(last) + if (last := user.auth.timestamps.loggedin) + else None + ) ), device_class=SensorDeviceClass.TIMESTAMP, ), @@ -321,9 +323,11 @@ SENSOR_DESCRIPTIONS_PARTY: tuple[HabiticaPartySensorEntityDescription, ...] = ( value_fn=lambda p, c: c.quests[p.quest.key].text if p.quest.key else None, attributes_fn=quest_attributes, entity_picture=( - lambda party: f"inventory_quest_scroll_{party.quest.key}.png" - if party.quest.key - else None + lambda party: ( + f"inventory_quest_scroll_{party.quest.key}.png" + if party.quest.key + else None + ) ), ), HabiticaPartySensorEntityDescription( @@ -349,16 +353,20 @@ SENSOR_DESCRIPTIONS_PARTY: tuple[HabiticaPartySensorEntityDescription, ...] = ( key=HabiticaSensorEntity.COLLECTED_ITEMS, translation_key=HabiticaSensorEntity.COLLECTED_ITEMS, value_fn=( - lambda p, _: sum(n for n in p.quest.progress.collect.values()) - if p.quest.progress.collect - else None + lambda p, _: ( + sum(n for n in p.quest.progress.collect.values()) + if p.quest.progress.collect + else None + ) ), attributes_fn=collected_quest_items, entity_picture=( - lambda p: f"quest_{p.quest.key}_{k}.png" - if p.quest.progress.collect - and (k := next(iter(p.quest.progress.collect), None)) - else None + lambda p: ( + f"quest_{p.quest.key}_{k}.png" + if p.quest.progress.collect + and (k := next(iter(p.quest.progress.collect), None)) + else None + ) ), ), HabiticaPartySensorEntityDescription( @@ -372,9 +380,9 @@ SENSOR_DESCRIPTIONS_PARTY: tuple[HabiticaPartySensorEntityDescription, ...] = ( key=HabiticaSensorEntity.BOSS_RAGE_LIMIT, translation_key=HabiticaSensorEntity.BOSS_RAGE_LIMIT, value_fn=( - lambda p, c: boss.rage.value - if (boss := quest_boss(p, c)) and boss.rage - else None + lambda p, c: ( + boss.rage.value if (boss := quest_boss(p, c)) and boss.rage else None + ) ), entity_picture=ha.RAGE, suggested_display_precision=0, diff --git a/homeassistant/components/habitica/services.py b/homeassistant/components/habitica/services.py index 1c677f18a58..fbf87d57337 100644 --- a/homeassistant/components/habitica/services.py +++ b/homeassistant/components/habitica/services.py @@ -763,8 +763,10 @@ async def _create_or_update_task(call: ServiceCall) -> ServiceResponse: # noqa: if task_type is TaskType.DAILY: reminders = list( filter( - lambda r: r.time.time().replace(second=0, microsecond=0) - not in remove_reminder, + lambda r: ( + r.time.time().replace(second=0, microsecond=0) + not in remove_reminder + ), reminders, ) ) diff --git a/homeassistant/components/homee/sensor.py b/homeassistant/components/homee/sensor.py index 5fc19e9bfdf..0bcfd1059f9 100644 --- a/homeassistant/components/homee/sensor.py +++ b/homeassistant/components/homee/sensor.py @@ -58,11 +58,11 @@ class HomeeSensorEntityDescription(SensorEntityDescription): device_class_fn: Callable[ [HomeeAttribute, SensorDeviceClass | None], SensorDeviceClass | None ] = lambda attribute, device_class: device_class - value_fn: Callable[[HomeeAttribute], str | float | None] = ( - lambda value: value.current_value + value_fn: Callable[[HomeeAttribute], str | float | None] = lambda value: ( + value.current_value ) - native_unit_of_measurement_fn: Callable[[str], str | None] = ( - lambda homee_unit: HOMEE_UNIT_TO_HA_UNIT[homee_unit] + native_unit_of_measurement_fn: Callable[[str], str | None] = lambda homee_unit: ( + HOMEE_UNIT_TO_HA_UNIT[homee_unit] ) @@ -84,9 +84,11 @@ SENSOR_DESCRIPTIONS: dict[AttributeType, HomeeSensorEntityDescription] = { device_class_fn=get_brightness_device_class, state_class=SensorStateClass.MEASUREMENT, value_fn=( - lambda attribute: attribute.current_value * 1000 - if attribute.unit == "klx" - else attribute.current_value + lambda attribute: ( + attribute.current_value * 1000 + if attribute.unit == "klx" + else attribute.current_value + ) ), ), AttributeType.CURRENT: HomeeSensorEntityDescription( diff --git a/homeassistant/components/homewizard/sensor.py b/homeassistant/components/homewizard/sensor.py index cadcbda29b7..6e53a178616 100644 --- a/homeassistant/components/homewizard/sensor.py +++ b/homeassistant/components/homewizard/sensor.py @@ -113,9 +113,11 @@ SENSORS: Final[tuple[HomeWizardSensorEntityDescription, ...]] = ( translation_key="active_tariff", has_fn=lambda data: data.measurement.tariff is not None, value_fn=( - lambda data: None - if data.measurement.tariff is None - else str(data.measurement.tariff) + lambda data: ( + None + if data.measurement.tariff is None + else str(data.measurement.tariff) + ) ), device_class=SensorDeviceClass.ENUM, options=["1", "2", "3", "4"], @@ -128,13 +130,14 @@ SENSORS: Final[tuple[HomeWizardSensorEntityDescription, ...]] = ( entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, has_fn=( - lambda data: data.system is not None - and data.system.wifi_strength_pct is not None + lambda data: ( + data.system is not None and data.system.wifi_strength_pct is not None + ) ), value_fn=( - lambda data: data.system.wifi_strength_pct - if data.system is not None - else None + lambda data: ( + data.system.wifi_strength_pct if data.system is not None else None + ) ), ), HomeWizardSensorEntityDescription( @@ -145,8 +148,9 @@ SENSORS: Final[tuple[HomeWizardSensorEntityDescription, ...]] = ( entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, has_fn=( - lambda data: data.system is not None - and data.system.wifi_rssi_db is not None + lambda data: ( + data.system is not None and data.system.wifi_rssi_db is not None + ) ), value_fn=( lambda data: data.system.wifi_rssi_db if data.system is not None else None @@ -733,9 +737,9 @@ async def async_setup_entry( ) ), has_fn=lambda x: True, - value_fn=lambda data: power_w * -1 - if (power_w := data.measurement.power_w) - else power_w, + value_fn=lambda data: ( + power_w * -1 if (power_w := data.measurement.power_w) else power_w + ), ) entities.append( HomeWizardSensorEntity( diff --git a/homeassistant/components/huawei_lte/sensor.py b/homeassistant/components/huawei_lte/sensor.py index ae63b67596c..aaf71c9195b 100644 --- a/homeassistant/components/huawei_lte/sensor.py +++ b/homeassistant/components/huawei_lte/sensor.py @@ -276,13 +276,11 @@ SENSOR_META: dict[str, HuaweiSensorGroup] = { {"0": "2G", "2": "3G", "7": "4G"}.get(x), None, ), - icon_fn=lambda x: ( - { - "2G": "mdi:signal-2g", - "3G": "mdi:signal-3g", - "4G": "mdi:signal-4g", - }.get(str(x), "mdi:signal") - ), + icon_fn=lambda x: { + "2G": "mdi:signal-2g", + "3G": "mdi:signal-3g", + "4G": "mdi:signal-4g", + }.get(str(x), "mdi:signal"), entity_category=EntityCategory.DIAGNOSTIC, ), "nei_cellid": HuaweiSensorEntityDescription( diff --git a/homeassistant/components/husqvarna_automower/sensor.py b/homeassistant/components/husqvarna_automower/sensor.py index 1d8c1d5d492..f079e7cb386 100644 --- a/homeassistant/components/husqvarna_automower/sensor.py +++ b/homeassistant/components/husqvarna_automower/sensor.py @@ -175,9 +175,9 @@ MOWER_SENSOR_TYPES: tuple[AutomowerSensorEntityDescription, ...] = ( device_class=SensorDeviceClass.ENUM, option_fn=lambda data: list(MowerModes), value_fn=( - lambda data: data.mower.mode - if data.mower.mode != MowerModes.UNKNOWN - else None + lambda data: ( + data.mower.mode if data.mower.mode != MowerModes.UNKNOWN else None + ) ), ), AutomowerSensorEntityDescription( diff --git a/homeassistant/components/hydrawise/binary_sensor.py b/homeassistant/components/hydrawise/binary_sensor.py index b26255db3fa..d7344f56ab5 100644 --- a/homeassistant/components/hydrawise/binary_sensor.py +++ b/homeassistant/components/hydrawise/binary_sensor.py @@ -37,8 +37,10 @@ CONTROLLER_BINARY_SENSORS: tuple[HydrawiseBinarySensorEntityDescription, ...] = key="status", device_class=BinarySensorDeviceClass.CONNECTIVITY, value_fn=( - lambda status_sensor: status_sensor.coordinator.last_update_success - and status_sensor.controller.online + lambda status_sensor: ( + status_sensor.coordinator.last_update_success + and status_sensor.controller.online + ) ), # Connectivtiy sensor is always available always_available=True, @@ -60,8 +62,9 @@ ZONE_BINARY_SENSORS: tuple[HydrawiseBinarySensorEntityDescription, ...] = ( translation_key="watering", device_class=BinarySensorDeviceClass.RUNNING, value_fn=( - lambda watering_sensor: watering_sensor.zone.scheduled_runs.current_run - is not None + lambda watering_sensor: ( + watering_sensor.zone.scheduled_runs.current_run is not None + ) ), ), ) diff --git a/homeassistant/components/intellifire/sensor.py b/homeassistant/components/intellifire/sensor.py index 287f9a60ca0..82abc0d3797 100644 --- a/homeassistant/components/intellifire/sensor.py +++ b/homeassistant/components/intellifire/sensor.py @@ -71,7 +71,7 @@ INTELLIFIRE_SENSORS: tuple[IntellifireSensorEntityDescription, ...] = ( translation_key="flame_height", state_class=SensorStateClass.MEASUREMENT, # UI uses 1-5 for flame height, backing lib uses 0-4 - value_fn=lambda coordinator: (coordinator.data.flameheight + 1), + value_fn=lambda coordinator: coordinator.data.flameheight + 1, ), IntellifireSensorEntityDescription( key="temperature", diff --git a/homeassistant/components/iron_os/sensor.py b/homeassistant/components/iron_os/sensor.py index 79f1e54a6f4..da70b998e34 100644 --- a/homeassistant/components/iron_os/sensor.py +++ b/homeassistant/components/iron_os/sensor.py @@ -165,9 +165,9 @@ PINECIL_SENSOR_DESCRIPTIONS: tuple[IronOSSensorEntityDescription, ...] = ( device_class=SensorDeviceClass.ENUM, options=[item.name.lower() for item in OperatingMode], value_fn=( - lambda data, _: data.operating_mode.name.lower() - if data.operating_mode - else None + lambda data, _: ( + data.operating_mode.name.lower() if data.operating_mode else None + ) ), ), IronOSSensorEntityDescription( diff --git a/homeassistant/components/jewish_calendar/sensor.py b/homeassistant/components/jewish_calendar/sensor.py index 8670bae5371..ee008950de9 100644 --- a/homeassistant/components/jewish_calendar/sensor.py +++ b/homeassistant/components/jewish_calendar/sensor.py @@ -42,8 +42,8 @@ class JewishCalendarSensorDescription(JewishCalendarBaseSensorDescription): value_fn: Callable[[HDateInfo], str | int] attr_fn: Callable[[HDateInfo], dict[str, str]] | None = None options_fn: Callable[[bool], list[str]] | None = None - next_update_fn: Callable[[Zmanim], dt.datetime | None] | None = ( - lambda zmanim: zmanim.shkia.local + next_update_fn: Callable[[Zmanim], dt.datetime | None] | None = lambda zmanim: ( + zmanim.shkia.local ) @@ -178,9 +178,9 @@ TIME_SENSORS: tuple[JewishCalendarTimestampSensorDescription, ...] = ( key="upcoming_shabbat_candle_lighting", translation_key="upcoming_shabbat_candle_lighting", entity_registry_enabled_default=False, - value_fn=lambda at_date, mz: mz( - at_date.upcoming_shabbat.previous_day.gdate - ).candle_lighting, + value_fn=lambda at_date, mz: ( + mz(at_date.upcoming_shabbat.previous_day.gdate).candle_lighting + ), next_update_fn=lambda zmanim: zmanim.havdalah, ), JewishCalendarTimestampSensorDescription( @@ -193,17 +193,19 @@ TIME_SENSORS: tuple[JewishCalendarTimestampSensorDescription, ...] = ( JewishCalendarTimestampSensorDescription( key="upcoming_candle_lighting", translation_key="upcoming_candle_lighting", - value_fn=lambda at_date, mz: mz( - at_date.upcoming_shabbat_or_yom_tov.first_day.previous_day.gdate - ).candle_lighting, + value_fn=lambda at_date, mz: ( + mz( + at_date.upcoming_shabbat_or_yom_tov.first_day.previous_day.gdate + ).candle_lighting + ), next_update_fn=lambda zmanim: zmanim.havdalah, ), JewishCalendarTimestampSensorDescription( key="upcoming_havdalah", translation_key="upcoming_havdalah", - value_fn=lambda at_date, mz: mz( - at_date.upcoming_shabbat_or_yom_tov.last_day.gdate - ).havdalah, + value_fn=lambda at_date, mz: ( + mz(at_date.upcoming_shabbat_or_yom_tov.last_day.gdate).havdalah + ), next_update_fn=lambda zmanim: zmanim.havdalah, ), ) diff --git a/homeassistant/components/knx/config_flow.py b/homeassistant/components/knx/config_flow.py index 7772f366493..5c72fed4820 100644 --- a/homeassistant/components/knx/config_flow.py +++ b/homeassistant/components/knx/config_flow.py @@ -231,9 +231,11 @@ class KNXConfigFlow(ConfigFlow, domain=DOMAIN): if gateway.supports_tunnelling ] self._found_tunnels.sort( - key=lambda tunnel: tunnel.individual_address.raw - if tunnel.individual_address - else 0 + key=lambda tunnel: ( + tunnel.individual_address.raw + if tunnel.individual_address + else 0 + ) ) return await self.async_step_tunnel() diff --git a/homeassistant/components/knx/sensor.py b/homeassistant/components/knx/sensor.py index 3325081b3bb..0d548085802 100644 --- a/homeassistant/components/knx/sensor.py +++ b/homeassistant/components/knx/sensor.py @@ -116,9 +116,11 @@ SYSTEM_ENTITY_DESCRIPTIONS = ( key="telegram_count", force_update=True, state_class=SensorStateClass.TOTAL_INCREASING, - value_fn=lambda knx: knx.xknx.connection_manager.cemi_count_outgoing - + knx.xknx.connection_manager.cemi_count_incoming - + knx.xknx.connection_manager.cemi_count_incoming_error, + value_fn=lambda knx: ( + knx.xknx.connection_manager.cemi_count_outgoing + + knx.xknx.connection_manager.cemi_count_incoming + + knx.xknx.connection_manager.cemi_count_incoming_error + ), ), KNXSystemEntityDescription( key="telegrams_data_secure_undecodable", diff --git a/homeassistant/components/lamarzocco/binary_sensor.py b/homeassistant/components/lamarzocco/binary_sensor.py index 262d5dfe933..425f47273f9 100644 --- a/homeassistant/components/lamarzocco/binary_sensor.py +++ b/homeassistant/components/lamarzocco/binary_sensor.py @@ -40,11 +40,11 @@ ENTITIES: tuple[LaMarzoccoBinarySensorEntityDescription, ...] = ( translation_key="water_tank", device_class=BinarySensorDeviceClass.PROBLEM, is_on_fn=( - lambda machine: cast( - NoWater, machine.dashboard.config[WidgetType.CM_NO_WATER] - ).allarm - if WidgetType.CM_NO_WATER in machine.dashboard.config - else False + lambda machine: ( + cast(NoWater, machine.dashboard.config[WidgetType.CM_NO_WATER]).allarm + if WidgetType.CM_NO_WATER in machine.dashboard.config + else False + ) ), entity_category=EntityCategory.DIAGNOSTIC, bt_offline_mode=True, @@ -54,10 +54,13 @@ ENTITIES: tuple[LaMarzoccoBinarySensorEntityDescription, ...] = ( translation_key="brew_active", device_class=BinarySensorDeviceClass.RUNNING, is_on_fn=( - lambda machine: cast( - MachineStatus, machine.dashboard.config[WidgetType.CM_MACHINE_STATUS] - ).status - is MachineState.BREWING + lambda machine: ( + cast( + MachineStatus, + machine.dashboard.config[WidgetType.CM_MACHINE_STATUS], + ).status + is MachineState.BREWING + ) ), available_fn=lambda coordinator: not coordinator.websocket_terminated, entity_category=EntityCategory.DIAGNOSTIC, @@ -67,13 +70,15 @@ ENTITIES: tuple[LaMarzoccoBinarySensorEntityDescription, ...] = ( translation_key="backflush_enabled", device_class=BinarySensorDeviceClass.RUNNING, is_on_fn=( - lambda machine: cast( - BackFlush, - machine.dashboard.config.get( - WidgetType.CM_BACK_FLUSH, BackFlush(status=BackFlushStatus.OFF) - ), - ).status - in (BackFlushStatus.REQUESTED, BackFlushStatus.CLEANING) + lambda machine: ( + cast( + BackFlush, + machine.dashboard.config.get( + WidgetType.CM_BACK_FLUSH, BackFlush(status=BackFlushStatus.OFF) + ), + ).status + in (BackFlushStatus.REQUESTED, BackFlushStatus.CLEANING) + ) ), entity_category=EntityCategory.DIAGNOSTIC, supported_fn=lambda coordinator: ( diff --git a/homeassistant/components/lamarzocco/number.py b/homeassistant/components/lamarzocco/number.py index 2eee3956bba..8132fb697ae 100644 --- a/homeassistant/components/lamarzocco/number.py +++ b/homeassistant/components/lamarzocco/number.py @@ -60,9 +60,11 @@ ENTITIES: tuple[LaMarzoccoNumberEntityDescription, ...] = ( native_max_value=104, set_value_fn=lambda machine, temp: machine.set_coffee_target_temperature(temp), native_value_fn=( - lambda machine: cast( - CoffeeBoiler, machine.dashboard.config[WidgetType.CM_COFFEE_BOILER] - ).target_temperature + lambda machine: ( + cast( + CoffeeBoiler, machine.dashboard.config[WidgetType.CM_COFFEE_BOILER] + ).target_temperature + ) ), bt_offline_mode=True, ), @@ -76,14 +78,18 @@ ENTITIES: tuple[LaMarzoccoNumberEntityDescription, ...] = ( native_max_value=134, set_value_fn=lambda machine, temp: machine.set_steam_target_temperature(temp), native_value_fn=( - lambda machine: cast( - SteamBoilerTemperature, - machine.dashboard.config[WidgetType.CM_STEAM_BOILER_TEMPERATURE], - ).target_temperature + lambda machine: ( + cast( + SteamBoilerTemperature, + machine.dashboard.config[WidgetType.CM_STEAM_BOILER_TEMPERATURE], + ).target_temperature + ) ), supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in (ModelName.GS3_AV, ModelName.GS3_MP) + lambda coordinator: ( + coordinator.device.dashboard.model_name + in (ModelName.GS3_AV, ModelName.GS3_MP) + ) ), bt_offline_mode=True, ), @@ -103,7 +109,9 @@ ENTITIES: tuple[LaMarzoccoNumberEntityDescription, ...] = ( minutes=int(value), ) ), - native_value_fn=lambda machine: machine.schedule.smart_wake_up_sleep.smart_stand_by_minutes, + native_value_fn=lambda machine: ( + machine.schedule.smart_wake_up_sleep.smart_stand_by_minutes + ), bt_offline_mode=True, ), LaMarzoccoNumberEntityDescription( @@ -122,25 +130,29 @@ ENTITIES: tuple[LaMarzoccoNumberEntityDescription, ...] = ( ) ), native_value_fn=( - lambda machine: cast( - PreBrewing, machine.dashboard.config[WidgetType.CM_PRE_BREWING] + lambda machine: ( + cast(PreBrewing, machine.dashboard.config[WidgetType.CM_PRE_BREWING]) + .times.pre_infusion[0] + .seconds.seconds_out ) - .times.pre_infusion[0] - .seconds.seconds_out ), available_fn=( - lambda coordinator: cast( - PreBrewing, - coordinator.device.dashboard.config[WidgetType.CM_PRE_BREWING], - ).mode - is PreExtractionMode.PREINFUSION + lambda coordinator: ( + cast( + PreBrewing, + coordinator.device.dashboard.config[WidgetType.CM_PRE_BREWING], + ).mode + is PreExtractionMode.PREINFUSION + ) ), supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in ( - ModelName.LINEA_MICRA, - ModelName.LINEA_MINI, - ModelName.LINEA_MINI_R, + lambda coordinator: ( + coordinator.device.dashboard.model_name + in ( + ModelName.LINEA_MICRA, + ModelName.LINEA_MINI, + ModelName.LINEA_MINI_R, + ) ) ), ), @@ -164,22 +176,27 @@ ENTITIES: tuple[LaMarzoccoNumberEntityDescription, ...] = ( ) ), native_value_fn=( - lambda machine: cast( - PreBrewing, machine.dashboard.config[WidgetType.CM_PRE_BREWING] + lambda machine: ( + cast(PreBrewing, machine.dashboard.config[WidgetType.CM_PRE_BREWING]) + .times.pre_brewing[0] + .seconds.seconds_in ) - .times.pre_brewing[0] - .seconds.seconds_in ), - available_fn=lambda coordinator: cast( - PreBrewing, coordinator.device.dashboard.config[WidgetType.CM_PRE_BREWING] - ).mode - is PreExtractionMode.PREBREWING, + available_fn=lambda coordinator: ( + cast( + PreBrewing, + coordinator.device.dashboard.config[WidgetType.CM_PRE_BREWING], + ).mode + is PreExtractionMode.PREBREWING + ), supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in ( - ModelName.LINEA_MICRA, - ModelName.LINEA_MINI, - ModelName.LINEA_MINI_R, + lambda coordinator: ( + coordinator.device.dashboard.model_name + in ( + ModelName.LINEA_MICRA, + ModelName.LINEA_MINI, + ModelName.LINEA_MINI_R, + ) ) ), ), @@ -203,25 +220,29 @@ ENTITIES: tuple[LaMarzoccoNumberEntityDescription, ...] = ( ) ), native_value_fn=( - lambda machine: cast( - PreBrewing, machine.dashboard.config[WidgetType.CM_PRE_BREWING] + lambda machine: ( + cast(PreBrewing, machine.dashboard.config[WidgetType.CM_PRE_BREWING]) + .times.pre_brewing[0] + .seconds.seconds_out ) - .times.pre_brewing[0] - .seconds.seconds_out ), available_fn=( - lambda coordinator: cast( - PreBrewing, - coordinator.device.dashboard.config[WidgetType.CM_PRE_BREWING], - ).mode - is PreExtractionMode.PREBREWING + lambda coordinator: ( + cast( + PreBrewing, + coordinator.device.dashboard.config[WidgetType.CM_PRE_BREWING], + ).mode + is PreExtractionMode.PREBREWING + ) ), supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in ( - ModelName.LINEA_MICRA, - ModelName.LINEA_MINI, - ModelName.LINEA_MINI_R, + lambda coordinator: ( + coordinator.device.dashboard.model_name + in ( + ModelName.LINEA_MICRA, + ModelName.LINEA_MINI, + ModelName.LINEA_MINI_R, + ) ) ), ), @@ -242,10 +263,12 @@ ENTITIES: tuple[LaMarzoccoNumberEntityDescription, ...] = ( ) ), native_value_fn=( - lambda machine: cast( - BrewByWeightDoses, - machine.dashboard.config[WidgetType.CM_BREW_BY_WEIGHT_DOSES], - ).doses.dose_1.dose + lambda machine: ( + cast( + BrewByWeightDoses, + machine.dashboard.config[WidgetType.CM_BREW_BY_WEIGHT_DOSES], + ).doses.dose_1.dose + ) ), available_fn=lambda coordinator: ( cast( @@ -254,10 +277,12 @@ ENTITIES: tuple[LaMarzoccoNumberEntityDescription, ...] = ( ).scale_connected ), supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in (ModelName.LINEA_MINI, ModelName.LINEA_MINI_R) - and WidgetType.CM_BREW_BY_WEIGHT_DOSES - in coordinator.device.dashboard.config + lambda coordinator: ( + coordinator.device.dashboard.model_name + in (ModelName.LINEA_MINI, ModelName.LINEA_MINI_R) + and WidgetType.CM_BREW_BY_WEIGHT_DOSES + in coordinator.device.dashboard.config + ) ), ), LaMarzoccoNumberEntityDescription( @@ -277,10 +302,12 @@ ENTITIES: tuple[LaMarzoccoNumberEntityDescription, ...] = ( ) ), native_value_fn=( - lambda machine: cast( - BrewByWeightDoses, - machine.dashboard.config[WidgetType.CM_BREW_BY_WEIGHT_DOSES], - ).doses.dose_2.dose + lambda machine: ( + cast( + BrewByWeightDoses, + machine.dashboard.config[WidgetType.CM_BREW_BY_WEIGHT_DOSES], + ).doses.dose_2.dose + ) ), available_fn=lambda coordinator: ( cast( @@ -289,10 +316,12 @@ ENTITIES: tuple[LaMarzoccoNumberEntityDescription, ...] = ( ).scale_connected ), supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in (ModelName.LINEA_MINI, ModelName.LINEA_MINI_R) - and WidgetType.CM_BREW_BY_WEIGHT_DOSES - in coordinator.device.dashboard.config + lambda coordinator: ( + coordinator.device.dashboard.model_name + in (ModelName.LINEA_MINI, ModelName.LINEA_MINI_R) + and WidgetType.CM_BREW_BY_WEIGHT_DOSES + in coordinator.device.dashboard.config + ) ), ), ) diff --git a/homeassistant/components/lamarzocco/select.py b/homeassistant/components/lamarzocco/select.py index 921f6a8d50d..05a52218680 100644 --- a/homeassistant/components/lamarzocco/select.py +++ b/homeassistant/components/lamarzocco/select.py @@ -86,8 +86,10 @@ ENTITIES: tuple[LaMarzoccoSelectEntityDescription, ...] = ( ).target_level ], supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in (ModelName.LINEA_MINI_R, ModelName.LINEA_MICRA) + lambda coordinator: ( + coordinator.device.dashboard.model_name + in (ModelName.LINEA_MINI_R, ModelName.LINEA_MICRA) + ) ), bt_offline_mode=True, ), @@ -103,12 +105,14 @@ ENTITIES: tuple[LaMarzoccoSelectEntityDescription, ...] = ( cast(PreBrewing, machine.dashboard.config[WidgetType.CM_PRE_BREWING]).mode ], supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in ( - ModelName.LINEA_MICRA, - ModelName.LINEA_MINI, - ModelName.LINEA_MINI_R, - ModelName.GS3_AV, + lambda coordinator: ( + coordinator.device.dashboard.model_name + in ( + ModelName.LINEA_MICRA, + ModelName.LINEA_MINI, + ModelName.LINEA_MINI_R, + ModelName.GS3_AV, + ) ) ), ), @@ -147,10 +151,12 @@ ENTITIES: tuple[LaMarzoccoSelectEntityDescription, ...] = ( ).scale_connected ), supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in (ModelName.LINEA_MINI, ModelName.LINEA_MINI_R) - and WidgetType.CM_BREW_BY_WEIGHT_DOSES - in coordinator.device.dashboard.config + lambda coordinator: ( + coordinator.device.dashboard.model_name + in (ModelName.LINEA_MINI, ModelName.LINEA_MINI_R) + and WidgetType.CM_BREW_BY_WEIGHT_DOSES + in coordinator.device.dashboard.config + ) ), ), ) diff --git a/homeassistant/components/lamarzocco/sensor.py b/homeassistant/components/lamarzocco/sensor.py index 2e36db85fc4..fbdad347a3a 100644 --- a/homeassistant/components/lamarzocco/sensor.py +++ b/homeassistant/components/lamarzocco/sensor.py @@ -52,16 +52,18 @@ ENTITIES: tuple[LaMarzoccoSensorEntityDescription, ...] = ( translation_key="coffee_boiler_ready_time", device_class=SensorDeviceClass.TIMESTAMP, value_fn=( - lambda config: cast( - CoffeeBoiler, config[WidgetType.CM_COFFEE_BOILER] - ).ready_start_time + lambda config: ( + cast(CoffeeBoiler, config[WidgetType.CM_COFFEE_BOILER]).ready_start_time + ) ), available_fn=( - lambda coordinator: cast( - CoffeeBoiler, - coordinator.device.dashboard.config[WidgetType.CM_COFFEE_BOILER], - ).ready_start_time - is not None + lambda coordinator: ( + cast( + CoffeeBoiler, + coordinator.device.dashboard.config[WidgetType.CM_COFFEE_BOILER], + ).ready_start_time + is not None + ) ), entity_category=EntityCategory.DIAGNOSTIC, ), @@ -70,20 +72,28 @@ ENTITIES: tuple[LaMarzoccoSensorEntityDescription, ...] = ( translation_key="steam_boiler_ready_time", device_class=SensorDeviceClass.TIMESTAMP, value_fn=( - lambda config: cast( - SteamBoilerLevel, config[WidgetType.CM_STEAM_BOILER_LEVEL] - ).ready_start_time + lambda config: ( + cast( + SteamBoilerLevel, config[WidgetType.CM_STEAM_BOILER_LEVEL] + ).ready_start_time + ) ), supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in (ModelName.LINEA_MICRA, ModelName.LINEA_MINI_R) + lambda coordinator: ( + coordinator.device.dashboard.model_name + in (ModelName.LINEA_MICRA, ModelName.LINEA_MINI_R) + ) ), available_fn=( - lambda coordinator: cast( - SteamBoilerLevel, - coordinator.device.dashboard.config[WidgetType.CM_STEAM_BOILER_LEVEL], - ).ready_start_time - is not None + lambda coordinator: ( + cast( + SteamBoilerLevel, + coordinator.device.dashboard.config[ + WidgetType.CM_STEAM_BOILER_LEVEL + ], + ).ready_start_time + is not None + ) ), entity_category=EntityCategory.DIAGNOSTIC, ), @@ -92,18 +102,22 @@ ENTITIES: tuple[LaMarzoccoSensorEntityDescription, ...] = ( translation_key="brewing_start_time", device_class=SensorDeviceClass.TIMESTAMP, value_fn=( - lambda config: cast( - MachineStatus, config[WidgetType.CM_MACHINE_STATUS] - ).brewing_start_time + lambda config: ( + cast( + MachineStatus, config[WidgetType.CM_MACHINE_STATUS] + ).brewing_start_time + ) ), entity_category=EntityCategory.DIAGNOSTIC, available_fn=( - lambda coordinator: not coordinator.websocket_terminated - and cast( - MachineStatus, - coordinator.device.dashboard.config[WidgetType.CM_MACHINE_STATUS], - ).status - is MachineState.BREWING + lambda coordinator: ( + not coordinator.websocket_terminated + and cast( + MachineStatus, + coordinator.device.dashboard.config[WidgetType.CM_MACHINE_STATUS], + ).status + is MachineState.BREWING + ) ), ), LaMarzoccoSensorEntityDescription( @@ -111,14 +125,19 @@ ENTITIES: tuple[LaMarzoccoSensorEntityDescription, ...] = ( translation_key="steam_boiler_ready_time", device_class=SensorDeviceClass.TIMESTAMP, value_fn=( - lambda config: cast( - SteamBoilerTemperature, config[WidgetType.CM_STEAM_BOILER_TEMPERATURE] - ).ready_start_time + lambda config: ( + cast( + SteamBoilerTemperature, + config[WidgetType.CM_STEAM_BOILER_TEMPERATURE], + ).ready_start_time + ) ), entity_category=EntityCategory.DIAGNOSTIC, supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in (ModelName.GS3_AV, ModelName.GS3_MP, ModelName.LINEA_MINI) + lambda coordinator: ( + coordinator.device.dashboard.model_name + in (ModelName.GS3_AV, ModelName.GS3_MP, ModelName.LINEA_MINI) + ) ), ), LaMarzoccoSensorEntityDescription( @@ -126,17 +145,20 @@ ENTITIES: tuple[LaMarzoccoSensorEntityDescription, ...] = ( translation_key="last_cleaning_time", device_class=SensorDeviceClass.TIMESTAMP, value_fn=( - lambda config: cast( - BackFlush, - config.get( - WidgetType.CM_BACK_FLUSH, BackFlush(status=BackFlushStatus.OFF) - ), - ).last_cleaning_start_time + lambda config: ( + cast( + BackFlush, + config.get( + WidgetType.CM_BACK_FLUSH, BackFlush(status=BackFlushStatus.OFF) + ), + ).last_cleaning_start_time + ) ), entity_category=EntityCategory.DIAGNOSTIC, supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - is not ModelName.GS3_MP + lambda coordinator: ( + coordinator.device.dashboard.model_name is not ModelName.GS3_MP + ) ), ), ) @@ -147,9 +169,12 @@ STATISTIC_ENTITIES: tuple[LaMarzoccoSensorEntityDescription, ...] = ( translation_key="total_coffees_made", state_class=SensorStateClass.TOTAL_INCREASING, value_fn=( - lambda statistics: cast( - CoffeeAndFlushCounter, statistics[WidgetType.COFFEE_AND_FLUSH_COUNTER] - ).total_coffee + lambda statistics: ( + cast( + CoffeeAndFlushCounter, + statistics[WidgetType.COFFEE_AND_FLUSH_COUNTER], + ).total_coffee + ) ), entity_category=EntityCategory.DIAGNOSTIC, ), @@ -158,9 +183,12 @@ STATISTIC_ENTITIES: tuple[LaMarzoccoSensorEntityDescription, ...] = ( translation_key="total_flushes_done", state_class=SensorStateClass.TOTAL_INCREASING, value_fn=( - lambda statistics: cast( - CoffeeAndFlushCounter, statistics[WidgetType.COFFEE_AND_FLUSH_COUNTER] - ).total_flush + lambda statistics: ( + cast( + CoffeeAndFlushCounter, + statistics[WidgetType.COFFEE_AND_FLUSH_COUNTER], + ).total_flush + ) ), entity_category=EntityCategory.DIAGNOSTIC, ), diff --git a/homeassistant/components/lamarzocco/switch.py b/homeassistant/components/lamarzocco/switch.py index 8f2299df745..e1d87eeb14e 100644 --- a/homeassistant/components/lamarzocco/switch.py +++ b/homeassistant/components/lamarzocco/switch.py @@ -44,14 +44,18 @@ ENTITIES: tuple[LaMarzoccoSwitchEntityDescription, ...] = ( translation_key="steam_boiler", control_fn=lambda machine, state: machine.set_steam(state), is_on_fn=( - lambda machine: cast( - SteamBoilerLevel, - machine.dashboard.config[WidgetType.CM_STEAM_BOILER_LEVEL], - ).enabled + lambda machine: ( + cast( + SteamBoilerLevel, + machine.dashboard.config[WidgetType.CM_STEAM_BOILER_LEVEL], + ).enabled + ) ), supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - in (ModelName.LINEA_MINI_R, ModelName.LINEA_MICRA) + lambda coordinator: ( + coordinator.device.dashboard.model_name + in (ModelName.LINEA_MINI_R, ModelName.LINEA_MICRA) + ) ), bt_offline_mode=True, ), @@ -60,14 +64,18 @@ ENTITIES: tuple[LaMarzoccoSwitchEntityDescription, ...] = ( translation_key="steam_boiler", control_fn=lambda machine, state: machine.set_steam(state), is_on_fn=( - lambda machine: cast( - SteamBoilerTemperature, - machine.dashboard.config[WidgetType.CM_STEAM_BOILER_TEMPERATURE], - ).enabled + lambda machine: ( + cast( + SteamBoilerTemperature, + machine.dashboard.config[WidgetType.CM_STEAM_BOILER_TEMPERATURE], + ).enabled + ) ), supported_fn=( - lambda coordinator: coordinator.device.dashboard.model_name - not in (ModelName.LINEA_MINI_R, ModelName.LINEA_MICRA) + lambda coordinator: ( + coordinator.device.dashboard.model_name + not in (ModelName.LINEA_MINI_R, ModelName.LINEA_MICRA) + ) ), bt_offline_mode=True, ), @@ -80,7 +88,9 @@ ENTITIES: tuple[LaMarzoccoSwitchEntityDescription, ...] = ( mode=machine.schedule.smart_wake_up_sleep.smart_stand_by_after, minutes=machine.schedule.smart_wake_up_sleep.smart_stand_by_minutes, ), - is_on_fn=lambda machine: machine.schedule.smart_wake_up_sleep.smart_stand_by_enabled, + is_on_fn=lambda machine: ( + machine.schedule.smart_wake_up_sleep.smart_stand_by_enabled + ), bt_offline_mode=True, ), ) @@ -91,10 +101,12 @@ MAIN_SWITCH_ENTITY = LaMarzoccoSwitchEntityDescription( name=None, control_fn=lambda machine, state: machine.set_power(state), is_on_fn=( - lambda machine: cast( - MachineStatus, machine.dashboard.config[WidgetType.CM_MACHINE_STATUS] - ).mode - is MachineMode.BREWING_MODE + lambda machine: ( + cast( + MachineStatus, machine.dashboard.config[WidgetType.CM_MACHINE_STATUS] + ).mode + is MachineMode.BREWING_MODE + ) ), bt_offline_mode=True, ) diff --git a/homeassistant/components/landisgyr_heat_meter/sensor.py b/homeassistant/components/landisgyr_heat_meter/sensor.py index 6a7d7c63103..9e9ef889500 100644 --- a/homeassistant/components/landisgyr_heat_meter/sensor.py +++ b/homeassistant/components/landisgyr_heat_meter/sensor.py @@ -244,9 +244,9 @@ HEAT_METER_SENSOR_TYPES = ( icon="mdi:clock-outline", device_class=SensorDeviceClass.TIMESTAMP, entity_category=EntityCategory.DIAGNOSTIC, - value_fn=lambda res: dt_util.as_utc(res.meter_date_time) - if res.meter_date_time - else None, + value_fn=lambda res: ( + dt_util.as_utc(res.meter_date_time) if res.meter_date_time else None + ), ), HeatMeterSensorEntityDescription( key="measuring_range_m3ph", diff --git a/homeassistant/components/letpot/binary_sensor.py b/homeassistant/components/letpot/binary_sensor.py index e5939abc24d..54b1499118a 100644 --- a/homeassistant/components/letpot/binary_sensor.py +++ b/homeassistant/components/letpot/binary_sensor.py @@ -57,10 +57,12 @@ BINARY_SENSORS: tuple[LetPotBinarySensorEntityDescription, ...] = ( is_on_fn=lambda status: status.pump_status == 1, device_class=BinarySensorDeviceClass.RUNNING, supported_fn=( - lambda coordinator: DeviceFeature.PUMP_STATUS - in coordinator.device_client.device_info( - coordinator.device.serial_number - ).features + lambda coordinator: ( + DeviceFeature.PUMP_STATUS + in coordinator.device_client.device_info( + coordinator.device.serial_number + ).features + ) ), ), LetPotBinarySensorEntityDescription( diff --git a/homeassistant/components/letpot/number.py b/homeassistant/components/letpot/number.py index 2061b419ddb..1ab632e067e 100644 --- a/homeassistant/components/letpot/number.py +++ b/homeassistant/components/letpot/number.py @@ -38,12 +38,14 @@ NUMBERS: tuple[LetPotNumberEntityDescription, ...] = ( key="light_brightness_levels", translation_key="light_brightness", value_fn=( - lambda coordinator: coordinator.device_client.get_light_brightness_levels( - coordinator.device.serial_number - ).index(coordinator.data.light_brightness) - + 1 - if coordinator.data.light_brightness is not None - else None + lambda coordinator: ( + coordinator.device_client.get_light_brightness_levels( + coordinator.device.serial_number + ).index(coordinator.data.light_brightness) + + 1 + if coordinator.data.light_brightness is not None + else None + ) ), set_value_fn=( lambda device_client, serial, value: device_client.set_light_brightness( @@ -52,10 +54,12 @@ NUMBERS: tuple[LetPotNumberEntityDescription, ...] = ( ) ), supported_fn=( - lambda coordinator: DeviceFeature.LIGHT_BRIGHTNESS_LEVELS - in coordinator.device_client.device_info( - coordinator.device.serial_number - ).features + lambda coordinator: ( + DeviceFeature.LIGHT_BRIGHTNESS_LEVELS + in coordinator.device_client.device_info( + coordinator.device.serial_number + ).features + ) ), native_min_value=float(1), max_value_fn=lambda coordinator: float( diff --git a/homeassistant/components/letpot/select.py b/homeassistant/components/letpot/select.py index 0a9f6b07046..7508e80329e 100644 --- a/homeassistant/components/letpot/select.py +++ b/homeassistant/components/letpot/select.py @@ -65,9 +65,11 @@ SELECTORS: tuple[LetPotSelectEntityDescription, ...] = ( translation_key="display_temperature_unit", options=[x.name.lower() for x in TemperatureUnit], value_fn=( - lambda coordinator: coordinator.data.temperature_unit.name.lower() - if coordinator.data.temperature_unit is not None - else None + lambda coordinator: ( + coordinator.data.temperature_unit.name.lower() + if coordinator.data.temperature_unit is not None + else None + ) ), set_value_fn=( lambda device_client, serial, option: device_client.set_temperature_unit( @@ -75,10 +77,12 @@ SELECTORS: tuple[LetPotSelectEntityDescription, ...] = ( ) ), supported_fn=( - lambda coordinator: DeviceFeature.TEMPERATURE_SET_UNIT - in coordinator.device_client.device_info( - coordinator.device.serial_number - ).features + lambda coordinator: ( + DeviceFeature.TEMPERATURE_SET_UNIT + in coordinator.device_client.device_info( + coordinator.device.serial_number + ).features + ) ), entity_category=EntityCategory.CONFIG, ), @@ -92,10 +96,12 @@ SELECTORS: tuple[LetPotSelectEntityDescription, ...] = ( value_fn=_get_brightness_low_high_value, set_value_fn=_set_brightness_low_high_value, supported_fn=( - lambda coordinator: DeviceFeature.LIGHT_BRIGHTNESS_LOW_HIGH - in coordinator.device_client.device_info( - coordinator.device.serial_number - ).features + lambda coordinator: ( + DeviceFeature.LIGHT_BRIGHTNESS_LOW_HIGH + in coordinator.device_client.device_info( + coordinator.device.serial_number + ).features + ) ), entity_category=EntityCategory.CONFIG, ), @@ -104,9 +110,11 @@ SELECTORS: tuple[LetPotSelectEntityDescription, ...] = ( translation_key="light_mode", options=[x.name.lower() for x in LightMode], value_fn=( - lambda coordinator: coordinator.data.light_mode.name.lower() - if coordinator.data.light_mode is not None - else None + lambda coordinator: ( + coordinator.data.light_mode.name.lower() + if coordinator.data.light_mode is not None + else None + ) ), set_value_fn=( lambda device_client, serial, option: device_client.set_light_mode( diff --git a/homeassistant/components/letpot/sensor.py b/homeassistant/components/letpot/sensor.py index 841b8720616..4391a6d8b0e 100644 --- a/homeassistant/components/letpot/sensor.py +++ b/homeassistant/components/letpot/sensor.py @@ -49,10 +49,12 @@ SENSORS: tuple[LetPotSensorEntityDescription, ...] = ( device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, supported_fn=( - lambda coordinator: DeviceFeature.TEMPERATURE - in coordinator.device_client.device_info( - coordinator.device.serial_number - ).features + lambda coordinator: ( + DeviceFeature.TEMPERATURE + in coordinator.device_client.device_info( + coordinator.device.serial_number + ).features + ) ), ), LetPotSensorEntityDescription( @@ -62,10 +64,12 @@ SENSORS: tuple[LetPotSensorEntityDescription, ...] = ( native_unit_of_measurement_fn=lambda _: PERCENTAGE, state_class=SensorStateClass.MEASUREMENT, supported_fn=( - lambda coordinator: DeviceFeature.WATER_LEVEL - in coordinator.device_client.device_info( - coordinator.device.serial_number - ).features + lambda coordinator: ( + DeviceFeature.WATER_LEVEL + in coordinator.device_client.device_info( + coordinator.device.serial_number + ).features + ) ), ), ) diff --git a/homeassistant/components/letpot/switch.py b/homeassistant/components/letpot/switch.py index d22bc85f116..119635b513c 100644 --- a/homeassistant/components/letpot/switch.py +++ b/homeassistant/components/letpot/switch.py @@ -50,10 +50,12 @@ SWITCHES: tuple[LetPotSwitchEntityDescription, ...] = ( ), entity_category=EntityCategory.CONFIG, supported_fn=( - lambda coordinator: DeviceFeature.PUMP_AUTO - in coordinator.device_client.device_info( - coordinator.device.serial_number - ).features + lambda coordinator: ( + DeviceFeature.PUMP_AUTO + in coordinator.device_client.device_info( + coordinator.device.serial_number + ).features + ) ), ), LetPotSwitchEntityDescription( diff --git a/homeassistant/components/linkplay/select.py b/homeassistant/components/linkplay/select.py index ebf5a05512a..d11b0540663 100644 --- a/homeassistant/components/linkplay/select.py +++ b/homeassistant/components/linkplay/select.py @@ -52,9 +52,10 @@ SELECT_TYPES_WIIM: tuple[LinkPlaySelectEntityDescription, ...] = ( translation_key="audio_output_hardware_mode", current_option_fn=_get_current_option, set_option_fn=( - lambda linkplay_bridge, - option: linkplay_bridge.player.set_audio_output_hw_mode( - AUDIO_OUTPUT_HW_MODE_MAP_INV[option] + lambda linkplay_bridge, option: ( + linkplay_bridge.player.set_audio_output_hw_mode( + AUDIO_OUTPUT_HW_MODE_MAP_INV[option] + ) ) ), options=list(AUDIO_OUTPUT_HW_MODE_MAP_INV), diff --git a/homeassistant/components/litterrobot/select.py b/homeassistant/components/litterrobot/select.py index 9ee186006b3..9bf8691cc8a 100644 --- a/homeassistant/components/litterrobot/select.py +++ b/homeassistant/components/litterrobot/select.py @@ -48,9 +48,11 @@ ROBOT_SELECT_MAP: dict[type[Robot], tuple[RobotSelectEntityDescription, ...]] = key="globe_brightness", translation_key="globe_brightness", current_fn=( - lambda robot: bri.name.lower() - if (bri := robot.night_light_level) is not None - else None + lambda robot: ( + bri.name.lower() + if (bri := robot.night_light_level) is not None + else None + ) ), options_fn=lambda _: [level.name.lower() for level in BrightnessLevel], select_fn=( @@ -63,9 +65,11 @@ ROBOT_SELECT_MAP: dict[type[Robot], tuple[RobotSelectEntityDescription, ...]] = key="globe_light", translation_key="globe_light", current_fn=( - lambda robot: mode.name.lower() - if (mode := robot.night_light_mode) is not None - else None + lambda robot: ( + mode.name.lower() + if (mode := robot.night_light_mode) is not None + else None + ) ), options_fn=lambda _: [mode.name.lower() for mode in NightLightMode], select_fn=( @@ -78,9 +82,11 @@ ROBOT_SELECT_MAP: dict[type[Robot], tuple[RobotSelectEntityDescription, ...]] = key="panel_brightness", translation_key="brightness_level", current_fn=( - lambda robot: bri.name.lower() - if (bri := robot.panel_brightness) is not None - else None + lambda robot: ( + bri.name.lower() + if (bri := robot.panel_brightness) is not None + else None + ) ), options_fn=lambda _: [level.name.lower() for level in BrightnessLevel], select_fn=( diff --git a/homeassistant/components/litterrobot/sensor.py b/homeassistant/components/litterrobot/sensor.py index ecbf805bea0..7f408a5afb6 100644 --- a/homeassistant/components/litterrobot/sensor.py +++ b/homeassistant/components/litterrobot/sensor.py @@ -169,8 +169,8 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = { state_class=SensorStateClass.TOTAL, last_reset_fn=dt_util.start_of_local_day, value_fn=( - lambda robot: ( - robot.get_food_dispensed_since(dt_util.start_of_local_day()) + lambda robot: robot.get_food_dispensed_since( + dt_util.start_of_local_day() ) ), ),