Anyone using västtrafik component?

Hey @EdwardTFN,

Tried your setup and works great. Getting an error on the timedate template though, you get the same?
Not comfortable with code so don’t really know how to interpret it…

Template variable error: ‘dict object’ has no attribute ‘DepartureBoard’ when rendering ‘{{ (value_json.DepartureBoard.serverdate + ’ ’ + value_json.DepartureBoard.servertime) | as_timestamp | timestamp_local }}’

Any chance of getting an update of the REST config? Västtrafik seems to have changed API in their end and I can’t seem to get the config correct with the new urls :confused:

They changed the api quite a lot and I haven’t found time to fix it. Let’s see if I can work on this this weekend. I will let you know.

1 Like

Hi! Any news on the progress? Anything I can do? (not a python coder, but php) :slight_smile:

1 Like

I’m so sorry for the loooong delay here.
I finally found some time to look at this. You will find my updated sensor here, and this is my card used to display the values:

                    type: custom:flex-table-card
                    title: Västtrafik - SKF
                    strict: true
                    max_rows: 20
                      - Departure+
                      include: sensor.vasttrafik_departure_table_city_centre
                      - name: Sort column
                        data: Departure
                        align: center
                        hidden: true
                        modify: >-
                      - name: Line
                        data: Departure
                        modify: x.serviceJourney.line.shortName
                        align: center
                        hidden: true
                        style: >-
                          'background-color: ' +
                          x.serviceJourney.line.backgroundColor + ';' + 'color:
                          ' + x.serviceJourney.line.foregroundColor + ';'
                      - name: Line
                        data: Departure
                        modify: >-
                          '<div style="padding: 1px 1px 4px 1px; height: 16px;
                          color: ' + x.serviceJourney.line.foregroundColor + '; background-color: ' +
                          x.serviceJourney.line.backgroundColor + '">&nbsp;' +
                          x.serviceJourney.line.shortName + '&nbsp;</div>'
                        align: center
                      - name: Direction
                        data: Departure
                        modify: x.serviceJourney.directionDetails.shortDirection
                      - name: Departure
                        data: Departure
                        align: center
                        modify: >-
                          var minutes =

                          if (minutes>=60 || isNaN(minutes))
                            {{ x.estimatedOtherwisePlannedTime }}
                          else if (minutes == 0)
                            {{ minutes }}
                      - name: Platform
                        data: Departure
                        align: center
                        modify: >-
                          x.stopPoint.platform + '&nbsp;<ha-icon
                          icon="mdi:' +
                          "tram-side") +  '"></ha-icon>'
                      tbody tr:nth-child(odd): 'color: #f2f2f2; background-color: #535B64;'
                      tbody tr:nth-child(even): 'color: #f2f2f2; background-color: #3C4650;'
                    style: |
                      ha-card {
                        --mdc-icon-size: 16px;
                        background-color: #3C4650;
                        color: #f2f2f2;

Unfortunately the API isn’t providing the correct line color. I’ve already sent an email to Västtrafik support.

The issue with the color was fixed from Västtrafik side, so all good now.

That is some great work @EdwardTFN, thank you so much! As your solution is superior to the one included in HASS in every way, do you think it would be possible to have yours replace the one in HASS?

Those are very different, as I’m not developing the packaging necessary for hacs… But I will take a look at that. :wink:

1 Like