Update viaggiatreno component due to API changes (#56463)

This commit is contained in:
Fabrizio Tarizzo 2021-09-30 13:22:43 +02:00 committed by GitHub
parent c9e1a03fe2
commit ef4b6d7bdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
"""Support for the Italian train system using ViaggiaTreno API.""" """Support for the Italian train system using ViaggiaTreno API."""
import asyncio import asyncio
import logging import logging
import time
import aiohttp import aiohttp
import async_timeout import async_timeout
@ -17,7 +18,7 @@ ATTRIBUTION = "Powered by ViaggiaTreno Data"
VIAGGIATRENO_ENDPOINT = ( VIAGGIATRENO_ENDPOINT = (
"http://www.viaggiatreno.it/viaggiatrenonew/" "http://www.viaggiatreno.it/viaggiatrenonew/"
"resteasy/viaggiatreno/andamentoTreno/" "resteasy/viaggiatreno/andamentoTreno/"
"{station_id}/{train_id}" "{station_id}/{train_id}/{timestamp}"
) )
REQUEST_TIMEOUT = 5 # seconds REQUEST_TIMEOUT = 5 # seconds
@ -94,7 +95,7 @@ class ViaggiaTrenoSensor(SensorEntity):
self._name = name self._name = name
self.uri = VIAGGIATRENO_ENDPOINT.format( self.uri = VIAGGIATRENO_ENDPOINT.format(
station_id=station_id, train_id=train_id station_id=station_id, train_id=train_id, timestamp=int(time.time()) * 1000
) )
@property @property