diff --git a/gallery/src/data/traces/basic_trace.ts b/gallery/src/data/traces/basic_trace.ts new file mode 100644 index 0000000000..fa17713af2 --- /dev/null +++ b/gallery/src/data/traces/basic_trace.ts @@ -0,0 +1,182 @@ +import { DemoTrace } from "./types"; + +export const basicTrace: DemoTrace = { + trace: { + last_action: "action/0", + last_condition: "condition/0", + run_id: "0", + state: "stopped", + timestamp: { + start: "2021-03-12T21:38:48.050464+00:00", + finish: "2021-03-12T21:38:48.068458+00:00", + }, + trigger: "state of input_boolean.toggle_1", + unique_id: "1615419646544", + action_trace: { + "action/0": [ + { + timestamp: "2021-03-12T21:38:48.054395+00:00", + changed_variables: { + trigger: { + platform: "state", + entity_id: "input_boolean.toggle_1", + from_state: { + entity_id: "input_boolean.toggle_1", + state: "on", + attributes: { editable: true, friendly_name: "Toggle 1" }, + last_changed: "2021-03-12T21:38:03.262985+00:00", + last_updated: "2021-03-12T21:38:03.262985+00:00", + context: { + id: "4ad34793b237d7cb5e541e8a331e7bf9", + parent_id: null, + user_id: null, + }, + }, + to_state: { + entity_id: "input_boolean.toggle_1", + state: "off", + attributes: { editable: true, friendly_name: "Toggle 1" }, + last_changed: "2021-03-12T21:38:48.049816+00:00", + last_updated: "2021-03-12T21:38:48.049816+00:00", + context: { + id: "2d83ca81663c85df51fae2a1f940d0e7", + parent_id: null, + user_id: "d1b4e89da01445fa8bc98e39fac477ca", + }, + }, + for: null, + attribute: null, + description: "state of input_boolean.toggle_1", + }, + context: { + id: "febeaa3d50152bae8017d783ed3c0751", + parent_id: "2d83ca81663c85df51fae2a1f940d0e7", + user_id: null, + }, + }, + }, + ], + }, + condition_trace: { + "condition/0": [ + { + timestamp: "2021-03-12T21:38:48.050783+00:00", + changed_variables: { + trigger: { + platform: "state", + entity_id: "input_boolean.toggle_1", + from_state: { + entity_id: "input_boolean.toggle_1", + state: "on", + attributes: { editable: true, friendly_name: "Toggle 1" }, + last_changed: "2021-03-12T21:38:03.262985+00:00", + last_updated: "2021-03-12T21:38:03.262985+00:00", + context: { + id: "4ad34793b237d7cb5e541e8a331e7bf9", + parent_id: null, + user_id: null, + }, + }, + to_state: { + entity_id: "input_boolean.toggle_1", + state: "off", + attributes: { editable: true, friendly_name: "Toggle 1" }, + last_changed: "2021-03-12T21:38:48.049816+00:00", + last_updated: "2021-03-12T21:38:48.049816+00:00", + context: { + id: "2d83ca81663c85df51fae2a1f940d0e7", + parent_id: null, + user_id: "d1b4e89da01445fa8bc98e39fac477ca", + }, + }, + for: null, + attribute: null, + description: "state of input_boolean.toggle_1", + }, + }, + result: { result: true }, + }, + ], + }, + config: { + id: "1615419646544", + alias: "Basic Trace Example", + description: "", + trigger: [{ platform: "state", entity_id: "input_boolean.toggle_1" }], + condition: [ + { + condition: "template", + alias: "Test if Paulus is home", + value_template: "{{ true }}", + }, + ], + action: [ + { + service: "input_boolean.toggle", + alias: "Enable party mode", + target: { entity_id: "input_boolean.toggle_2" }, + }, + ], + mode: "single", + }, + context: { + id: "febeaa3d50152bae8017d783ed3c0751", + parent_id: "2d83ca81663c85df51fae2a1f940d0e7", + user_id: null, + }, + variables: { + trigger: { + platform: "state", + entity_id: "input_boolean.toggle_1", + from_state: { + entity_id: "input_boolean.toggle_1", + state: "on", + attributes: { editable: true, friendly_name: "Toggle 1" }, + last_changed: "2021-03-12T21:38:03.262985+00:00", + last_updated: "2021-03-12T21:38:03.262985+00:00", + context: { + id: "4ad34793b237d7cb5e541e8a331e7bf9", + parent_id: null, + user_id: null, + }, + }, + to_state: { + entity_id: "input_boolean.toggle_1", + state: "off", + attributes: { editable: true, friendly_name: "Toggle 1" }, + last_changed: "2021-03-12T21:38:48.049816+00:00", + last_updated: "2021-03-12T21:38:48.049816+00:00", + context: { + id: "2d83ca81663c85df51fae2a1f940d0e7", + parent_id: null, + user_id: "d1b4e89da01445fa8bc98e39fac477ca", + }, + }, + for: null, + attribute: null, + description: "state of input_boolean.toggle_1", + }, + }, + }, + logbookEntries: [ + { + name: "Ensure Party mode", + message: "has been triggered by state of input_boolean.toggle_1", + source: "state of input_boolean.toggle_1", + entity_id: "automation.toggle_toggles", + when: "2021-03-12T21:38:48.051460+00:00", + domain: "automation", + }, + { + when: "2021-03-12T21:38:48.064184+00:00", + name: "Toggle 2", + state: "off", + entity_id: "input_boolean.toggle_2", + context_entity_id: "automation.toggle_toggles", + context_entity_id_name: "Ensure Party mode", + context_event_type: "automation_triggered", + context_domain: "automation", + context_name: "Ensure Party mode", + }, + ], +}; diff --git a/gallery/src/data/traces/types.ts b/gallery/src/data/traces/types.ts new file mode 100644 index 0000000000..11ccf0e36e --- /dev/null +++ b/gallery/src/data/traces/types.ts @@ -0,0 +1,7 @@ +import { AutomationTraceExtended } from "../../../../src/data/automation_debug"; +import { LogbookEntry } from "../../../../src/data/logbook"; + +export interface DemoTrace { + trace: AutomationTraceExtended; + logbookEntries: LogbookEntry[]; +} diff --git a/gallery/src/demos/demo-automation-trace.ts b/gallery/src/demos/demo-automation-trace.ts new file mode 100644 index 0000000000..c7bca8f523 --- /dev/null +++ b/gallery/src/demos/demo-automation-trace.ts @@ -0,0 +1,62 @@ +import { + customElement, + html, + css, + LitElement, + TemplateResult, + property, +} from "lit-element"; +import "../../../src/components/ha-card"; +import "../../../src/components/trace/hat-trace"; +import { provideHass } from "../../../src/fake_data/provide_hass"; +import { HomeAssistant } from "../../../src/types"; +import { basicTrace } from "../data/traces/basic_trace"; +import { DemoTrace } from "../data/traces/types"; + +const traces: DemoTrace[] = [basicTrace]; + +@customElement("demo-automation-trace") +export class DemoAutomationTrace extends LitElement { + @property({ attribute: false }) hass?: HomeAssistant; + + protected render(): TemplateResult { + if (!this.hass) { + return html``; + } + return html` + ${traces.map( + (trace) => html` + +
+ +
+
+ ` + )} + `; + } + + protected firstUpdated(changedProps) { + super.firstUpdated(changedProps); + provideHass(this); + } + + static get styles() { + return css` + ha-card { + max-width: 600px; + margin: 24px; + } + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + "demo-automation-trace": DemoAutomationTrace; + } +} diff --git a/gallery/src/demos/demo-more-info-light.ts b/gallery/src/demos/demo-more-info-light.ts index 3a05f1becf..d469da2212 100644 --- a/gallery/src/demos/demo-more-info-light.ts +++ b/gallery/src/demos/demo-more-info-light.ts @@ -81,4 +81,8 @@ class DemoMoreInfoLight extends LitElement { } } -customElements.define("demo-more-info-light", DemoMoreInfoLight); +declare global { + interface HTMLElementTagNameMap { + "demo-more-info-light": DemoMoreInfoLight; + } +} diff --git a/gallery/src/ha-gallery.js b/gallery/src/ha-gallery.js index c1de40203d..f94fd0ab53 100644 --- a/gallery/src/ha-gallery.js +++ b/gallery/src/ha-gallery.js @@ -111,29 +111,9 @@ class HaGallery extends PolymerElement { - -
-

- More info screens show up when an entity is clicked. -

-
- -
- - -
-

- Test pages for our utility functions. -

-
-