Add launch mission sensor for launch_library (#64387)

This commit is contained in:
Simon Hansen 2022-01-19 09:28:07 +01:00 committed by GitHub
parent 2f5f6cc05e
commit 6fcf643d5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -29,17 +29,21 @@ from homeassistant.helpers.update_coordinator import (
from homeassistant.util.dt import parse_datetime
from .const import (
ATTR_DESCRIPTION,
ATTR_LAUNCH_FACILITY,
ATTR_LAUNCH_PAD,
ATTR_LAUNCH_PAD_COUNTRY_CODE,
ATTR_LAUNCH_PROVIDER,
ATTR_ORBIT,
ATTR_REASON,
ATTR_STREAM_LIVE,
ATTR_TYPE,
ATTR_WINDOW_END,
ATTR_WINDOW_START,
ATTRIBUTION,
DEFAULT_NAME,
DOMAIN,
LAUNCH_MISSION,
LAUNCH_PROBABILITY,
LAUNCH_STATUS,
LAUNCH_TIME,
@ -115,6 +119,17 @@ SENSOR_DESCRIPTIONS: tuple[NextLaunchSensorEntityDescription, ...] = (
if next_launch.inhold
else None,
),
NextLaunchSensorEntityDescription(
key=LAUNCH_MISSION,
icon="mdi:orbit",
name="Launch mission",
value_fn=lambda next_launch: next_launch.mission.name,
attributes_fn=lambda next_launch: {
ATTR_TYPE: next_launch.mission.type,
ATTR_ORBIT: next_launch.mission.orbit.name,
ATTR_DESCRIPTION: next_launch.mission.description,
},
),
)