amaximus / garbage-collection-card

Custom Lovelace card for Garbage Collection custom component
MIT License
127 stars 24 forks source link

hide_before isn't hiding the card #117

Closed pvillanyi closed 5 months ago

pvillanyi commented 5 months ago

Describe the bug I wanted to show the cards just 3 days before due date, but hide_befor isn't affecting it.

To Reproduce type: custom:garbage-collection-card entity: sensor.zold_hulladek icon_size: 35px icon_color: green due_1_color: green due_color: red hide_before: 3

Expected behavior cards shouldn't be shown.

Screenshots image

Environment (please complete the following information):

Additional context Add any other context about the problem here.

amaximus commented 5 months ago

The hide_before works the following way: https://github.com/amaximus/garbage-collection-card/blob/master/dist/garbage-collection-card.js#L278

so for hide_before: 3 it will hide the card if the attribute days is greater than 3. See an example from today: both test_garbage_every_tue and test_garbage_every_wed have hide_before: 3, Tue sensor is displayed while Wed sensor is hidden: garbage

(ha_venv3_12) pi@raspberrypi:~/homeassistant_test $grep -v "#" ui-lovelace.yaml | head -30|tail -18
      - type: custom:garbage-collection-card
        entity: sensor.test_garbage_every_tue
        icon_color: green
        icon_size: 35px
        hide_date: false
        hide_days: false
        due_txt: true
        hass_lang_priority: true
        hide_before: 3
      - type: custom:garbage-collection-card
        entity: sensor.test_garbage_every_wed
        icon_size: 35px
        hide_date: false
        hide_days: false
        due_txt: true
        due_1_color: brown
        due_color: red
        hide_before: 3
(ha_venv3_12) pi@raspberrypi:~/homeassistant_test $
pvillanyi commented 5 months ago

OK, it's nice you can use it. Have you and idea, what could be wrong in my card config? You can see, hide_before: 3 for zold_hulladek and the card is shown although it has 26 days.

amaximus commented 5 months ago

I will check tomorrow for green garbage as well.

pvillanyi commented 5 months ago

I use custom sensors with waste collection schedule. It is a simple sensor in matters for garbage collection card. But in my case neighter of the three cards hides when days are bigger than the set number in hide_before...


Feladó: Atticus Maximus @.> Elküldve: 2024. március 10., vasárnap 19:25 Címzett: amaximus/garbage-collection-card @.> Másolatot kap: pvillanyi @.>; Author @.> Tárgy: Re: [amaximus/garbage-collection-card] hide_before isn't hiding the card (Issue #117)

I will check tomorrow for green garbage as well.

— Reply to this email directly, view it on GitHubhttps://github.com/amaximus/garbage-collection-card/issues/117#issuecomment-1987317749, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AXVFZ65435VSK45EPKYGW33YXSQS3AVCNFSM6AAAAABENKTAWSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBXGMYTONZUHE. You are receiving this because you authored the thread.Message ID: @.***>

amaximus commented 5 months ago

Please paste here the card configuration for the zold_hulladek sensor.

pvillanyi commented 5 months ago

As shown on top:

type: custom:garbage-collection-card entity: sensor.zold_hulladek icon_size: 35px icon_color: green due_1_color: green due_color: red hide_before: 3

amaximus commented 5 months ago

Could you please also provide a screenshot of the sensor.zoldhulladek as seen in the Developer Tools->States where the attributes are also seen.

pvillanyi commented 5 months ago

image

amaximus commented 5 months ago

The issue is that - as the Readme also mentions - it was written for bruxy70's Garbage Collection integration, meaning that it expects states and attributes as per that integration, e.g. state=0 (collection today), 1 (collection tomorrow) or 2 (collection later) and the days attribute among others: garbage1 If these cannot be found, the card will not work properly.

The Readme also mentions the card in what conditions supports the HACS Waste Collection Schedule integration. Check it out!

pvillanyi commented 5 months ago

I've changed the sensor configuration back to value_template: "{{ value.daysTo }}" and it works now although in developper tools it still doesn't show the days:

pvillanyi commented 5 months ago

the original was: value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %}'

amaximus commented 5 months ago

The simple format of "{{ value.daysTo }}" should be used for the sensor definition together with

platform: waste_collection_schedule
details_format: 'generic'

See the example at the bottom of the Readme.