home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.98k stars 31.03k forks source link

Viaggiatreno - Timestamp is never updated #63159

Closed boggiano closed 2 years ago

boggiano commented 2 years ago

The problem

The timestamp data, used in the uri variable is never updated. It works the first time, when HA is created but it became useless after that.

I just modified the code of sensor.py from:

   async def async_update(self):
        """Update state."""
        uri = self.uri
        res = await async_http_request(self.hass, uri)

to:

   async def async_update(self):
        """Update state."""
        uri = self.uri
        timeNow = timestamp=int(time.time()) * 1000
        newTime = "/" + str(timeNow)
        uri2 = re.sub(r"/[0-9]{1,}$", newTime, uri)
        res = await async_http_request(self.hass, uri2)

and it's working.

What version of Home Assistant Core has the issue?

core-2021.12.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

viaggiaterno

Link to integration documentation on our website

https://www.home-assistant.io/integrations/viaggiatreno/

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Adding the line: _LOGGER.info("Calling la URL: %s", uri) into async def async_http_request(hass, uri):

I saw the same URI, time after time.

probot-home-assistant[bot] commented 2 years ago

viaggiatreno documentation viaggiatreno source (message by IssueLinks)