Remove useless check in launch_library (#54393)

This commit is contained in:
Joakim Sørensen 2021-08-10 15:03:12 +02:00 committed by GitHub
parent 1d40a6e407
commit 8ea5a0dbc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,17 +57,13 @@ class LaunchLibrarySensor(SensorEntity):
_LOGGER.error("Error getting data, %s", exception)
self._attr_available = False
else:
if launches and (
next_launch := next((launch for launch in launches), None)
):
if next_launch := next((launch for launch in launches), None):
self._attr_available = True
self._attr_state = next_launch.name
self._attr_extra_state_attributes.update(
{
ATTR_LAUNCH_TIME: next_launch.net,
ATTR_AGENCY: next_launch.launch_service_provider.name,
ATTR_AGENCY_COUNTRY_CODE: next_launch.pad.location.country_code,
ATTR_STREAM: next_launch.webcast_live,
ATTR_ATTRIBUTION: ATTRIBUTION,
}
)
self._attr_extra_state_attributes = {
ATTR_LAUNCH_TIME: next_launch.net,
ATTR_AGENCY: next_launch.launch_service_provider.name,
ATTR_AGENCY_COUNTRY_CODE: next_launch.pad.location.country_code,
ATTR_STREAM: next_launch.webcast_live,
ATTR_ATTRIBUTION: ATTRIBUTION,
}