mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 03:03:17 +01:00
Reformat lambda (a-l) (#162377)
This commit is contained in:
@@ -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
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -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))
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -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(),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
]
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"]
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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: (
|
||||
|
||||
@@ -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
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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=(
|
||||
|
||||
@@ -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()
|
||||
)
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user