jesmak / package-tracker-card

Custom Lovelace card for package tracking
MIT License
3 stars 0 forks source link

Opotion to hide the card when no packages to track #1

Open Aasikki opened 3 weeks ago

Aasikki commented 3 weeks ago

Can we have an option to hide the card when there's no packages to track? Currently the card displays "no packages to track at the moment" which imo adds unnecessary clutter to my dashboard.

Maybe something like "hide_when_no_packages" or "hide_when_empty" which when set to "true" would hide the card when you're not expecting for any packages.

jesmak commented 2 weeks ago

Hey! As this is something already achievable with Home Assistant's built-in conditional card, I'm not keen on adding the same functionality to the card itself. You do need to create a template sensor, but with that it's quite simple. See the example below.

Template sensor definition for getting the total number of packages: {{ state_attr("sensor.matkahuolto_XXXXXXXX", "packages")|count + state_attr("sensor.posti_XXXXXXXX", "packages")|count }}

Conditional card configuration:

type: conditional
conditions:
  - condition: numeric_state
    entity: sensor.lahetysten_kokonaismaara
    above: 0
card:
  type: custom:package-tracker-card
  entity:
    - sensor.posti_XXXXXXXXXX
    - sensor.matkahuolto_XXXXXXXXXXX
  max_events: 3
  title: Lähetykset
  show_destination: false