From 026fc1d2e34c2aa25174137a0031a8eaee36ab24 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 23 Aug 2020 17:00:27 -0500 Subject: [PATCH 1/4] Show the entity id that first used the context in logbook --- src/data/logbook.ts | 2 ++ src/panels/logbook/ha-logbook.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/data/logbook.ts b/src/data/logbook.ts index fd79c87301..ac6f342f7b 100644 --- a/src/data/logbook.ts +++ b/src/data/logbook.ts @@ -7,6 +7,8 @@ export interface LogbookEntry { entity_id?: string; domain: string; context_user_id?: string; + context_entity_id?: string; + context_entity_id_name?: string; } const DATA_CACHE: { diff --git a/src/panels/logbook/ha-logbook.ts b/src/panels/logbook/ha-logbook.ts index 3fb8bf7a0c..d95ee7e156 100644 --- a/src/panels/logbook/ha-logbook.ts +++ b/src/panels/logbook/ha-logbook.ts @@ -118,6 +118,18 @@ class HaLogbook extends LitElement { ? ` (${item_username})` : ``} + ${!item.context_entity_id + ? "" + : html` + by + ${item.context_entity_id_name} + `} From 63fef9bd4bb1c275c642aefb2fdd8a96733c8475 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 24 Aug 2020 11:23:07 -0500 Subject: [PATCH 2/4] Adjust to handle service calls and described events --- src/data/logbook.ts | 4 ++++ src/panels/logbook/ha-logbook.ts | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/data/logbook.ts b/src/data/logbook.ts index ac6f342f7b..c1ff44b6fe 100644 --- a/src/data/logbook.ts +++ b/src/data/logbook.ts @@ -7,8 +7,12 @@ export interface LogbookEntry { entity_id?: string; domain: string; context_user_id?: string; + context_event_type?: string; + context_domain?: string; + context_service?: string; context_entity_id?: string; context_entity_id_name?: string; + context_name?: string; } const DATA_CACHE: { diff --git a/src/panels/logbook/ha-logbook.ts b/src/panels/logbook/ha-logbook.ts index d95ee7e156..831a394e95 100644 --- a/src/panels/logbook/ha-logbook.ts +++ b/src/panels/logbook/ha-logbook.ts @@ -118,18 +118,26 @@ class HaLogbook extends LitElement { ? ` (${item_username})` : ``} - ${!item.context_entity_id + ${!item.context_event_type ? "" - : html` - by + : item.context_event_type == "service_call" + ? // Service Call + html` by service ${item.context_domain}.${item.context_service}` + : item.context_entity_id == item.entity_id + ? // HomeKit or something that self references + html` by + ${item.context_name + ? item.context_name + : item.context_event_type}` + : // Another entity such as an automation or script + html` by ${item.context_entity_id_name} - `} + >`} From d49302c03227d60c78d9a1067a05b9764fa6a70e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 24 Aug 2020 12:20:48 -0500 Subject: [PATCH 3/4] typo --- src/panels/logbook/ha-logbook.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/logbook/ha-logbook.ts b/src/panels/logbook/ha-logbook.ts index 831a394e95..635a4113a1 100644 --- a/src/panels/logbook/ha-logbook.ts +++ b/src/panels/logbook/ha-logbook.ts @@ -120,7 +120,7 @@ class HaLogbook extends LitElement { > ${!item.context_event_type ? "" - : item.context_event_type == "service_call" + : item.context_event_type == "call_service" ? // Service Call html` by service ${item.context_domain}.${item.context_service}` : item.context_entity_id == item.entity_id From 63c995e5daa6a3968e1c440867ff80085b8d5949 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 24 Aug 2020 12:24:24 -0500 Subject: [PATCH 4/4] cleanups --- src/panels/logbook/ha-logbook.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/panels/logbook/ha-logbook.ts b/src/panels/logbook/ha-logbook.ts index 635a4113a1..af886126d3 100644 --- a/src/panels/logbook/ha-logbook.ts +++ b/src/panels/logbook/ha-logbook.ts @@ -120,10 +120,10 @@ class HaLogbook extends LitElement { > ${!item.context_event_type ? "" - : item.context_event_type == "call_service" + : item.context_event_type === "call_service" ? // Service Call html` by service ${item.context_domain}.${item.context_service}` - : item.context_entity_id == item.entity_id + : item.context_entity_id === item.entity_id ? // HomeKit or something that self references html` by ${item.context_name