mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Make launch library lambdas single line (#64424)
This commit is contained in:
parent
b82a57d861
commit
29d13110af
@ -60,12 +60,12 @@ SENSOR_DESCRIPTIONS: tuple[NextLaunchSensorEntityDescription, ...] = (
|
|||||||
key="next_launch",
|
key="next_launch",
|
||||||
icon="mdi:rocket-launch",
|
icon="mdi:rocket-launch",
|
||||||
name="Next launch",
|
name="Next launch",
|
||||||
value_fn=lambda next_launch: next_launch.name,
|
value_fn=lambda nl: nl.name,
|
||||||
attributes_fn=lambda next_launch: {
|
attributes_fn=lambda nl: {
|
||||||
"provider": next_launch.launch_service_provider.name,
|
"provider": nl.launch_service_provider.name,
|
||||||
"pad": next_launch.pad.name,
|
"pad": nl.pad.name,
|
||||||
"facility": next_launch.pad.location.name,
|
"facility": nl.pad.location.name,
|
||||||
"provider_country_code": next_launch.pad.location.country_code,
|
"provider_country_code": nl.pad.location.country_code,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
NextLaunchSensorEntityDescription(
|
NextLaunchSensorEntityDescription(
|
||||||
@ -73,11 +73,11 @@ SENSOR_DESCRIPTIONS: tuple[NextLaunchSensorEntityDescription, ...] = (
|
|||||||
icon="mdi:clock-outline",
|
icon="mdi:clock-outline",
|
||||||
name="Launch time",
|
name="Launch time",
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
value_fn=lambda next_launch: parse_datetime(next_launch.net),
|
value_fn=lambda nl: parse_datetime(nl.net),
|
||||||
attributes_fn=lambda next_launch: {
|
attributes_fn=lambda nl: {
|
||||||
"window_start": next_launch.window_start,
|
"window_start": nl.window_start,
|
||||||
"window_end": next_launch.window_end,
|
"window_end": nl.window_end,
|
||||||
"stream_live": next_launch.webcast_live,
|
"stream_live": nl.webcast_live,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
NextLaunchSensorEntityDescription(
|
NextLaunchSensorEntityDescription(
|
||||||
@ -85,31 +85,25 @@ SENSOR_DESCRIPTIONS: tuple[NextLaunchSensorEntityDescription, ...] = (
|
|||||||
icon="mdi:dice-multiple",
|
icon="mdi:dice-multiple",
|
||||||
name="Launch Probability",
|
name="Launch Probability",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
value_fn=lambda next_launch: next_launch.probability
|
value_fn=lambda nl: None if nl.probability == -1 else nl.probability,
|
||||||
if next_launch.probability != -1
|
attributes_fn=lambda nl: None,
|
||||||
else None,
|
|
||||||
attributes_fn=lambda next_launch: None,
|
|
||||||
),
|
),
|
||||||
NextLaunchSensorEntityDescription(
|
NextLaunchSensorEntityDescription(
|
||||||
key="launch_status",
|
key="launch_status",
|
||||||
icon="mdi:rocket-launch",
|
icon="mdi:rocket-launch",
|
||||||
name="Launch status",
|
name="Launch status",
|
||||||
value_fn=lambda next_launch: next_launch.status.name,
|
value_fn=lambda nl: nl.status.name,
|
||||||
attributes_fn=lambda next_launch: {
|
attributes_fn=lambda nl: {"reason": nl.holdreason} if nl.inhold else None,
|
||||||
"reason": next_launch.holdreason,
|
|
||||||
}
|
|
||||||
if next_launch.inhold
|
|
||||||
else None,
|
|
||||||
),
|
),
|
||||||
NextLaunchSensorEntityDescription(
|
NextLaunchSensorEntityDescription(
|
||||||
key="launch_mission",
|
key="launch_mission",
|
||||||
icon="mdi:orbit",
|
icon="mdi:orbit",
|
||||||
name="Launch mission",
|
name="Launch mission",
|
||||||
value_fn=lambda next_launch: next_launch.mission.name,
|
value_fn=lambda nl: nl.mission.name,
|
||||||
attributes_fn=lambda next_launch: {
|
attributes_fn=lambda nl: {
|
||||||
"mission_type": next_launch.mission.type,
|
"mission_type": nl.mission.type,
|
||||||
"target_orbit": next_launch.mission.orbit.name,
|
"target_orbit": nl.mission.orbit.name,
|
||||||
"description": next_launch.mission.description,
|
"description": nl.mission.description,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user