crismc / homeassistant_nationalrailtimes_integration

A custom Home Assistant component to show next available trains to specific stops through the National Rail Darwin SOAP API.
14 stars 4 forks source link

[Bug]: Single calling station breaks the lovelace card #4

Closed araines closed 11 months ago

araines commented 11 months ago

Requirements

Current Behavior

When selecting a station with only a single calling point (the destination), the lovelace card fails.

I currently believe this is because the calling points are not a list when only one item (probably an XML parsing problem).

Expected Behavior

Single calling point journeys should work

Steps To Reproduce

  1. Create an entity from WSU (West Sutton) to SUO (Sutton)
  2. Add the entity to the nationalrail-times-card card in lovelace
  3. Observe it does not work

Context

YAML state

Environment

- Browser: Chrome
- HA Version: 2023.10.5
- NationalRailTimes: 1.0.2

Anything else?

Comparing the calling points from WSU to SUO (single calling point):

Calling points
locationName: Sutton (London)
crs: SUO
st: '22:14'
et: '22:18'

Versus the calling points from SUO to LBG (multiple calling points):

Calling points
- locationName: Carshalton Beeches
  crs: CSB
  st: '21:59'
  et: On time
  length: '5'
- locationName: Wallington
  crs: WLT
  st: '22:01'
  et: On time
  length: '5'
- locationName: Waddon
  crs: WDO
  st: '22:05'
  et: On time
  length: '5'
- locationName: West Croydon
  crs: WCY
  st: '22:09'
  et: On time
  length: '5'
- locationName: Norwood Junction
  crs: NWD
  st: '22:15'
  et: On time
  length: '5'
- locationName: London Bridge
  crs: LBG
  st: '22:28'
  et: On time
  length: '5'

You can see the latter is a list, whereas the former is not.

I'm planning to take a look to see if I can provide a patch for this as well.