amaximus / garbage-collection-card

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

Fixed due_txt: true #100

Closed mookkari closed 1 year ago

mookkari commented 1 year ago

Changed the code to show "due today" or "tomorrow" when: hide_date: false hide_days: true due_txt: true

mookkari commented 1 year ago

I prefer to use parameter combination below. My problem is just near collecting date that I do not know if collecting will be tomorrow or is is today. Parameter due_txt has no affect in this case. hide_date: false hide_days: true (due_txt: true)

I have changed the code to take account due_txt=true.

I would prefer to make other changes to make parameter more undertandable:

Please take a look for my changes and detailed example below.


hide_date: true hide_days: true due_txt: true

No changes to behaviour.


hide_date: false hide_days: true due_txt: false

No changes to behaviour.

Better option would be to drive 'Due today' and 'Due tomorrow' behaviour just using parameter due_txt without automatic rules: due_txt: false --> Show always days and/or date depending parameters hide_date/hide_days. due_txt: true --> Show always 'Due today' or 'Due tomorrow' for parameters hide_date/hide_days. Preferred to change also default due_txt=true to keep earlier behaviour in most of the configurations.

Would that make sense?


amaximus commented 1 year ago

Please unset/remove verbose_state in/from the sensor definition and due_txt setting of the card will be granted.

mookkari commented 1 year ago

Do you mean if I set verbose_state=false in the garbage_collection helper configuration all changes in this pull request can be ignored? That's not the case.

Actually, I already have verbose_state=false in the garbage_collection plugin and the card shows now translations and texts from the garbage-collection-card. The issue is just that some parameter combinations hide detailed text from the card if the collection is today or tomorrow.

If I set verbose_state=true in garbage_collection, it seems that all texts are coming from the garbage_collection plugin, not from the card. In this case, it seems that any of the card parameters (hide_date, hide_days, due_txt) does not have any effect, it will always use date and verbose Format from the sensor. Basically, I could verbose_state=true to get what I want using plugin configuration, but the plugin is not translated into Finnish so I would need to do add the missing translation garbage_collection plugin. Still prefer to card configuration to get more flexibility and it's already translated.

amaximus commented 1 year ago

The garbage collection integration has two modes:

The card follows these two modes, for verbose_state=false the card will provide the date and days information, while for verbose_state=true these information will be taken from the sensor as-is.

Testing your setup, I don't see any issues, due today|tomorrow is displayed correctly:

(ha_venv3_9) pi@raspberrypi:~/homeassistant_test $date;grep -A 18 -B 1 every_tue  ui-lovelace.yaml
Tue Dec 20 00:12:45 CET 2022
      - type: custom:garbage-collection-card
        entity: sensor.test_garbage_every_tue
        icon_color: green
        #due_color: red
        icon_size: 35px
        hide_date: false
        hide_days: true
        due_txt: true
        details_size: 12px
        hass_lang_priority: true
      - type: custom:garbage-collection-card
        entity: sensor.test_garbage_every_wed
        #icon_color: green
        icon_size: 35px
        hide_date: false
        hide_days: true
        due_txt: true
        details_size: 10px
        due_1_color: brown
        due_color: red
(ha_venv3_9) pi@raspberrypi:~/homeassistant_test $

garbage

mookkari commented 1 year ago

Sorry for the very long delay in answering. I just updated to the latest version 1.22.1. Your example above works and shows 'Today' and 'Tomorrow' but problem is that I do not want to see date, I want to see text like "In 2 days". Therefore I'm using configuration: hide_date: true hide_days: false due_txt: true

I have created 3 Garbage Collection helpers: Today, tomorrow and after 2 days All have verbose_state=false (unchecked), Hide in calendar=true (checked).

Here are my test card configurations: cards:

  - type: custom:garbage-collection-card
    entity: sensor.roskien_tyhjennys
    icon_size: 35px
    icon_color: green
    hide_date: true
    hide_days: false
    due_txt: true
    hide_on_click: false
    title_size: 15px
    hass_lang_priority: false
    due_color: '#FF2400'
    due_1_color: '#FFA500'
  - type: custom:garbage-collection-card
    entity: sensor.test_garbage_every_thu
    icon_size: 35px
    icon_color: green
    hide_date: true
    hide_days: false
    due_txt: true
    hide_on_click: false
    title_size: 15px
    hass_lang_priority: false
    due_color: '#FF2400'
    due_1_color: '#FFA500'
  - type: custom:garbage-collection-card
    entity: sensor.test_garbage_every_fri
    icon_size: 35px
    icon_color: green
    hide_date: true
    hide_days: false
    due_txt: true
    hide_on_click: false
    title_size: 15px
    hass_lang_priority: false
    due_color: '#FF2400'
    due_1_color: '#FFA500'
type: vertical-stack

This is the end result:

image

Cards for today or tomorrow do not show any text. I also tested changing to verbose=true, but the result is exactly the same. The only last card is what I expect. Also, the browser cache was cleaned and tested in incognito more.

Below is an example of what I want to see, but I cannot find any parameter combination from the card or using verbose_state=true/false get card looking like this. In this example the last card has different parameters than the first two to just demonstrate my goal:

image

I prefer using verbose_state=false to get translations for 'Today' and 'Tomorrow' from card translations.

My fix above fixed this problem for the older version.

mookkari commented 1 year ago

With a quick test in my environment with the latest version, I changed line 166 to:

if ( hdays === true && hdate === true && duetxt === false) {

And now it looks as expected:

image

with parameter combination: hide_date: true hide_days: false due_txt: true

It does not matter if verbose_state is true or false.