Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed due_txt: true #100

Merged
merged 1 commit into from
Jan 26, 2023
Merged

Fixed due_txt: true #100

merged 1 commit into from
Jan 26, 2023

Conversation

mookkari
Copy link
Contributor

@mookkari mookkari commented Dec 13, 2022

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

Changed the code show "due today" or "tomorrow" when:
hide_date: false
hide_days: true
due_txt: true
@mookkari
Copy link
Contributor Author

mookkari commented Dec 13, 2022

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:

  • Always follow due_txt=true/false with any paramater combinations hide_date/hide_days.
  • Because of above change default: due_txt=true to keep earlier behaviour in most of the configurations.
  • Remove any "automatically set to true when collection is due today or tomorrow"

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


hide_date: true
hide_days: true
due_txt: true

  • Before: When collection is due today or tomorrow does did not show any details section.
  • After: When collection is due today or tomorrow will show 'Due today' or 'Due tomorrow'

hide_date: true
hide_days: false
due_txt: true

  • Before: When collection is due today or tomorrow does did not show any details section
  • After: When collection is due today or tomorrow will show 'Due today' or 'Due tomorrow'

hide_date: false
hide_days: true
due_txt: true

  • This was working as expected. When collection is due today or tomorrow will show 'Due today' or 'Due tomorrow'

hide_date: true
hide_days: true
due_txt: false

  • No changes to behaviour. Details section always hidden. Also when collection is due today or tomorrow does does not show any details section. I guess this is working as expected if due_txt: false?

hide_date: true
hide_days: false
due_txt: false

No changes to behaviour.

  • Details section only hidden when collection is due today or tomorrow. I guess this is working as expected if due_txt: false. But reason why detail section is hidden is documented feature "hide_days: automatically set to true when collection is due today or tomorrow.", when hide_date=true and hide_days=true is detail section is hidden. I do not fully understand the reason but I guess it better to show 'Due today' or 'Due tomorrow' in near future. But why not using same rule for parameter hide_date (set to true when collection is due today or tomorrow.)

hide_date: false
hide_days: true
due_txt: false

No changes to behaviour.

  • Current: When collection is due today or tomorrow will show 'Due today' or 'Due tomorrow' even if due_txt: false!
  • Proposal: No changes to behaviour at this point but I prefer to change this. In code level I removed "hide_days: automatically set to true when collection is due today or tomorrow.". I think this is unnecessary after my changes.

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
Copy link
Owner

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

@mookkari
Copy link
Contributor Author

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
Copy link
Owner

The garbage collection integration has two modes:

  • verbose_state=false in which case the sensor state is a digit (0-2): 0: due today, 1: due tomorrow, 2: later than tomorrow
  • verbose_state=true in which case the sensor state is a free text provided by the sensor definition

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@amaximus amaximus merged commit e6ccd27 into amaximus:master Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants