Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Home Assistant with Dublin Bus RTPI

Options
  • 16-01-2017 9:31pm
    #1
    Registered Users Posts: 7,518 ✭✭✭


    For anyone interested I've written a home assistant component that links with the Dublin Bus real time information. It will give you the time in minutes to the next bus and you could use this to trigger automations, e.g. change a light to let you know it is due.

    This was released as part of the new home assistant 0.36 update that was out today. For more information see https://home-assistant.io/components/sensor.dublin_bus_transport/


Comments

  • Closed Accounts Posts: 4,620 ✭✭✭Roen


    matrim wrote: »
    For anyone interested I've written a home assistant component that links with the Dublin Bus real time information. It will give you the time in minutes to the next bus and you could use this to trigger automations, e.g. change a light to let you know it is due.

    This was released as part of the new home assistant 0.36 update that was out today. For more information see https://home-assistant.io/components/sensor.dublin_bus_transport/

    Saw that earlier when I was updating it but the link was a 404.
    Fair play on the effort. It should be useful for people near routes. I assume it talks to some real time location monitoring that DB expose. Wasn't aware they were doing that.


  • Registered Users Posts: 7,518 ✭✭✭matrim


    Roen wrote: »
    Saw that earlier when I was updating it but the link was a 404.
    Fair play on the effort. It should be useful for people near routes. I assume it talks to some real time location monitoring that DB expose. Wasn't aware they were doing that.

    It's a fairly simple JSON api and I get the information from https://data.dublinked.ie/dataset/real-time-passenger-information-rtpi-for-dublin-bus-bus-eireann-luas-and-irish-rail


  • Registered Users Posts: 149 ✭✭paradisepaddy


    Great stuff on the sensor. Have been getting errors the last while tho. Probably better to post on homeassistant forum but maybe you can diagnose quickly? Pretty big error log but bit relevant to Dublin bus....

    17-02-13 18:57:08 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform dublin_bus_transport
    Traceback (most recent call last):
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 326, in connect
    ssl_context=context)
    File "/usr/local/lib/python3.4/dist-packages


  • Registered Users Posts: 7,518 ✭✭✭matrim


    Great stuff on the sensor. Have been getting errors the last while tho. Probably better to post on homeassistant forum but maybe you can diagnose quickly? Pretty big error log but bit relevant to Dublin bus....

    17-02-13 18:57:08 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform dublin_bus_transport
    Traceback (most recent call last):
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 326, in connect
    ssl_context=context)
    File "/usr/local/lib/python3.4/dist-packages

    The site that is used to get the information updated their certificate but haven't configured it correctly. I contacted them over the weekend with details on what is wrong and they said they will look into it.


  • Registered Users Posts: 7,518 ✭✭✭matrim


    Great stuff on the sensor. Have been getting errors the last while tho. Probably better to post on homeassistant forum but maybe you can diagnose quickly? Pretty big error log but bit relevant to Dublin bus....

    17-02-13 18:57:08 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform dublin_bus_transport
    Traceback (most recent call last):
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
    File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 326, in connect
    ssl_context=context)
    File "/usr/local/lib/python3.4/dist-packages

    Just got a response from dublinked and they have fixed their cert. Doing a wget now works and I assume the plugin is working again. Although haven't had a chance to test yet.


  • Advertisement
  • Registered Users Posts: 149 ✭✭paradisepaddy


    matrim wrote: »
    Just got a response from dublinked and they have fixed their cert. Doing a wget now works and I assume the plugin is working again. Although haven't had a chance to test yet.

    Thanks Matrim. Just checked from a remote connection and all is working fine now. Thanks for that. Now to get some automations setup :)


  • Registered Users Posts: 61 ✭✭OrdeP


    I've created one for irishrail. Still beta and not published to the official release, yet

    https://github.com/Ordep/home-assistant/blob/dev/homeassistant/components/sensor/irishrail_transport.py

    You can set by station and direction/destination

    Let me know what you think.

    PS: the idea came from the Dublin bus one


  • Registered Users Posts: 149 ✭✭paradisepaddy


    Will this work for luas also? Any good resources on how you made this also. Been a hobby I've wanted to learn at some point.
    OrdeP wrote: »
    I've created one for irishrail. Still beta and not published to the official release, yet

    https://github.com/Ordep/home-assistant/blob/dev/homeassistant/components/sensor/irishrail_transport.py

    You can set by station and direction/destination

    Let me know what you think.

    PS: the idea came from the Dublin bus one


  • Moderators, Technology & Internet Moderators Posts: 17,134 Mod ✭✭✭✭cherryghost


    Hey,

    Sorry for bringing up an old thread, but this may have been broken in recent updates.
    2018-09-11 00:57:56 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
    Traceback (most recent call last):
    File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 243, in async_update_ha_state
    device_attr = self.device_state_attributes
    File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/dublin_bus_transport.py", line 96, in device_state_attributes
    next_up = self._times[1][ATTR_ROUTE] + " in "
    IndexError: list index out of range

    I assume its in relation to recent changes here in naming scheme. Haven't changed my HA in months, only updating the HA package so I guess this is it.


  • Registered Users Posts: 149 ✭✭paradisepaddy


    Yep same here. I'm on the latest Hass.io install since last night and the bus component is throwing out same errors.

    Is still showing the correct data I assume tho as I'm still getting bus times.
    Hey,

    Sorry for bringing up an old thread, but this may have been broken in recent updates.


    I assume its in relation to recent changes here in naming scheme. Haven't changed my HA in months, only updating the HA package so I guess this is it.


  • Advertisement
  • Registered Users Posts: 7,276 ✭✭✭kenmc


    It's straightforward to do this in openhab at least. I've a script which gets the next 2 buses at a certain stop, and as of this morning it's still running fine. Openhab use java**** to do the dirty parsing work though, so my code is not as clean as I'd like.

    The API is https://data.dublinked.ie/cgi-bin/rtpi/realtimebusinformation?stopid=3024

    Stop you need to find on the bus stop or website


  • Registered Users Posts: 547 ✭✭✭the merchant


    FWIW I'm running the latest version of hassio and it works fine.

    5tysk2.jpg


  • Registered Users Posts: 7,518 ✭✭✭matrim


    I'll take a look some time this week

    is it working for people and just showing errors in the logs?


  • Moderators, Technology & Internet Moderators Posts: 17,134 Mod ✭✭✭✭cherryghost


    It's not working at all for me. I'll have a look at the script myself later to see what may have changed.


  • Moderators, Technology & Internet Moderators Posts: 17,134 Mod ✭✭✭✭cherryghost


    Yep same here. I'm on the latest Hass.io install since last night and the bus component is throwing out same errors.

    Is still showing the correct data I assume tho as I'm still getting bus times.

    Are you using any custom UI elements or custom written scripts?


  • Moderators, Technology & Internet Moderators Posts: 17,134 Mod ✭✭✭✭cherryghost


    Well, I've dug into my logs and the error magically stopped for me at 5:20 this morning, all has been working since then. No idea what triggered it to stop as I was fast asleep at that point!


  • Registered Users Posts: 149 ✭✭paradisepaddy


    Same with me. All errors have disappeared relating to this one. :)

    Now I just need to fix the others that have been on my to-do list.


  • Moderators, Technology & Internet Moderators Posts: 17,134 Mod ✭✭✭✭cherryghost


    It seems the dublinked API is wholly unreliable these days.


  • Registered Users Posts: 7,518 ✭✭✭matrim


    It seems the dublinked API is wholly unreliable these days.

    I have a fix coming in the next version that should hopefully make the home assistant checker more stable. Basically I wasn't checking that the 2nd bus time was always being set and this was throwing an error which could cause home assistant to stop checking the API. I think the next release is due tomorrow.

    This is possibly the same issue that people were getting for a while. I recently changed office so re-setup the bus checker and now use it enough to actually get to the root cause of the issue.


  • Moderators, Technology & Internet Moderators Posts: 17,134 Mod ✭✭✭✭cherryghost


    Understood but making API HTTP requests directly, the API server itself responds with 503s quite often


  • Advertisement
  • Registered Users Posts: 7,518 ✭✭✭matrim


    Understood but making API HTTP requests directly, the API server itself responds with 503s quite often

    Ok. You could try emailing them. I did last year when they had a certificate issue and they were very responsive and helpful.


  • Moderators, Technology & Internet Moderators Posts: 17,134 Mod ✭✭✭✭cherryghost


    matrim wrote: »
    Ok. You could try emailing them. I did last year when they had a certificate issue and they were very responsive and helpful.

    Yep way ahead of you :) Will let you know


  • Moderators, Technology & Internet Moderators Posts: 17,134 Mod ✭✭✭✭cherryghost


    I got a swift reply, it seems the API is overloaded and thus has been temporarily restricted for some time. There's going to be a new server rollout in the coming weeks that can handle the larger load seen recently.


  • Registered Users Posts: 7,518 ✭✭✭matrim


    I got a swift reply, it seems the API is overloaded and thus has been temporarily restricted for some time. There's going to be a new server rollout in the coming weeks that can handle the larger load seen recently.

    I hope us HA users aren't adding too much to the load . IIRC it's one request per configured bus per minute.


  • Moderators, Technology & Internet Moderators Posts: 17,134 Mod ✭✭✭✭cherryghost


    matrim wrote: »
    I hope us HA users aren't adding too much to the load . IIRC it's one request per configured bus per minute.

    Yes, it is every minute. Builds up if you're using multiple stops/configs, then lord knows how many users use HA :) They said they were getting tens of thousands of requests an hour which was putting the server under strain, even running through the night (out of bus service hours).

    I would assume myself it's all the 3rd party phone apps (Dublin Bus app is AFK) that you can hit refresh a thousand times a minute to find that ghost bus :D


Advertisement