SL public transport information (Sweden)

Ooohlala. That looked nice. Would you like to submit a PR you are more than welcome to do that! =) I even appreciate it! =)

Give me a couple of days to remove the unused code and make it more dynamic (a little bit of hardcoded stuff right now) and I can make a PR. In dev branch right?

1 Like

Naa… I will kill that branch just dump into main (hasl) and thanks for helping out! =)

Ok everyone, as it seems to be a bunch of people that use the component and card and that I have started to quite a number of changes daily to avoid stuff breaking in everyones installation because I push some new crap onto GitHub I have decided to go back to having two branches; a main and a dev one as one should. I took a shortcut and just used worked one branch to keep it simpler for me but will now go away from that and do proper handling. Sorry if I have messed someones install up… =)

1 Like

Live and learn! :slight_smile: I have done the same recently with my stuff. Once it gets popular it’s almost impossible to keep only one branch since so many people are using it, and if it breaks it causes outrage :smiley: But that’s only because you are delivering something good that people like so much. :+1:

1 Like

Everyone!

I have been modifying, taking in suggestions from all sorts of channels and making a huge pile of changes. I am about to push it into the main repo and “release it” but if anyone would like to check it out and feedback already now please do so at the dev: https://github.com/DSorlov/ha-sensor-sl/tree/dev that includes compability for 0.92 and loads more (also a few very breaking changes). Feedback please (please use GitHub! =)

Thanks for all the great support and feedback!!

2 Likes

Only read the Readme, but it sounds good!

I can’t make this work for me.
When I run the validation check it says: “Platform not found: sensor.sl”
I checked and I’m pretty sure all the files is in the right directory.

I noticed that you changed the name for the directory from “sl” to “hasl” so I tried to rename the “platform” to “hasl”, so they would be the same, and now the configuration check just spins and nothing is happening.

I also tried to change both plattform and sensor to “sl” but with the same result.

What can I be doing wrong?

In which version of home assistant? Are you using hasl or dev branch in github?

Assuming you are running dev-branch, You should have a custom_components/hasl directory. In this directory you should have three files __ init __.py, manifest.json and sensor.py, I have also removed the __ pycache __ directory prior to restarting, also make sure your config follows the new guidelines as pretty much everything changed

And also make sure your HA install is atleast 0.92 when using dev-branch.

Version 92.1

I emptied all pycache, restarted and tried again.

image

image

image

I might have done some error but I can’t se it.

Aha! Error in documentation, just fixed and reupoaded the instructions! Should be platform: hasl

Also note that if you update and use the absolute last code from today there is an additional attribute that needs to be added to the sensor sensor_type: comb

Hi,

I have followed the guide here: https://github.com/dimmanramone/ha-sensor-sl
My home assistant are not giving me any errors when i do the “check config” i don’t get any errors.

I have version 0.91.4 when i check in the webgui but it i try to upgrade i get a note that 0.92.2 is installed…

My problem with this SL sensor are:

Log Details (ERROR)
Sat May 04 2019 20:04:12 GMT+0200 (CEST)
Error while setting up platform hasl
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py”, line 126, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/lib/python3.5/asyncio/tasks.py”, line 400, in wait_for
return fut.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/hasl/sensor.py”, line 103, in setup_platform
sensorconf.get(CONF_SENSORPROPERTY)
File “/home/homeassistant/.homeassistant/custom_components/hasl/sensor.py”, line 272, in init
from hasl import ri4api,si2api
ImportError: No module named ‘has’

Any ideas?

thanks,

You should follow the guide in https://github.com/DSorlov/ha-sensor-sl and not the one in my repository. Mine it is just a fork and not updated with the latest code. Be sure first which version of home assistant you have. If you have 0.92+ use the latest version and follow the guide as it is in the link above.

If your home assistant is older follow the instructions and the files from the following link

Edit: From the error that you posted it seems that you use the the files from @DSorlov repository using the instructions from mine as you said. As I wrote about use the appropriate instructions and files depending on your home assistant version

1 Like

Hi again,

So i followed the guide that you linked to.
Im not getting any errors and im not getting any new sensors and i have no clue what im doing wrong.

I have created the folders, copied the files, edited my configuration.yaml and checked the config without any errors.
Have i missed something?

Can you post your sensor and card configuration, as well as a screenshot of your custom component folder? Which version of Home Assistant?

This is how my section in configuration.yaml looks like

sensor:
- platform: hasl
  ri4key: key
  si2key: key
  tl2key: key
  sensors:
  - friendly_name: hallplats
    sensor_type: comb
    siteid: xxxx
    lines: xxx
    direction: 1
    sensor: binary_sensor.test
  - friendly_name: Trafikstatus
    sensor_type: tl2

No card config yet since i now get error messages in HA webgui:
2019-05-06 14:03:03 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “c:\users\fredric\appdata\local\programs\python\python37\lib\site-packages\homeassistant\helpers\entity_platform.py”, line 365, in _async_add_entity
await entity.async_update_ha_state()
File “c:\users\fredric\appdata\local\programs\python\python37\lib\site-packages\homeassistant\helpers\entity.py”, line 225, in async_update_ha_state
self._async_write_ha_state()
File “c:\users\fredric\appdata\local\programs\python\python37\lib\site-packages\homeassistant\helpers\entity.py”, line 256, in _async_write_ha_state
attr.update(self.device_state_attributes or {})
File “C:\Users\Fredric\AppData\Roaming.homeassistant\custom_components\hasl\sensor.py”, line 388, in device_state_attributes
if self._enabled_sensor is None or sensor_state.state is STATE_ON:
AttributeError: ‘NoneType’ object has no attribute ‘state’

and

2019-05-06 14:03:34 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.hallplats fails
Traceback (most recent call last):
File “c:\users\fredric\appdata\local\programs\python\python37\lib\site-packages\homeassistant\helpers\entity.py”, line 220, in async_update_ha_state
await self.async_device_update()
File “c:\users\fredric\appdata\local\programs\python\python37\lib\site-packages\homeassistant\helpers\entity.py”, line 377, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “c:\users\fredric\appdata\local\programs\python\python37\lib\concurrent\futures\thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “c:\users\fredric\appdata\local\programs\python\python37\lib\site-packages\homeassistant\util_init_.py”, line 224, in wrapper
result = method(*args, **kwargs)
File “C:\Users\Fredric\AppData\Roaming.homeassistant\custom_components\hasl\sensor.py”, line 454, in _update
if self._enabled_sensor is None or sensor_state.state is STATE_ON:
AttributeError: ‘NoneType’ object has no attribute ‘state’

custom

Using version 0.92.2

Have you setup a sensor that is called binary_sensor.test?

Try to remove it from your config and restart to see if you still get the same error.

sensor: binary_sensor.test
1 Like

Update:
i have a sensor called sensor.Trafikstatus and i have made a badge with it.
When i try to make a custom card with “Add card” and “Manual card” i get an error talling me this:

I have the file “hasl-comb-card” under www-folder.
I have added this to my raw configurator:
resources:
- url: /local/hasl-comb-card.js
type: js

Any ideas?

By the way, im trying to add the same lines as you do, buss 402 and sjövägen från finnboda hamn.