diff --git a/.github/workflows/translations.yaml b/.github/workflows/translations.yaml index 3aa24b9d80..701277f973 100644 --- a/.github/workflows/translations.yaml +++ b/.github/workflows/translations.yaml @@ -7,7 +7,7 @@ on: branches: - dev paths: - - translations/en.json + - src/translations/en.json env: NODE_VERSION: 12 diff --git a/cast/src/launcher/layout/hc-layout.ts b/cast/src/launcher/layout/hc-layout.ts index 58e1f7cc94..76a3af25ef 100644 --- a/cast/src/launcher/layout/hc-layout.ts +++ b/cast/src/launcher/layout/hc-layout.ts @@ -100,7 +100,7 @@ class HcLayout extends LitElement { display: block; margin: 0; } - + .hero { border-radius: 4px 4px 0 0; } diff --git a/cast/src/receiver/layout/hc-lovelace.ts b/cast/src/receiver/layout/hc-lovelace.ts index 3812da11d0..be23073207 100644 --- a/cast/src/receiver/layout/hc-lovelace.ts +++ b/cast/src/receiver/layout/hc-lovelace.ts @@ -39,7 +39,7 @@ class HcLovelace extends LitElement { urlPath: this.urlPath!, enableFullEditMode: () => undefined, mode: "storage", - language: "en", + locale: this.hass.locale, saveConfig: async () => undefined, deleteConfig: async () => undefined, setEditMode: () => undefined, @@ -94,6 +94,7 @@ class HcLovelace extends LitElement { return css` :host { min-height: 100vh; + height: 0; display: flex; flex-direction: column; box-sizing: border-box; diff --git a/gallery/src/data/traces/basic_trace.ts b/gallery/src/data/traces/basic_trace.ts new file mode 100644 index 0000000000..24afe1fa07 --- /dev/null +++ b/gallery/src/data/traces/basic_trace.ts @@ -0,0 +1,382 @@ +import { DemoTrace } from "./types"; + +export const basicTrace: DemoTrace = { + trace: { + last_action: "action/2", + last_condition: "condition/0", + run_id: "0", + state: "stopped", + timestamp: { + start: "2021-03-25T04:36:51.223693+00:00", + finish: "2021-03-25T04:36:51.266132+00:00", + }, + trigger: "state of input_boolean.toggle_1", + domain: "automation", + item_id: "1615419646544", + trace: { + "condition/0": [ + { + path: "condition/0", + timestamp: "2021-03-25T04:36:51.228243+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-24T19:03:59.141440+00:00", + last_updated: "2021-03-24T19:03:59.141440+00:00", + context: { + id: "5d0918eb379214d07554bdab6a08bcff", + 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-25T04:36:51.220696+00:00", + last_updated: "2021-03-25T04:36:51.220696+00:00", + context: { + id: "664d6d261450a9ecea6738e97269a149", + parent_id: null, + user_id: "d1b4e89da01445fa8bc98e39fac477ca", + }, + }, + for: null, + attribute: null, + description: "state of input_boolean.toggle_1", + }, + }, + result: { + result: true, + }, + }, + ], + "action/0": [ + { + path: "action/0", + timestamp: "2021-03-25T04:36:51.243018+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-24T19:03:59.141440+00:00", + last_updated: "2021-03-24T19:03:59.141440+00:00", + context: { + id: "5d0918eb379214d07554bdab6a08bcff", + 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-25T04:36:51.220696+00:00", + last_updated: "2021-03-25T04:36:51.220696+00:00", + context: { + id: "664d6d261450a9ecea6738e97269a149", + parent_id: null, + user_id: "d1b4e89da01445fa8bc98e39fac477ca", + }, + }, + for: null, + attribute: null, + description: "state of input_boolean.toggle_1", + }, + context: { + id: "6cfcae368e7b3686fad6c59e83ae76c9", + parent_id: "664d6d261450a9ecea6738e97269a149", + user_id: null, + }, + }, + result: { + params: { + domain: "input_boolean", + service: "toggle", + service_data: {}, + target: { + entity_id: ["input_boolean.toggle_4"], + }, + }, + running_script: false, + limit: 10, + }, + }, + ], + "action/1": [ + { + path: "action/1", + timestamp: "2021-03-25T04:36:51.252406+00:00", + result: { + choice: 0, + }, + }, + ], + "action/1/choose/0": [ + { + path: "action/1/choose/0", + timestamp: "2021-03-25T04:36:51.254569+00:00", + result: { + result: true, + }, + }, + ], + "action/1/choose/0/conditions/0": [ + { + path: "action/1/choose/0/conditions/0", + timestamp: "2021-03-25T04:36:51.254697+00:00", + result: { + result: true, + }, + }, + ], + "action/1/choose/0/sequence/0": [ + { + path: "action/1/choose/0/sequence/0", + timestamp: "2021-03-25T04:36:51.257360+00:00", + result: { + params: { + domain: "input_boolean", + service: "toggle", + service_data: {}, + target: { + entity_id: ["input_boolean.toggle_2"], + }, + }, + running_script: false, + limit: 10, + }, + }, + ], + "action/1/choose/0/sequence/1": [ + { + path: "action/1/choose/0/sequence/1", + timestamp: "2021-03-25T04:36:51.260658+00:00", + result: { + params: { + domain: "input_boolean", + service: "toggle", + service_data: {}, + target: { + entity_id: ["input_boolean.toggle_3"], + }, + }, + running_script: false, + limit: 10, + }, + }, + ], + "action/2": [ + { + path: "action/2", + timestamp: "2021-03-25T04:36:51.264159+00:00", + result: { + params: { + domain: "input_boolean", + service: "toggle", + service_data: {}, + target: { + entity_id: ["input_boolean.toggle_4"], + }, + }, + running_script: false, + limit: 10, + }, + }, + ], + }, + + config: { + id: "1615419646544", + alias: "Ensure Party mode", + 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", + target: { + entity_id: "input_boolean.toggle_4", + }, + }, + { + choose: [ + { + alias: "If toggle 3 is on", + conditions: [ + { + condition: "template", + value_template: + "{{ is_state('input_boolean.toggle_3', 'on') }}", + }, + ], + sequence: [ + { + service: "input_boolean.toggle", + alias: "Toggle 2 while 3 is on", + target: { + entity_id: "input_boolean.toggle_2", + }, + }, + { + service: "input_boolean.toggle", + alias: "Toggle 3", + target: { + entity_id: "input_boolean.toggle_3", + }, + }, + ], + }, + ], + default: [ + { + service: "input_boolean.toggle", + alias: "Toggle 2", + target: { + entity_id: "input_boolean.toggle_2", + }, + }, + ], + }, + { + service: "input_boolean.toggle", + target: { + entity_id: "input_boolean.toggle_4", + }, + }, + ], + mode: "single", + }, + context: { + id: "6cfcae368e7b3686fad6c59e83ae76c9", + parent_id: "664d6d261450a9ecea6738e97269a149", + 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-24T19:03:59.141440+00:00", + last_updated: "2021-03-24T19:03:59.141440+00:00", + context: { + id: "5d0918eb379214d07554bdab6a08bcff", + 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-25T04:36:51.220696+00:00", + last_updated: "2021-03-25T04:36:51.220696+00:00", + context: { + id: "664d6d261450a9ecea6738e97269a149", + 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", + context_id: "6cfcae368e7b3686fad6c59e83ae76c9", + when: "2021-03-25T04:36:51.240832+00:00", + domain: "automation", + }, + { + when: "2021-03-25T04:36:51.249828+00:00", + name: "Toggle 4", + state: "on", + entity_id: "input_boolean.toggle_4", + 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", + }, + { + when: "2021-03-25T04:36:51.258947+00:00", + name: "Toggle 2", + state: "on", + 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", + }, + { + when: "2021-03-25T04:36:51.261806+00:00", + name: "Toggle 3", + state: "off", + entity_id: "input_boolean.toggle_3", + 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", + }, + { + when: "2021-03-25T04:36:51.265246+00:00", + name: "Toggle 4", + state: "off", + entity_id: "input_boolean.toggle_4", + 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/motion-light-trace.ts b/gallery/src/data/traces/motion-light-trace.ts new file mode 100644 index 0000000000..9992989124 --- /dev/null +++ b/gallery/src/data/traces/motion-light-trace.ts @@ -0,0 +1,247 @@ +import { DemoTrace } from "./types"; + +export const motionLightTrace: DemoTrace = { + trace: { + last_action: "action/3", + last_condition: null, + run_id: "1", + state: "stopped", + timestamp: { + start: "2021-03-14T06:07:01.768006+00:00", + finish: "2021-03-14T06:07:53.287525+00:00", + }, + trigger: "state of binary_sensor.pauluss_macbook_pro_camera_in_use", + domain: "automation", + item_id: "1614732497392", + trace: { + "action/0": [ + { + path: "action/0", + timestamp: "2021-03-14T06:07:01.771038+00:00", + changed_variables: { + trigger: { + platform: "state", + entity_id: "binary_sensor.pauluss_macbook_pro_camera_in_use", + from_state: { + entity_id: "binary_sensor.pauluss_macbook_pro_camera_in_use", + state: "off", + attributes: { + friendly_name: "Paulus’s MacBook Pro Camera In Use", + icon: "mdi:camera-off", + }, + last_changed: "2021-03-14T06:06:29.235325+00:00", + last_updated: "2021-03-14T06:06:29.235325+00:00", + context: { + id: "ad4864c5ce957c38a07b50378eeb245d", + parent_id: null, + user_id: null, + }, + }, + to_state: { + entity_id: "binary_sensor.pauluss_macbook_pro_camera_in_use", + state: "on", + attributes: { + friendly_name: "Paulus’s MacBook Pro Camera In Use", + icon: "mdi:camera", + }, + last_changed: "2021-03-14T06:07:01.762009+00:00", + last_updated: "2021-03-14T06:07:01.762009+00:00", + context: { + id: "e22ddfd5f11dc4aad9a52fc10dab613b", + parent_id: null, + user_id: null, + }, + }, + for: null, + attribute: null, + description: + "state of binary_sensor.pauluss_macbook_pro_camera_in_use", + }, + context: { + id: "43b6ee9293a551c5cc14e8eb60af54ba", + parent_id: "e22ddfd5f11dc4aad9a52fc10dab613b", + user_id: null, + }, + }, + }, + ], + "action/1": [ + { path: "action/1", timestamp: "2021-03-14T06:07:01.875316+00:00" }, + ], + "action/2": [ + { + path: "action/2", + timestamp: "2021-03-14T06:07:53.195013+00:00", + changed_variables: { + wait: { + remaining: null, + trigger: { + platform: "state", + entity_id: "binary_sensor.pauluss_macbook_pro_camera_in_use", + from_state: { + entity_id: "binary_sensor.pauluss_macbook_pro_camera_in_use", + state: "on", + attributes: { + friendly_name: "Paulus’s MacBook Pro Camera In Use", + icon: "mdi:camera", + }, + last_changed: "2021-03-14T06:07:01.762009+00:00", + last_updated: "2021-03-14T06:07:01.762009+00:00", + context: { + id: "e22ddfd5f11dc4aad9a52fc10dab613b", + parent_id: null, + user_id: null, + }, + }, + to_state: { + entity_id: "binary_sensor.pauluss_macbook_pro_camera_in_use", + state: "off", + attributes: { + friendly_name: "Paulus’s MacBook Pro Camera In Use", + icon: "mdi:camera-off", + }, + last_changed: "2021-03-14T06:07:53.186755+00:00", + last_updated: "2021-03-14T06:07:53.186755+00:00", + context: { + id: "b2308cc91d509ea8e0c623331ab178d6", + parent_id: null, + user_id: null, + }, + }, + for: null, + attribute: null, + description: + "state of binary_sensor.pauluss_macbook_pro_camera_in_use", + }, + }, + }, + }, + ], + "action/3": [ + { + path: "action/3", + timestamp: "2021-03-14T06:07:53.196014+00:00", + }, + ], + }, + config: { + mode: "restart", + max_exceeded: "silent", + trigger: [ + { + platform: "state", + entity_id: "binary_sensor.pauluss_macbook_pro_camera_in_use", + from: "off", + to: "on", + }, + ], + action: [ + { + service: "light.turn_on", + target: { + entity_id: "light.elgato_key_light_air", + }, + }, + { + wait_for_trigger: [ + { + platform: "state", + entity_id: "binary_sensor.pauluss_macbook_pro_camera_in_use", + from: "on", + to: "off", + }, + ], + }, + { + delay: 0, + }, + { + service: "light.turn_off", + target: { + entity_id: "light.elgato_key_light_air", + }, + }, + ], + id: "1614732497392", + alias: "Auto Elgato", + description: "", + }, + context: { + id: "43b6ee9293a551c5cc14e8eb60af54ba", + parent_id: "e22ddfd5f11dc4aad9a52fc10dab613b", + user_id: null, + }, + variables: { + trigger: { + platform: "state", + entity_id: "binary_sensor.pauluss_macbook_pro_camera_in_use", + from_state: { + entity_id: "binary_sensor.pauluss_macbook_pro_camera_in_use", + state: "off", + attributes: { + friendly_name: "Paulus’s MacBook Pro Camera In Use", + icon: "mdi:camera-off", + }, + last_changed: "2021-03-14T06:06:29.235325+00:00", + last_updated: "2021-03-14T06:06:29.235325+00:00", + context: { + id: "ad4864c5ce957c38a07b50378eeb245d", + parent_id: null, + user_id: null, + }, + }, + to_state: { + entity_id: "binary_sensor.pauluss_macbook_pro_camera_in_use", + state: "on", + attributes: { + friendly_name: "Paulus’s MacBook Pro Camera In Use", + icon: "mdi:camera", + }, + last_changed: "2021-03-14T06:07:01.762009+00:00", + last_updated: "2021-03-14T06:07:01.762009+00:00", + context: { + id: "e22ddfd5f11dc4aad9a52fc10dab613b", + parent_id: null, + user_id: null, + }, + }, + for: null, + attribute: null, + description: "state of binary_sensor.pauluss_macbook_pro_camera_in_use", + }, + }, + }, + logbookEntries: [ + { + name: "Auto Elgato", + message: + "has been triggered by state of binary_sensor.pauluss_macbook_pro_camera_in_use", + source: "state of binary_sensor.pauluss_macbook_pro_camera_in_use", + entity_id: "automation.auto_elgato", + when: "2021-03-14T06:07:01.768492+00:00", + domain: "automation", + }, + { + when: "2021-03-14T06:07:01.872187+00:00", + name: "Elgato Key Light Air", + state: "on", + entity_id: "light.elgato_key_light_air", + context_entity_id: "automation.auto_elgato", + context_entity_id_name: "Auto Elgato", + context_event_type: "automation_triggered", + context_domain: "automation", + context_name: "Auto Elgato", + }, + { + when: "2021-03-14T06:07:53.284505+00:00", + name: "Elgato Key Light Air", + state: "off", + entity_id: "light.elgato_key_light_air", + context_entity_id: "automation.auto_elgato", + context_entity_id_name: "Auto Elgato", + context_event_type: "automation_triggered", + context_domain: "automation", + context_name: "Auto Elgato", + }, + ], +}; diff --git a/gallery/src/data/traces/types.ts b/gallery/src/data/traces/types.ts new file mode 100644 index 0000000000..eb99350ebf --- /dev/null +++ b/gallery/src/data/traces/types.ts @@ -0,0 +1,7 @@ +import { AutomationTraceExtended } from "../../../../src/data/trace"; +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..a7124ab527 --- /dev/null +++ b/gallery/src/demos/demo-automation-trace.ts @@ -0,0 +1,64 @@ +import { + customElement, + html, + css, + LitElement, + TemplateResult, + property, +} from "lit-element"; +import "../../../src/components/ha-card"; +import "../../../src/components/trace/hat-trace-timeline"; +import { provideHass } from "../../../src/fake_data/provide_hass"; +import { HomeAssistant } from "../../../src/types"; +import { DemoTrace } from "../data/traces/types"; +import { basicTrace } from "../data/traces/basic_trace"; +import { motionLightTrace } from "../data/traces/motion-light-trace"; + +const traces: DemoTrace[] = [basicTrace, motionLightTrace]; + +@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); + const hass = provideHass(this); + hass.updateTranslations(null, "en"); + } + + 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. -

-
-