Trafikverket - Swedish train information - Testers

If anyone wish to try out trafikverket custom component it would be nice.

Forked from @AnderssonPeter 's file on his gist and made some small corrections to make it work.
I have not made any quality checks other than basic tests…

https://github.com/endor-force/ha-trafikverket

1 Like

Made more adjustments.
It’s now proposed as a standard component to hass.

This is now an accepted pull request and merged as standard to dev branch preparing for coming release.
Some adjustments and cleanups has been made so the custom component should be removed once it hit the shelves as a standard component.

So it is washed and released as standard component since 0.96.

We can see a spike in downloads and an increase of pytrafikverket library downloads which indicate that some people started trying it out :slight_smile:
https://pypistats.org/packages/pytrafikverket

@AnderssonPeter , great job on setting the foundation for this one!

I hope it can come to good use for the commuters out there.

Great to see some Swedish components for Home Assistant! I was wondering if there is any possibility to make the state show time instead of date and time? I’m trying to make this look nice in my Lovelace setup hehe :slight_smile:

How does it look in lovelace?

When I tried it it looked like below, but it was on unused entities not on a card in lovelace.
59961804-d8a63d00-94dc-11e9-8033-19b5dd01c125

Looks like this to me

It’s totaly my bad! For some reason I used the “sensor” card instead of “entities”…

Hi,
I’m trying to use this integration.
However I cannot get this to work properly.

I get the entity “sensor.nasta_tag_till_malmo” but it’s displaying “invalid date”.
I do not get the entity where I placed a specific time and date.
What is wrong with the code below?
I have tried with “quotes” and without with no avail.
The integration is found here

my code:

- platform: trafikverket_train
  api_key: my api code here
  trains:
  - name: "Tåg till Malmö"
    from: Dösjebro
    to: Malmö C
    time: "07:53"
    weekday: [mon, tue, wed, thu, fri]

  - name: "Nästa tåg till Malmö"
    from: Dösjebro
    to: Malmö C

Hi,

The departure seems to be 7.52 on the first one but regardless of which direct train to Malmö C i try with i get same error, departure not found…
I can search for specific times to Lund C on monday using the pytrafikeverket module… which is strange.
Also the departure 9:25 on monday is working, but only with to: “Trelleborg”

Second one works fine for me, could be worth testing with to: “Trelleborg” if it is the direct train you’re looking for.

image

Hi, thanks for the reply.
Yes, I’m only looking for the direct train.
Tried to place “Trelleborg” as final destination instead (end station for the train).
Still only one senor created (the last one in the code).

- platform: trafikverket_train
  api_key: <my secret code>
  trains:
  - name: "Tåg till Malmö"
    from: Dösjebro
    to: Trelleborg
    time: "07:52"
    weekday: [mon, tue, wed, thu, fri]

  - name: "Nästa tåg till Malmö"
    from: "Dösjebro"
    to: "Trelleborg"

This is what’s presented to me.

I also have this error in the log

Logger: homeassistant.components.sensor
Source: components/trafikverket_train/sensor.py:152 
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22)) 
First occurred: 17:17:03 (1 occurrences) 
Last logged: 17:17:03

trafikverket_train: Error on device update!

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update await task File "/usr/src/homeassistant/homeassistant/components/trafikverket_train/sensor.py", line 152, in async_update self._departure_state = self._state.get_state().name AttributeError: 'NoneType' object has no attribute 'get_state'