mirror of
https://github.com/home-assistant/core.git
synced 2025-05-21 06:17:06 +00:00
Update NSAPI to 3.0.2 (#30971)
* Bump NSAPI version to 3.0.1 * Compatibility with NSAPI 3.0.1 response * Removed commented code * Obsolete setups receive an upgrade notification * Bump NS-API to 3.0.2 * Assign platform values directly * Removed obsolete config warning * Improved reference to obsolete password
This commit is contained in:
parent
13aae8b5ec
commit
9bb8b2bc00
@ -2,7 +2,7 @@
|
||||
"domain": "nederlandse_spoorwegen",
|
||||
"name": "Nederlandse Spoorwegen (NS)",
|
||||
"documentation": "https://www.home-assistant.io/integrations/nederlandse_spoorwegen",
|
||||
"requirements": ["nsapi==3.0.0"],
|
||||
"requirements": ["nsapi==3.0.2"],
|
||||
"dependencies": [],
|
||||
"codeowners": ["@YarmoM"]
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
requests.exceptions.ConnectionError,
|
||||
requests.exceptions.HTTPError,
|
||||
) as error:
|
||||
_LOGGER.error("Couldn't fetch stations, API password correct?: %s", error)
|
||||
_LOGGER.error("Couldn't fetch stations, API key correct?: %s", error)
|
||||
return
|
||||
|
||||
sensors = []
|
||||
@ -127,20 +127,16 @@ class NSDepartureSensor(Entity):
|
||||
# Static attributes
|
||||
attributes = {
|
||||
"going": self._trips[0].going,
|
||||
"departure_time_planned": self._trips[0].departure_time_planned.strftime(
|
||||
"%H:%M"
|
||||
),
|
||||
"departure_time_planned": None,
|
||||
"departure_time_actual": None,
|
||||
"departure_delay": False,
|
||||
"departure_platform_planned": self._trips[0].departure_platform_planned,
|
||||
"departure_platform_actual": None,
|
||||
"arrival_time_planned": self._trips[0].arrival_time_planned.strftime(
|
||||
"%H:%M"
|
||||
),
|
||||
"departure_platform_actual": self._trips[0].departure_platform_actual,
|
||||
"arrival_time_planned": None,
|
||||
"arrival_time_actual": None,
|
||||
"arrival_delay": False,
|
||||
"arrival_platform_platform": self._trips[0].arrival_platform_planned,
|
||||
"arrival_platform_actual": None,
|
||||
"arrival_platform_planned": self._trips[0].arrival_platform_planned,
|
||||
"arrival_platform_actual": self._trips[0].arrival_platform_actual,
|
||||
"next": None,
|
||||
"status": self._trips[0].status.lower(),
|
||||
"transfers": self._trips[0].nr_transfers,
|
||||
@ -149,25 +145,46 @@ class NSDepartureSensor(Entity):
|
||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
||||
}
|
||||
|
||||
# Departure attributes
|
||||
# Planned departure attributes
|
||||
if self._trips[0].departure_time_planned is not None:
|
||||
attributes["departure_time_planned"] = self._trips[
|
||||
0
|
||||
].departure_time_planned.strftime("%H:%M")
|
||||
|
||||
# Actual departure attributes
|
||||
if self._trips[0].departure_time_actual is not None:
|
||||
attributes["departure_time_actual"] = self._trips[
|
||||
0
|
||||
].departure_time_actual.strftime("%H:%M")
|
||||
attributes["departure_delay"] = True
|
||||
attributes["departure_platform_actual"] = self._trips[
|
||||
0
|
||||
].departure_platform_actual
|
||||
|
||||
# Arrival attributes
|
||||
# Delay departure attributes
|
||||
if (
|
||||
attributes["departure_time_planned"]
|
||||
and attributes["departure_time_actual"]
|
||||
and attributes["departure_time_planned"]
|
||||
!= attributes["departure_time_actual"]
|
||||
):
|
||||
attributes["departure_delay"] = True
|
||||
|
||||
# Planned arrival attributes
|
||||
if self._trips[0].arrival_time_planned is not None:
|
||||
attributes["arrival_time_planned"] = self._trips[
|
||||
0
|
||||
].arrival_time_planned.strftime("%H:%M")
|
||||
|
||||
# Actual arrival attributes
|
||||
if self._trips[0].arrival_time_actual is not None:
|
||||
attributes["arrival_time_actual"] = self._trips[
|
||||
0
|
||||
].arrival_time_actual.strftime("%H:%M")
|
||||
|
||||
# Delay arrival attributes
|
||||
if (
|
||||
attributes["arrival_time_planned"]
|
||||
and attributes["arrival_time_actual"]
|
||||
and attributes["arrival_time_planned"] != attributes["arrival_time_actual"]
|
||||
):
|
||||
attributes["arrival_delay"] = True
|
||||
attributes["arrival_platform_actual"] = self._trips[
|
||||
0
|
||||
].arrival_platform_actual
|
||||
|
||||
# Next attributes
|
||||
if self._trips[1].departure_time_actual is not None:
|
||||
|
@ -905,7 +905,7 @@ niko-home-control==0.2.1
|
||||
niluclient==0.1.2
|
||||
|
||||
# homeassistant.components.nederlandse_spoorwegen
|
||||
nsapi==3.0.0
|
||||
nsapi==3.0.2
|
||||
|
||||
# homeassistant.components.nsw_fuel_station
|
||||
nsw-fuel-api-client==1.0.10
|
||||
|
Loading…
x
Reference in New Issue
Block a user