simonhq / asx_sensor

get ASX information in home assistant
3 stars 2 forks source link

Adding ASX code A200 creates key error 0 #3

Open grantclem opened 1 year ago

grantclem commented 1 year ago

When adding this ASX code to the ticker line of the yaml file the following error occurs:

TICKER: "VGS,VAS,A200"

2023-03-29 10:07:51.880121 WARNING Error: ------------------------------------------------------------
2023-03-29 10:09:17.735538 WARNING asx_sensor: ------------------------------------------------------------
2023-03-29 10:09:17.735861 WARNING asx_sensor: Unexpected error running initialize() for asx_sensor
2023-03-29 10:09:17.736096 WARNING asx_sensor: ------------------------------------------------------------
2023-03-29 10:09:17.736693 WARNING asx_sensor: Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/appdaemon/app_management.py", line 165, in initialize_app
    await utils.run_in_executor(self, init)
  File "/usr/lib/python3.10/site-packages/appdaemon/utils.py", line 337, in run_in_executor
    response = future.result()
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/appdaemon/apps/utils/asx_sensor.py", line 70, in initialize
    self.load()
  File "/config/appdaemon/apps/utils/asx_sensor.py", line 138, in load
    div_y = jtags[0]['year']
KeyError: 0

It appears to happen when adding any asx code that is alpha numeric.

simonhq commented 1 year ago

Hi Grant,

I have greatly simplified the code base and hopefully reduced the need for the shares to be the 'company' type.

I have tested with A200 but unsure which others may have been affected.

The changes should be available through HACS. let me know if works.

Simon.

grantclem commented 1 year ago

Hi Simon,

Thanks for your prompt reply - the error appears to have gone, but was initially getting a Class error... may want capitalise line 30 "class Get_ASX_Info(hass.Hass):" in your code.. Appears to be now working... thanks very much.