Add launch status sensor for launch_library (#64382)

This commit is contained in:
Simon Hansen 2022-01-18 22:39:37 +01:00 committed by GitHub
parent 13fe5d8216
commit 57bcddbba2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -33,6 +33,7 @@ from .const import (
ATTR_LAUNCH_PAD,
ATTR_LAUNCH_PAD_COUNTRY_CODE,
ATTR_LAUNCH_PROVIDER,
ATTR_REASON,
ATTR_STREAM_LIVE,
ATTR_WINDOW_END,
ATTR_WINDOW_START,
@ -40,6 +41,7 @@ from .const import (
DEFAULT_NAME,
DOMAIN,
LAUNCH_PROBABILITY,
LAUNCH_STATUS,
LAUNCH_TIME,
NEXT_LAUNCH,
)
@ -102,6 +104,17 @@ SENSOR_DESCRIPTIONS: tuple[NextLaunchSensorEntityDescription, ...] = (
else STATE_UNKNOWN,
attributes_fn=lambda next_launch: None,
),
NextLaunchSensorEntityDescription(
key=LAUNCH_STATUS,
icon="mdi:rocket-launch",
name="Launch status",
value_fn=lambda next_launch: next_launch.status.name,
attributes_fn=lambda next_launch: {
ATTR_REASON: next_launch.holdreason,
}
if next_launch.inhold
else None,
),
)