Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

fredrikbaberg/ha-sensor-sl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SL sensor for Home Assistant

This is a fork of fuffenz SL sensor (https://github.com/fuffenz/ha-sensor-sl).

I'm archiving this, since I'm not actively working on it. Have a look at this fork instead: https://github.com/DSorlov/ha-sensor-sl

This is a simple component for Home Assistant that can be used to create a "Departure board" for buses and trains in Stockholm, Sweden. You have to install it as a custom component and you need to get your own API key from SL / Trafiklab.

  • First, visit https://www.trafiklab.se/api and create a free account. They provide multiple APIs, the one you want is "SL Trafikinformation 4".
    When you have your API key, you're ready to add the component to your Home Assistant. Since this is a custom component, you need to add it manually to your config directory.

  • Create a folder named custom_components under your Home Assistant config folder.

  • Create a folder named sensor under the custom_components folder.

  • Download sl.py from here and put it in the sensor folder.

  • Edit your configuration.yaml file and add the component

# Example configuration.yaml entry
- platform: sl
  name: gullmarsplan
  ri4key: YOUR-API-KEY-HERE
  siteid: 9189
  lines: 17, 18, 19
  direction: 1
  sensor: binary_sensor.test

Configuration variables

  • name: The name of the sensor (will be prefixed with "sl_")

  • ri4key: Your API key from Trafiklab

  • siteid: The ID of the bus stop or station you want to monitor. You can find the ID with some help from another API, sl-platsuppslag. In the example above, site 9189 is Gullmarsplan.

  • lines: (optional) A comma separated list of line numbers that you are interested in. Most likely, you only want info on the bus that you usually ride. If omitted, all lines at the specified site id will be included. In the example above, lines 17, 18 and 19 will be included.

  • direction: (optional) Unless your site id happens to be the end of the line, buses and trains goes in both directions. You can enter 1 or 2. If omitted, both directions are included.

  • sensor: (optional) Sensor to determine if status should be updated. If sensor is 'on', or if this option is not set, update will be done.

sensor value

The sensor value is the number of minutes to the next departure. There are also a number of attributes:

next_departure: 1 min
next_line: 17
next_destination: Åkeshov
upcoming_departure: 4 min
upcoming_line: 18
upcoming_destination: Hässelby strand
unit_of_measurement: min
icon: fa-subway
friendly_name: sl gullmarsplan
attribution: Data from sl.se / trafiklab.se

API-call restrictions

The Bronze level API is limited to 30 API calls per minute, 10.000 per month. For a private project, Silver level does not seem possible. With 10.000 calls per month, that allows for less than one call every 4 minute.

custom_updater

For update check of this sensor, add the following to your configuration.yaml. For more information, see [custom_updater]

custom_updater:
  component_urls:
    - https://raw.githubusercontent.com/fredrikbaberg/ha-sensor-sl/master/custom_updater.json

About

Home Assistant sensor for sl.se departures

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%