Miicroo / lovelace-vasttrafik-card

Lovelace card for displaying transportation data from Västtrafik in HomeAssistant
10 stars 2 forks source link

Better handling of empty sensor #14

Closed frankysan closed 11 months ago

frankysan commented 1 year ago

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.

Miicroo commented 1 year ago

Ah, good catch! I thought I had some handling to filter these out but it might have been lost in a rewrite some time back! Let me know if you find something, otherwise I will have a look at it :)

Miicroo commented 11 months ago

Fixed in https://github.com/Miicroo/lovelace-vasttrafik-card/pull/15