Giter Site home page Giter Site logo

miicroo / lovelace-vasttrafik-card Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 2.0 348 KB

Lovelace card for displaying transportation data from Västtrafik in HomeAssistant

Python 100.00%
homeassistant ui lovelace-ui lovelace-card vasttrafik transportation-planning homeautomation

lovelace-vasttrafik-card's Introduction

vasttrafik-card

Styled entities using the Västtrafik theme in a lovelace entities card. All trams and buses are styled using the colours used in their respective municipality.

This card also displays:

  • When the next vehicle is leaving
  • Departing station
  • Heading / arriving station
  • When you have to leave home in order to catch the vehicle (also known as the sensor delay).
  • Sorting of entities, showing the next entity to depart first

v1.0.0

If you are looking for the Västtrafik-card where you can group sensors based on departure or destination, you want the (discontinued) v1.0.0

Installation

Install card-tools by adding card-tools.js to your lovelace resources. Install this card either through HACS (recommended), or by manually extracting and setting up as a resource.

Options

Name Type Default Description
entities list Required A list of entity sensors provided by the Västtrafik integration
title string Västtrafik The title of the card
municipality string Göteborg The municipality of the station(s), more info here
sort boolean true Whether to sort the departures (earliest first), or keep the entities in the given order
showFrom boolean true Whether to show the departing station or not
showTo boolean false Whether to show the arriving station or not
showDir boolean false Whether to show the destination station or not

Municipality

As there are many lines with the same name or number in Västra Götaland, the styles are split by municipality. For accuracy, choose the municipality of your departing sensor(s).

Currently supported municipalities:

Ale
Alingsås
Åmål
Årjäng
Bengtsfors
Bollebygd
Borås
Dals-Ed
Essunga
Falkenberg
Falköping
Färgelanda
Göteborg
Götene
Grästorp
Gullspång
Habo
Hallsberg
Härryda
Herrljunga
Hjo
Jönköping
Karlsborg
Kristinehamn
Kumla
Kungälv
Kungsbacka
Laxå
Lerum
Lidköping
Lilla Edet
Lysekil
Mariestad
Mark
Mellerud
Mölndal
Mullsjö
Munkedal
Nässjö
Norge
Öckerö
Örebro
Orust
Partille
Säffle
Skara
Skövde
Sotenäs
Stenungsund
Strömstad
Svenljunga
Tanum
Tibro
Tidaholm
Tjörn
Töreboda
Tranemo
Trollhättan
Uddevalla
Ulricehamn
Vänersborg
Vara
Varberg
Vårgårda
Västra Götaland

Examples

type: 'custom:vasttrafik-card'
title: 'Mot Brunnsparken'
entities:
  - sensor.ekedal_till_brunnsparken
  - sensor.godhemsgatan_till_brunnsparken
municipality: Göteborg
sort: true

Example 1

Tram and bus styles (example shows Göteborg)

Colours for each tram or bus line

In case of errors

  1. A warning will be printed to the console if any entity id you provide is not attributed to Västtrafik
  2. The sensor updates every 2 minutes, so you will sometimes get -2 minutes until departure

Västtrafik updated their designs?

To get the latest designs/colours exported as css, run python3 ../helpers/generate_css.py from the dist folder.

lovelace-vasttrafik-card's People

Contributors

frankysan avatar miicroo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lixgbg frankysan

lovelace-vasttrafik-card's Issues

Trouble getting the lovelace-card to work.

Dear Magnus,

I'm quite new to HA and adding cards manually.

What I've done so far:

  • Added vasttrafik-card.js, vasttrafik-card-editor.js, vasttrafik-card.css from the dist folder to:
    ../www/community/lovelace-vasttrafik-card

  • Added your version of vasttrafik sensor (ha-vasttrafik) to:
    ../custom_components/vasttrafik

  • I also added the url of the lovelace .js files via the GUI:
    https://my.home-assistant.io/redirect/lovelace_resources/

With these entries:

  • url: /local/community/lovelace-vasttrafik-card/vasttrafik-card.js
    type: module
  • url: /local/community/lovelace-vasttrafik-card/vasttrafik-card-editor.js
    type: module
  • Restarted HA and the browser but when I try to add the card with yaml in the editor of HA it gets this error:

image

Sincerely yours,
MonkeyFaceMoney

Unreasonable departure times, "in 1000+ minutes"

Sometimes the card shows unreasonable values, like 1000+ minutes to the next departure. It seems to happen mostly on the HA app on android, but haven't found all edge cases yet. It can either be that the card itself is not updated, that the values are incorrect or a miscalculation.

Update editor

The editor needs a refresh and to get up to the latest standards, at the moment it is broken.

Add option to have "To" in table instead of "From"

It would be good to have the table optionally show the "heading" (as specified in the configuration) in the table instead of the "from", since "from" does not specify the direction, one tram number can go two directions.

I normally use only one "from" station but multiple "headings", depending on where I am going.

Better handling of empty sensor

I have a sensor for a bus that runs at certain time intervals, and only on weekdays. This means that the sensor is undefined for all other times. This results in a line that doesn't get rendered properly on the card.

This is my code for the card:

type: custom:vasttrafik-card
title: Bussavgångar
entities:
  - sensor.17_mot_stan
  - sensor.44_mot_stan
municipality: Göteborg
sort: true
showFrom: false
showTo: false
showDir: true

The code for sensors:

- platform: vasttrafik
  key: !secret vasttrafik_api_key
  secret: !secret vasttrafik_api_secret
  departures:
    - name: 17, Mot stan
      from: Norumsgärde
      heading: Tuve torg
      delay: 5
      lines:
        - 17
    - name: 44, Mot stan
      from: Norumsgärde
      heading: Tuve torg
      delay: 5
      lines:
        - 44

The resulting card:
vasttrafik

I'm not really a programmer, more of a hobby hacker, but I'll see what I can do myself on my branch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.