Coder Social home page Coder Social logo

crismc / homeassistant_nationalrailtimes_integration Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 3.0 320 KB

A custom Home Assistant component to show next available trains to specific stops through the National Rail Darwin SOAP API.

Python 100.00%
hacs hacs-integration home-assistant home-assistant-component home-assistant-integration national-rail

homeassistant_nationalrailtimes_integration's People

Contributors

araines avatar crismc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

homeassistant_nationalrailtimes_integration's Issues

[Bug]: Returns "None" if next train is tomorrow morning

Requirements

  • I have updated NationalRailTimes to the latest available version
  • I did a search to see if there is a similar issue.

Current Behavior

If there are no more trains today, and the next one is in the morning, the integration gives the following output:

...
destination_name: null
service: null

It would be better if the next day's trains were polled, so that it could display the time of that train.

See the below screenshot from Journey Planner. This was taken at 23:00 hours, just after the last train for the evening has left.

image

If it matters, I have a 15 minute offset set up.

Expected Behavior

It would be best if the integration checks for the next train time, and if none are found, checks for the earliest time the next day. There should be a 24 hour limit to ensure that the user is never given a train time that could be of an unknown day.

Alternatively, returning a list of the next n trains regardless of date would also work.

Steps To Reproduce

15 minute offset
arriving: Neath
destination: Cardiff Central

Context

YAML state

Environment

- Browser: Chromium based
- HA Version: 2023.12.4
- NationalRailTimes: 1.0.3

Anything else?

No response

[Bug]: Unable to setup via configuration.yaml

Requirements

  • I have updated NationalRailTimes to the latest available version
  • I did a search to see if there is a similar issue.

Current Behavior

Invalid configuration error when trying to configure via yaml.

Invalid config for [sensor.nationalrailtimes]: [destination] is an invalid option for [sensor.nationalrailtimes]. Check: sensor.nationalrailtimes->destination. (See ?, line ?).

Expected Behavior

Configuration pass

Steps To Reproduce

Try to add the following to your configuration.yaml:

  • sensor:
    • platform: nationalrailtimes
      api_key: YOUR_KEY
      arrival: LBG
      destination: CHX
      time_offset: 15

Context

No response

Environment

No response

Anything else?

Is it possible that this is caused by PLATFORM_SCHEMA (in sensor.py) not including destination?

[Bug]: station messages wrapped with <p> </p>

Requirements

  • I have updated NationalRailTimes to the latest available version
  • I did a search to see if there is a similar issue.

Current Behavior

Some station messages are reported as:

The Ticket Office is currently closed at XYZ station.

Expected Behavior

and

should not be displayed.

Steps To Reproduce

You just need a station that has ticket office closed message.

Context

No response

Environment

- Browser:
- HA Version:
- NationalRailTimes:

Anything else?

I have modified my local copy of def extra_state_attributes(self) adding the followings before return:

        pattern1 = re.compile(r'</p>')
        attributes["message"] = [pattern1.sub('', sub) for sub in attributes["message"]]
        
        pattern2 = re.compile(r'<p>')
        attributes["message"] = [pattern2.sub('', sub) for sub in attributes["message"]]

It works, would be good to add something similar in your implementation.

[Feature]: Timetable

Is your feature request related to a problem?

No

Describe the solution you'd like

To get information about the next few trains and not just 1 (next) departure. It would be great to be able to create a timetable card with:
Destination name
Scheduled arrival time
"on-time" status
Estiamted arrival time

I see a single destination per card as the best idea, but multiple destinations in one timetable could also be helpful

Describe alternatives you've considered

No response

Additional context

No response

[Bug]: Single calling station breaks the lovelace card

Requirements

  • I have updated NationalRailTimes to the latest available version
  • I did a search to see if there is a similar issue.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.