Coder Social home page Coder Social logo

bremor / public_transport_victoria Goto Github PK

View Code? Open in Web Editor NEW
30.0 4.0 5.0 83 KB

Custom component for retrieving departure times for Public Transport Victoria.

Python 100.00%
ptv australia victoria train bus tram hacs public transport hacktoberfest

public_transport_victoria's Introduction

hacs_badge

The public transport victoria sensor platform uses the Public Transport Victoria (PTV) as a source for public transport departure times for Victoria, Australia.

Installation (There are two methods, with HACS or manual)

hacs

Install via HACS (default store) or install manually by copying the files in a new 'custom_components/public_transport_victoria' directory.

Prerequisites

Developer ID and API Key

Please follow the instructions on http://ptv.vic.gov.au/ptv-timetable-api/ for obtaining a Developer ID and API Key.

Configuration

After you have installed the custom component (see above):

  1. Goto the Configuration -> Integrations page.
  2. On the bottom right of the page, click on the + Add Integration sign to add an integration.
  3. Search for Public Transport Victoria. (If you don't see it, try refreshing your browser page to reload the cache.)
  4. Click Submit to add the integration.

Notes

This integration will refresh data every 10 minutes. If you wish to update the departure information more frequently during interesting periods, you may use an automation like the one below. It will update the sensors every minute between 7:30AM-8:30AM and 4:45PM-5:45PM.

automation:

  - alias: 'update_trains'
    initial_state: true
    trigger:
      trigger:
      - platform: time_pattern
        minutes: "/1"
    condition:
      condition: or
      conditions:
        - condition: time
          after: '07:30:00'
          before: '08:30:00'
        - condition: time
          after: '16:45:00'
          before: '17:45:00'
    action:
      - service: 'homeassistant.update_entity'
        data:
          entity_id:
            - 'sensor.werribee_line_to_city_flinders_street_from_aircraft_station_0'
            - 'sensor.werribee_line_to_city_flinders_street_from_aircraft_station_1'
            - 'sensor.werribee_line_to_city_flinders_street_from_aircraft_station_2'
            - 'sensor.werribee_line_to_city_flinders_street_from_aircraft_station_3'
            - 'sensor.werribee_line_to_city_flinders_street_from_aircraft_station_4'

Buy Me A Coffee

public_transport_victoria's People

Contributors

bremor avatar kaizersoje avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

public_transport_victoria's Issues

Addition of RideSpace crowding information

PTV/TransportX has launched RideSpace, which reports a realtime estimate of crowding on platforms and PT services.

I don't know whether there is API access to the data or not.

On its launch DOT reported that "We’ll continue to monitor RideSpace and its usage over the next few months, as well as investigating options to expand it to include tram, regional train and bus capacity; and integration into our other products (like the PTV app) and third-party services (like Google Maps)." which would suggest that they don't have an API yet.

So I guess just consider this issue a bookmark to come back to it when they do?

Duplicate times occasionally

HI Brendon

Just a quick one which I have noticed. Occasionally I notice that the next train to depart and the one after that are displayed with the same time

See example

image

It however it not all the time and sometimes it seems to display the correct times.

Either way, only a minor issue, and thanks again for this awesome custom component (As well as the bureau_of_meteorology
one as well)

Trouble on the busses

On setting up the integration, I can add trains ok, but not busses.
Selecting Bus and submitting has the interface spinning for awhile and then this hits the logs.

2020-11-27 14:55:15 ERROR (MainThread) [custom_components.public_transport_victoria.config_flow] Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/public_transport_victoria/config_flow.py", line 66, in async_step_route_types
self.routes = await self.connector.async_routes(
File "/config/custom_components/public_transport_victoria/PublicTransportVictoria/public_transport_victoria.py", line 73, in async_routes
response = await response.json()
File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1094, in json
await self.read()
File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1034, in read
self._body = await self.content.read()
File "/usr/local/lib/python3.8/site-packages/aiohttp/streams.py", line 371, in read
block = await self.readany()
File "/usr/local/lib/python3.8/site-packages/aiohttp/streams.py", line 393, in readany
await self._wait("readany")
File "/usr/local/lib/python3.8/site-packages/aiohttp/streams.py", line 307, in _wait
await waiter
File "/usr/local/lib/python3.8/site-packages/aiohttp/helpers.py", line 656, in exit
raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError

Entity does not always update with homeassistant.update_entity

Hello,

Firstly, loving this integration. I'm using it to send voice alerts over my Google Home speakers for upcoming trains at important times of the day, and have an entities card on one of my dashboards which shows the next 5 trains.

The other day I had trouble getting the next train time to update. I called the homeassistant.update_entity service but it was stuck with a 12 minute old update. I was out and about so couldn't get any logs, but do have this screenshot showing stop ID, rout ID etc which is hopefully helpful.

If it happens again I'll try and capture more details, but wanted to log there here in case there is a problem somewhere in the integration.

image

No 'version' key in the manifest file for custom integration 'public_transport_victoria'

Hi, can you please update so a future HA update doesn't break functionality of your excellent integration?

2021-03-05 14:48:00 WARNING (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'public_transport_victoria'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'public_transport_victoria'

Copy/Paste error in docs?

Sample configuration in the docs for this component has the following;
`automation:

  • alias: 'bom_melbourne_max_temp_c'`

A small thing but might trip someone up :)

times displaying in UTC format

The times for the upcoming trains are incorrectly showing. I'm pretty sure the time is displaying in UTC format rather than AEST.

No Bus timetable

When I tried to load the PTV bus timetables, it goes into a loop.

Relative not absolute times

Is it possible to modify the times so that you can see X minutes until departure?

e.g. If departure time is the same as current time, print "Now"
If departure time is 5 minutes from current time, print "5 minutes"

Not picking up correct direction

I tried to setup a sensor for this service but it always sets the direction in the outbound direction.
VLine service, Geelong - Melbourne line, Melbourne direction, From Wyndham Vale Railway Station.

It tells me that:
Created configuration for Geelong - Melbourne line to Geelong from Wyndham Vale Railway Station.

It doesn't matter if I choose the Melbourne or Geelong direction it will always create the sensors in the Geelong direction.
The actual sensors show the direction ID as 21, where it should be 0 for inbound.

Sensor Names Incorrect

HI. I found your repo on and just want to let you know of a couple of small bugs. I don't know if you are still maintaining it and of course, it isn't likely I will be using public transport for the rest of the year, but it seems like it will be a useful tool once we are allowed to go into the office.

I set it up correctly with the User ID and API key and it appeared to work fine. (I already had these as I previously had been using a rest sensor to get the information)

However I did notice that the sensor name were called sensor.example_temperature sensor.example_temperature_1 etc
Also the friendly name was Example Temperature

Anyway, just thought I would let you know, as this is potentially a very useful custom component for when life gets back to something resembling normality.

Thanks again...

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.