Components for Belgian public transport

The optional name is not working - I have set 2 sensors for Home and Work and it shows as sensor.nmbs for home and sensor.nmbs_2 for work. Tried with and without quotes - no difference

  - platform: nmbs
    name: "Work"

  - platform: nmbs
    name: Home

Yeah I forgot that along the way I guess, planning to release that as a patch fix today or this weekend.

For anyone interested tracking progress on this component (and all my other components): I have a Notion board where you can find all the info.

Seems to work perfectly fine here:

sensor:
  - platform: nmbs
    name: 'Trein Werk'
    station_from: "Brugge"
    station_to: "Gent Dampoort"
  - platform: nmbs
    station_from: "Gent Dampoort"
    station_to: "Brugge"

All fine now thanks, now very good visisble in Lovelace

That’s nice! What are those cards?

see below config, i’m using the following custom cards

Bar-card
Attributes card / entity row

entities:
  - entity: sensor.train_home
    from: left
    height: 30px
    indicator: true
    max: 40
    min: 0
    rounding: 5px
    saturation: 50%
    severity:
      - hue: '120'
        value: 30
      - hue: '40'
        value: 31
      - hue: '0'
        value: 35
    style:
      '--paper-card-background-color': 'rgba(84, 95, 108, 0.7)'
      border-radius: 8px
      left: 1%
      overflow: hidden
      top: 29%
      transform: none
      width: 48%
    title: Train Home
    type: 'custom:bar-card'
    width: '70'
  - entity: sensor.train_home
    filter:
      exclude:
        - sensor.train_home.at*
        - sensor.train_home.fr*
        - sensor.train_home.oc*
        - sensor.train_home.ic*
        - sensor.train_home.oc*
        - sensor.train_home.uni*
      include:
        - sensor.train_home.*
    heading_name: Home
    heading_state: '  '
    type: 'custom:entity-attributes-card'
  - entity: sensor.train_work
    from: left
    height: 30px
    indicator: true
    max: 40
    min: 0
    rounding: 5px
    saturation: 50%
    severity:
      - hue: '120'
        value: 30
      - hue: '40'
        value: 31
      - hue: '0'
        value: 35
    style:
      '--paper-card-background-color': 'rgba(84, 95, 108, 0.7)'
      border-radius: 8px
      left: 1%
      overflow: hidden
      top: 29%
      transform: none
      width: 48%
    title: Train Work
    type: 'custom:bar-card'
    width: '70'
  - entity: sensor.train_work
    filter:
      exclude:
        - sensor.train_work.at*
        - sensor.train_work.fr*
        - sensor.train_work.oc*
        - sensor.train_work.ic*
        - sensor.train_work.oc*
        - sensor.train_work.uni*
      include:
        - sensor.train_work.*
    heading_name: Work
    heading_state: '  '
    type: 'custom:entity-attributes-card'
show_header_toggle: false
type: entities

Just finished adding displaying if the train is a via train and show on map:

Nice update; what’s more useful if to add real time arrival/departure instead of arriving in 4 minutes.
I cant even use that as template sensor if wanted to.

For example I want to monitor the train arriving at 8h34 in Brussels or any train between 8 o’clock till 8h30.

I’ll try to do that in 2.1

@thibmaek just upgraded to the latest HA version 0.89 and I got the following error:

lan hass[27455]: 2019-03-07 09:38:50 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Mar 07 09:38:50 raspi.lan hass[27455]: Traceback (most recent call last):
Mar 07 09:38:50 raspi.lan hass[27455]:   File "/usr/local/lib/python3.6/asyncio/tasks.py", line 179, in _step
Mar 07 09:38:50 raspi.lan hass[27455]:     result = coro.send(None)
Mar 07 09:38:50 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
Mar 07 09:38:50 raspi.lan hass[27455]:     await entity.async_update_ha_state()
Mar 07 09:38:50 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
Mar 07 09:38:50 raspi.lan hass[27455]:     device_attr = self.device_state_attributes
Mar 07 09:38:50 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/nmbs.py", line 197, in device_state_attributes
Mar 07 09:38:50 raspi.lan hass[27455]:     'occupancy': self._attrs['departure']['occupancy']['name'],
Mar 07 09:38:50 raspi.lan hass[27455]: KeyError: 'occupancy'
Mar 07 09:38:50 raspi.lan hass[27455]: 2019-03-07 09:38:50 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Mar 07 09:38:50 raspi.lan hass[27455]: Traceback (most recent call last):
Mar 07 09:38:50 raspi.lan hass[27455]:   File "/usr/local/lib/python3.6/asyncio/tasks.py", line 179, in _step
Mar 07 09:38:50 raspi.lan hass[27455]:     result = coro.send(None)
Mar 07 09:38:50 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
Mar 07 09:38:50 raspi.lan hass[27455]:     await entity.async_update_ha_state()
Mar 07 09:38:50 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
Mar 07 09:38:50 raspi.lan hass[27455]:     device_attr = self.device_state_attributes
Mar 07 09:38:50 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/nmbs.py", line 127, in device_state_attributes
Mar 07 09:38:50 raspi.lan hass[27455]:     'occupancy': self._attrs['occupancy']['name'],
Mar 07 09:38:50 raspi.lan hass[27455]: KeyError: 'occupancy'
Mar 07 09:38:51 raspi.lan hass[27455]: 2019-03-07 09:38:51 INFO (SyncWorker_8) [homeassistant.components.sensor.command_line] Running command: /opt/scripts/status/state.sh -s 6
Mar 07 09:38:51 raspi.lan hass[27455]: 2019-03-07 09:38:51 INFO (SyncWorker_13) [homeassistant.components.sensor.command_line] Running command: /opt/scripts/status/state.sh -s 10
Mar 07 09:38:51 raspi.lan hass[27455]: 2019-03-07 09:38:51 INFO (SyncWorker_10) [homeassistant.components.sensor.command_line] Running command: /opt/scripts/status/state.sh -t 0
Mar 07 09:38:51 raspi.lan hass[27455]: 2019-03-07 09:38:51 WARNING (MainThread) [homeassistant.components.sensor] Setup of platform mqtt is taking over 10 seconds.
Mar 07 09:38:51 raspi.lan hass[27455]: 2019-03-07 09:38:51 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Mar 07 09:38:51 raspi.lan hass[27455]: Traceback (most recent call last):
Mar 07 09:38:51 raspi.lan hass[27455]:   File "/usr/local/lib/python3.6/asyncio/tasks.py", line 179, in _step
Mar 07 09:38:51 raspi.lan hass[27455]:     result = coro.send(None)
Mar 07 09:38:51 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
Mar 07 09:38:51 raspi.lan hass[27455]:     await entity.async_update_ha_state()
Mar 07 09:38:51 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
Mar 07 09:38:51 raspi.lan hass[27455]:     device_attr = self.device_state_attributes
Mar 07 09:38:51 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/nmbs.py", line 127, in device_state_attributes
Mar 07 09:38:51 raspi.lan hass[27455]:     'occupancy': self._attrs['occupancy']['name'],
Mar 07 09:38:51 raspi.lan hass[27455]: KeyError: 'occupancy'
Mar 07 09:38:51 raspi.lan hass[27455]: 2019-03-07 09:38:51 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Mar 07 09:38:51 raspi.lan hass[27455]: Traceback (most recent call last):
Mar 07 09:38:51 raspi.lan hass[27455]:   File "/usr/local/lib/python3.6/asyncio/tasks.py", line 179, in _step
Mar 07 09:38:51 raspi.lan hass[27455]:     result = coro.send(None)
Mar 07 09:38:51 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
Mar 07 09:38:51 raspi.lan hass[27455]:     await entity.async_update_ha_state()
Mar 07 09:38:51 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
Mar 07 09:38:51 raspi.lan hass[27455]:     device_attr = self.device_state_attributes
Mar 07 09:38:51 raspi.lan hass[27455]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/nmbs.py", line 197, in device_state_attributes
Mar 07 09:38:51 raspi.lan hass[27455]:     'occupancy': self._attrs['departure']['occupancy']['name'],
Mar 07 09:38:51 raspi.lan hass[27455]: KeyError: 'occupancy'

Yup, I’m aware of the issue. Seems like something changed in the iRail API and the component needs to be updated.

Feel free to make this into an issue on HA’s Github and tag me (@thibmaek) so I can look into it.

done, there is still one open, just added an update to that request

HI,

what station name is to be used? the components documentation states is uses the api.irail.be which shows name Gent-Dampoort, but you use Gent Dampoort?:

station locationX="3.740591" locationY="51.056365" id="BE.NMBS.008893120" URI="http://irail.be/stations/NMBS/008893120" standardname="Gent-Dampoort">Ghent-Dampoort</station>

I ask because I need to travel to Brussel Noord, which is listed in the api as Brussel-Noord/Bruxelles-Nord:

station locationX="4.360846" locationY="50.859663" id="BE.NMBS.008812005" URI="http://irail.be/stations/NMBS/008812005" standardname="Brussel-Noord/Bruxelles-Nord">Brussels-North</station>

following the above, would I need:

  - platform: nmbs
    station_from: 'Essen'
    station_to: 'Brussel-Noord/Bruxelles-Nord'
    station_live: 'Essen'
    exclude_vias: true
    name: Essen - Brussel Noord
    show_on_map: true

or:

  - platform: nmbs
    station_from: 'Essen'
    station_to: 'Brussel Noord'
    station_live: 'Essen'
    exclude_vias: true
    name: Essen - Brussel Noord
    show_on_map: true

iRail API is pretty flexible in naming I noticed: you can just use it like that:

Best way to check is just seeing if the URL with your station returns a valid response (see screenshot)

not sure why, but trying this doesn’t give me any sensor:

sensor:

  - platform: nmbs
    station_from: 'Essen'
    station_to: 'Brussel-Noord'
    station_live: 'Essen'
    exclude_vias: true
    name: Essen - Brussel Noord
    show_on_map: true

  - platform: nmbs
    station_from: 'Brussel-Noord'
    station_to: 'Essen'
    station_live: 'Brussel-Noord'
    exclude_vias: true
    name: Brussel Noord - Essen
    show_on_map: true

That’s related to the errors posted above and https://github.com/home-assistant/home-assistant/issues/20744

If you check your logs you should have a similar error.

ok thanks for clarifying, btw I’m on 87.1, so guess will wait for this to be resolved and try again.

Great addon !

I second the request to cut the “Vehicle ID” to only show the train number.
Drop the “BE.NMBS.”-part, please.

Hi,

I can see the issue was closed on github, but was it fixed or not? I just configured this integration but see no sensor in the entity registry.

If your line has no current connection (for example Bruges -> Aalter) it might take until the next connection to show up (next day)