royto / logbook-card

Logbook card for Home Assistant UI Lovelace
GNU General Public License v3.0
203 stars 9 forks source link

Remove duplicates in multiple logbook card #116

Closed Kanecaine closed 6 months ago

Kanecaine commented 7 months ago

Describe the bug The feature described here

https://github.com/royto/logbook-card/issues/8#issue-517587134

doesnt work in multiple logbook card. I wanted to see a logbook for my window sensors and want to show when they have been open.

Expected behavior No duplicate entries.

Screenshots IMG_0433

Environment (please complete the following information):

Card configuration


type: custom:multiple-logbook-card
desc: true
entities:
  - entity: binary_sensor.alle_fenster
    hidden_state:
      - unavailable
      - 'on'
    state_map:
      - label: geschlossen
        value: 'off'
  - entity: binary_sensor.fenster_bad
    hidden_state:
      - unavailable
      - 'off'
    state_map:
      - label: geöffnet
        value: 'on'
  - entity: binary_sensor.terrassentur
    hidden_state:
      - unavailable
      - 'off'
    state_map:
      - label: geöffnet
        value: 'on'
  - entity: binary_sensor.fenster_wohnen_links
    hidden_state:
      - unavailable
      - 'off'
    state_map:
      - label: geöffnet
        value: 'on'
title: Fenster
collapse: 1
show:
  end_date: false
  start_date: true
group_by_day: true
scroll: true
minimal_duration: 90

Additional context I used the logbook card for multiple entities and added each window sensor with a state filter for „unavailable“ and „off“ - for showing only when they are open. Additionally i added a „all windows closed“ sensor with a state filter for „on“ - for showing only when all windows are closed. I turned on the group-by-day function.

Kanecaine commented 7 months ago

I suppose it is the minimal_duration option. It filters out when a window is only opened for a short time. At least in one case it is the reason for duplicate entries in my config.

royto commented 7 months ago

Can you provide the full history (without hidden states) and provide the history you want to be displayed based on your configuration?

Is it working with non multiple card ?

Kanecaine commented 7 months ago

Hi, thanks for your reply. I found an explanation for the 2 „alle Fenster geschlossen“ at 21:29 on March, 31. I simply missed too add all window sensors. So between these to „closed“ events, there have been another “opened“ event. After adding the missing sensor, the history shows right.

With all filters removed i scrolled to the same date/time (2 cards, first one with filters, second one without):

IMG_0435

The two „Terrassentür geöffnet“ events at 14:28 on April, 1st: between them is a „Terrassentür geschlossen“ event which i filtered out. So maybe your card does all right - i don’t know what it should show in that case. Combining the two „open“ events would not be right. So if i filter out the „closed“ event it shows right in history, isn‘t it?

royto commented 7 months ago

Yes, to me the behaviour is correct and squashing the 2 open state will lead to a invalid state ...

If OK for you, you can close the issue

royto commented 6 months ago

@Kanecaine can we close the issue ?

Kanecaine commented 6 months ago

Hi @royto, yes it works as aspected now. This can be closed. Sorry, for my late response and thanks for your support.