royto / logbook-card

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

Automation triggers not showed #91

Closed L0bit0 closed 11 months ago

L0bit0 commented 12 months ago

Hi

I configured a card to show different entities logs, one of them is an automation. If I do the same with the standard log card, i see when the automation was launched. here you have side by side: image

and the code:

type: logbook
entities:
  - automation.alert_shelly_aerotermia_off
  - binary_sensor.aerotermia_termostato_status
  - switch.shellyaerotermia_switch
  - binary_sensor.aerotermia
type: custom:multiple-logbook-card
desc: true
entities:
  - entity: binary_sensor.aerotermia_termostato_status
  - entity: switch.shellyaerotermia_switch
  - entity: binary_sensor.aerotermia
  - entity: automation.alert_shelly_aerotermia_off
history: 1
date_format: DD-MMM hh:mm:ss
scroll: false
action: more-info
show:
  state: true
  duration: true
  start_date: true
  end_date: true
  icon: true
  separator: true
  entity_name: true
custom_logs: true

I am missing anything? There is a way to show automation triggers?

Thansk

royto commented 12 months ago

For mutli-entities, the custom_logs: true has to be set per entity

Can you try with this configuration

type: custom:multiple-logbook-card
desc: true
entities:
  - entity: binary_sensor.aerotermia_termostato_status
  - entity: switch.shellyaerotermia_switch
  - entity: binary_sensor.aerotermia
  - entity: automation.alert_shelly_aerotermia_off
    custom_logs: true
history: 1
date_format: DD-MMM hh:mm:ss
scroll: false
action: more-info
show:
  state: true
  duration: true
  start_date: true
  end_date: true
  icon: true
  separator: true
  entity_name: true
L0bit0 commented 12 months ago

Hi

thanks for the response, but it is not working: image

Thanks

royto commented 12 months ago

Can you provide the response of the call to /api/logbook (tab network in developper tools of your browser (F12)) ?

L0bit0 commented 12 months ago

Hi

not sure if I capture correctlly, this is what i got (I use google chrome):

image

This is Response tab content

[
    {
        "name": "ALERT - Shelly Aerotermia Off",
        "message": "triggered by state of switch.shellyaerotermia_switch",
        "source": "state of switch.shellyaerotermia_switch",
        "entity_id": "automation.alert_shelly_aerotermia_off",
        "context_id": "01HGDSY4KDMM0D52W2BPR7X9SW",
        "when": "2023-11-29T15:07:38.990412+00:00",
        "domain": "automation"
    },
    {
        "name": "ALERT - Shelly Aerotermia Off",
        "message": "triggered by state of switch.shellyaerotermia_switch",
        "source": "state of switch.shellyaerotermia_switch",
        "entity_id": "automation.alert_shelly_aerotermia_off",
        "context_id": "01HGFN6AATZGT2TGPE7A07QGJP",
        "when": "2023-11-30T08:23:12.987166+00:00",
        "domain": "automation"
    },
    {
        "name": "ALERT - Shelly Aerotermia Off",
        "message": "triggered by state of switch.shellyaerotermia_switch",
        "source": "state of switch.shellyaerotermia_switch",
        "entity_id": "automation.alert_shelly_aerotermia_off",
        "context_id": "01HGFXDC9YGEDC9E7JRX61C0FY",
        "when": "2023-11-30T10:46:52.990946+00:00",
        "domain": "automation"
    },
    {
        "name": "ALERT - Shelly Aerotermia Off",
        "message": "triggered by state of switch.shellyaerotermia_switch",
        "source": "state of switch.shellyaerotermia_switch",
        "entity_id": "automation.alert_shelly_aerotermia_off",
        "context_id": "01HGFYASPX02YMPFKD57GH4PGZ",
        "when": "2023-11-30T11:02:56.990276+00:00",
        "domain": "automation"
    },
    {
        "name": "ALERT - Shelly Aerotermia Off",
        "message": "triggered by state of switch.shellyaerotermia_switch",
        "source": "state of switch.shellyaerotermia_switch",
        "entity_id": "automation.alert_shelly_aerotermia_off",
        "context_id": "01HGFYPAVBD68VFYH4CA4988HP",
        "when": "2023-11-30T11:09:14.987630+00:00",
        "domain": "automation"
    },
    {
        "when": "2023-11-30T11:37:35.298729+00:00",
        "state": "unavailable",
        "entity_id": "automation.alert_shelly_aerotermia_off",
        "name": "ALERT - Shelly Aerotermia Off"
    },
    {
        "when": "2023-11-30T11:37:35.313002+00:00",
        "state": "on",
        "entity_id": "automation.alert_shelly_aerotermia_off",
        "name": "ALERT - Shelly Aerotermia Off"
    }
]

let me know if this is not what you was looking for.

thanks!

royto commented 12 months ago

this is exactly what I was looking for.

Is it possible to have the automation that create the log please (as yaml) ?

L0bit0 commented 12 months ago

for sure, but I need some help to do, you mean an automation to call a service? can you give more details on how to create?

thansk

royto commented 11 months ago

can you paste here the content of the automation.alert_shelly_aerotermia_off automation

L0bit0 commented 11 months ago

Hi

her you have:

alias: ALERT - Shelly Aerotermia Off
description: ""
trigger:
  - platform: state
    entity_id:
      - switch.shellyaerotermia_switch
    to: unavailable
    for:
      hours: 0
      minutes: 5
      seconds: 0
  - platform: state
    entity_id:
      - switch.shellyaerotermia_switch
    to: unknown
    for:
      hours: 0
      minutes: 5
      seconds: 0
  - platform: state
    entity_id:
      - switch.shellyaerotermia_switch
    to: "off"
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition:
  - condition: state
    entity_id: automation.schedule_aerotermia_on_3_00pm_to_5_00pm_v2
    state: "off"
action:
  - service: notify.mobile_app_l0bit0iphonese
    data:
      title: HA - Shelly Aerotermia
      data:
        push:
          sound:
            name: default
            critical: 1
            volume: 1
      message: Shelly aerotermia is  {{ states('switch.shellyaerotermia_switch') }}
mode: single

Quick explain: I am just checking if a switch is available or off. If it is off and another schedule is not on (just to ensure the switch is not off by other automation), it sends me an alert.

Anyway I have created a couple of new cards to compare logs just for some automations I have and any trigger action is not showed: image Thanks!

L0bit0 commented 11 months ago

@royto an update? this info gives you any clue? anyone else can chek?

thanks

royto commented 11 months ago

All good for me. Working on it

L0bit0 commented 11 months ago

Hi

Sorry, @royto I do not get you, you mean you have identified the issue and working on a fix? or you are working on the analysis.

Thanks in advance.

royto commented 11 months ago

Should be fixed in v2.1.1

L0bit0 commented 11 months ago

Thansk so much for your clarification and your help!

L0bit0 commented 11 months ago

hi

@royto thansk you so much for the fix, now is working fine: image NOTE: I have tested with a different automation triggered more often as original one is not launched on some days...

thanks!