royto / logbook-card

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

Unknown with custom log #85

Closed alphasixtyfive closed 1 year ago

alphasixtyfive commented 1 year ago

Describe the bug

For some reason I'm getting a single "Unknown" entry whenever

image

Although default logbook card displays it just fine:

image

Card configuration

type: custom:logbook-card
entity: input_button.logbook_tasker
custom_logs: true
- alias: Tasker event receiver log
  trigger:
    - platform: event
      event_type: "tasker"
  action:
    - alias: Make a log entry
      service: logbook.log
      data:
        name: "{{ trigger.event.data.app }}"
        message: "{{ trigger.event.data.message }}"
        entity_id: input_button.logbook_tasker
royto commented 1 year ago

Add show_history: false to your config this issue.

type: custom:logbook-card
entity: input_button.logbook_tasker
custom_logs: true
show_history: false

I'll update documentation to clarify this

alphasixtyfive commented 1 year ago

Add show_history: false to your config this issue.

type: custom:logbook-card
entity: input_button.logbook_tasker
custom_logs: true
show_history: false

I'll update documentation to clarify this

Thanks, however this did not help.

royto commented 1 year ago

Can you confirm that you are using the last version of the card ?

alphasixtyfive commented 1 year ago

I do. The version is 2.0.1. Perhaps it would help if I provided an output of API call to history endpoint?

alphasixtyfive commented 1 year ago

In an unusual turn of events it actually outputs unknown:

http://XXX:8123/api/history/period/2023-11-13T00%3A00%3A00.000Z?filter_entity_id=input_button.logbook_tasker
[
    [
        {
            "entity_id": "input_button.logbook_tasker",
            "state": "unknown",
            "attributes": {
                "icon": "mdi:math-log",
                "friendly_name": "Logbook Tasker"
            },
            "last_changed": "2023-11-13T00:00:00+00:00",
            "last_updated": "2023-11-13T00:00:00+00:00"
        },
        {
            "entity_id": "input_button.logbook_tasker",
            "state": "unknown",
            "attributes": {
                "icon": "mdi:math-log",
                "friendly_name": "Logbook Tasker"
            },
            "last_changed": "2023-11-13T10:03:21.707839+00:00",
            "last_updated": "2023-11-13T10:03:21.707839+00:00"
        },
        {
            "entity_id": "input_button.logbook_tasker",
            "state": "unknown",
            "attributes": {
                "icon": "mdi:math-log",
                "friendly_name": "Logbook Tasker"
            },
            "last_changed": "2023-11-13T23:33:03.107622+00:00",
            "last_updated": "2023-11-13T23:33:03.107622+00:00"
        }
    ]
]
alphasixtyfive commented 1 year ago

This is the output of /api/logbook on the other hand:

[
    {
        "when": "2023-11-13T21:31:17.606946+00:00",
        "name": "com.pyronixhc2.android.app",
        "message": "13/11/23 21:31:31: Saturn External Beam: Armed by: User 01",
        "domain": "input_button",
        "entity_id": "input_button.logbook_tasker",
        "context_event_type": "automation_triggered",
        "context_domain": "automation",
        "context_name": "Tasker event receiver log",
        "context_message": "triggered by event 'tasker'",
        "context_source": "event 'tasker'",
        "context_entity_id": "automation.tasker_event_receiver_log",
        "context_entity_id_name": "Tasker event receiver log"
    },
    {
        "when": "2023-11-13T21:31:37.895000+00:00",
        "name": "com.pyronixhc2.android.app",
        "message": "13/11/23 21:31:51: Saturn External Beam: Disarmed: User 01",
        "domain": "input_button",
        "entity_id": "input_button.logbook_tasker",
        "context_event_type": "automation_triggered",
        "context_domain": "automation",
        "context_name": "Tasker event receiver log",
        "context_message": "triggered by event 'tasker'",
        "context_source": "event 'tasker'",
        "context_entity_id": "automation.tasker_event_receiver_log",
        "context_entity_id_name": "Tasker event receiver log"
    }
]
royto commented 1 year ago

there is a pb with show_history. I'll check that

alphasixtyfive commented 1 year ago

Many thanks for taking the time to look into this, however this did not solve the issue. With show_history set to false it shows a No event on the period message, and when you set it it to true it once again shows a single Unknown entry.

royto commented 1 year ago

ok. Seems that when you log using your automation, it is not setting the context_service property to log on which I'm filtering on ...

alphasixtyfive commented 1 year ago

ok. Seems that when you log using your automation, it is not setting the context_service property to log on which I'm filtering on ...

I might be wrong but shouldn't you just filter by entity_id or domain?

royto commented 1 year ago

the call to the api is already filtered per entity.

I think I will autorize log with "context_domain": "automation"

royto commented 1 year ago

Version 2.1.0 should fix the issue

alphasixtyfive commented 1 year ago

It works now, thank you!