Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for sensor.nmbs(_live) fails #20744

Closed
joske500 opened this issue Feb 4, 2019 · 7 comments
Closed

Update for sensor.nmbs(_live) fails #20744

joske500 opened this issue Feb 4, 2019 · 7 comments

Comments

@joske500
Copy link

joske500 commented Feb 4, 2019

Home Assistant release with the issue:
0.86.4

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io

Component/platform:
Component: NMBS Sensor

Description of problem:
The sensor is giving accurate information but litters the Home Assistant Log with ERROR messages.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

  - platform: nmbs
    station_from: "Gent-Sint-Pieters"
    station_to: "Brussel-Centraal/Bruxelles-Central"
    station_live: "Gent-Sint-Pieters"

Traceback (if applicable):

Mon Feb 04 2019 19:11:52 GMT+0100 (Central European Standard Time)

Update for sensor.nmbs fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/nmbs.py", line 207, in update
    if int(connections['connection'][0]['departure']['left']) > 0:
TypeError: 'int' object is not subscriptable

AND

Mon Feb 04 2019 18:39:52 GMT+0100 (Central European Standard Time)

Update for sensor.nmbs_live fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/nmbs.py", line 132, in update
    next_departure = liveboard['departures']['departure'][0]
TypeError: 'int' object is not subscriptable

Additional information:
Had this problem since the beginning, already tried with other stations/data in configuration.yaml but problem persists.

@elRadix
Copy link

elRadix commented Mar 7, 2019

@thibmaek error on HA version 0.89
reference: https://community.home-assistant.io/t/components-for-belgian-public-transport/55194/47?u=elradix

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'

@thibmaek
Copy link
Contributor

thibmaek commented Mar 7, 2019

Thanks for the info, will take a look at this (hopefully this week).
Maintainers, feel free to assign this to me.

@thibmaek
Copy link
Contributor

@elRadix can be closed, because @nudded has fixed this in #21810 !

@thibmaek
Copy link
Contributor

thibmaek commented Mar 21, 2019

Can you verify that this is fixed in 0.90 @elRadix and close the issue?

@elRadix
Copy link

elRadix commented Mar 21, 2019

@thibmaek
I get now the train info but this error is still shown, my log is full with these
HA v.0.90

2019-03-21 20:09:23 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 179, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 225, in async_update_ha_state
    self._async_write_ha_state()
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 256, in _async_write_ha_state
    device_attr = self.device_state_attributes
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/nmbs.py", line 127, in device_state_attributes
    'occupancy': self._attrs['occupancy']['name'],
KeyError: 'occupancy'

@thibmaek
Copy link
Contributor

Aha! Seems like #21810 didn't fully fix it and there is still a reference to the deprecated occupancy key. I'll try and remove this ASAP.

@thibmaek
Copy link
Contributor

Fix in progress at #22320

@fabaff fabaff closed this as completed Mar 23, 2019
@ghost ghost removed the in progress label Mar 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants