diff --git a/package.json b/package.json index a88f82772b..a1e74fceef 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,9 @@ "author": "Paulus Schoutsen (http://paulusschoutsen.nl)", "license": "Apache-2.0", "dependencies": { - "@material/mwc-button": "^0.5.0", - "@material/mwc-ripple": "^0.5.0", + "@material/mwc-base": "^0.6.0", + "@material/mwc-button": "^0.6.0", + "@material/mwc-ripple": "^0.6.0", "@mdi/svg": "3.5.95", "@polymer/app-layout": "^3.0.2", "@polymer/app-localize-behavior": "^3.0.1", @@ -77,13 +78,13 @@ "fuse.js": "^3.4.4", "google-timezones-json": "^1.0.2", "hls.js": "^0.12.4", - "home-assistant-js-websocket": "^4.2.1", + "home-assistant-js-websocket": "^4.2.2", "intl-messageformat": "^2.2.0", "jquery": "^3.3.1", "js-yaml": "^3.13.0", "leaflet": "^1.4.0", - "lit-element": "^2.1.0", - "lit-html": "^1.0.0", + "lit-element": "^2.2.0", + "lit-html": "^1.1.0", "marked": "^0.6.1", "mdn-polyfills": "^5.16.0", "memoize-one": "^5.0.2", @@ -169,7 +170,7 @@ "workbox-webpack-plugin": "^4.1.1" }, "resolutions": { - "@webcomponents/webcomponentsjs": "^2.2.7", + "@webcomponents/webcomponentsjs": "^2.2.10", "@vaadin/vaadin-lumo-styles": "^1.4.2" }, "main": "src/home-assistant.js", diff --git a/setup.py b/setup.py index c3d29c54d3..893e62b35c 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20190604.0", + version="20190614.0", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", diff --git a/src/components/ha-toast.ts b/src/components/ha-toast.ts index 488a152967..9c57c0fd75 100644 --- a/src/components/ha-toast.ts +++ b/src/components/ha-toast.ts @@ -4,6 +4,9 @@ import "@polymer/paper-toast/paper-toast"; const PaperToast = customElements.get("paper-toast"); export class HaToast extends PaperToast { + private _resizeListener?: (obj: { matches: boolean }) => unknown; + private _mediaq?: MediaQueryList; + public connectedCallback() { super.connectedCallback(); @@ -12,13 +15,13 @@ export class HaToast extends PaperToast { this.classList.toggle("fit-bottom", ev.matches); this._mediaq = window.matchMedia("(max-width: 599px"); } - this._mediaq.addListener(this._resizeListener); - this._resizeListener(this._mediaq); + this._mediaq!.addListener(this._resizeListener); + this._resizeListener(this._mediaq!); } public disconnectedCallback() { super.disconnectedCallback(); - this._mediaq.removeListener(this._resizeListener); + this._mediaq!.removeListener(this._resizeListener!); } } diff --git a/src/data/alexa.ts b/src/data/alexa.ts new file mode 100644 index 0000000000..e3f154c558 --- /dev/null +++ b/src/data/alexa.ts @@ -0,0 +1,10 @@ +import { HomeAssistant } from "../types"; + +export interface AlexaEntity { + entity_id: string; + display_categories: string[]; + interfaces: string[]; +} + +export const fetchCloudAlexaEntities = (hass: HomeAssistant) => + hass.callWS({ type: "cloud/alexa/entities" }); diff --git a/src/data/cloud.ts b/src/data/cloud.ts index 5135867376..0755aafcc7 100644 --- a/src/data/cloud.ts +++ b/src/data/cloud.ts @@ -13,6 +13,10 @@ export interface GoogleEntityConfig { disable_2fa?: boolean; } +export interface AlexaEntityConfig { + should_expose?: boolean; +} + export interface CertificateInformation { common_name: string; expire_date: string; @@ -28,6 +32,10 @@ export interface CloudPreferences { google_entity_configs: { [entityId: string]: GoogleEntityConfig; }; + alexa_entity_configs: { + [entityId: string]: AlexaEntityConfig; + }; + alexa_report_state: boolean; } export type CloudStatusLoggedIn = CloudStatusBase & { @@ -35,7 +43,6 @@ export type CloudStatusLoggedIn = CloudStatusBase & { google_entities: EntityFilter; google_domains: string[]; alexa_entities: EntityFilter; - alexa_domains: string[]; prefs: CloudPreferences; remote_domain: string | undefined; remote_connected: boolean; @@ -55,12 +62,6 @@ export interface CloudWebhook { managed?: boolean; } -export interface GoogleEntity { - entity_id: string; - traits: string[]; - might_2fa: boolean; -} - export const fetchCloudStatus = (hass: HomeAssistant) => hass.callWS({ type: "cloud/status" }); @@ -94,6 +95,7 @@ export const updateCloudPref = ( prefs: { google_enabled?: CloudPreferences["google_enabled"]; alexa_enabled?: CloudPreferences["alexa_enabled"]; + alexa_report_state?: CloudPreferences["alexa_report_state"]; google_secure_devices_pin?: CloudPreferences["google_secure_devices_pin"]; } ) => @@ -102,9 +104,6 @@ export const updateCloudPref = ( ...prefs, }); -export const fetchCloudGoogleEntities = (hass: HomeAssistant) => - hass.callWS({ type: "cloud/google_assistant/entities" }); - export const updateCloudGoogleEntityConfig = ( hass: HomeAssistant, entityId: string, @@ -118,3 +117,14 @@ export const updateCloudGoogleEntityConfig = ( export const cloudSyncGoogleAssistant = (hass: HomeAssistant) => hass.callApi("POST", "cloud/google_actions/sync"); + +export const updateCloudAlexaEntityConfig = ( + hass: HomeAssistant, + entityId: string, + values: AlexaEntityConfig +) => + hass.callWS({ + type: "cloud/alexa/entities/update", + entity_id: entityId, + ...values, + }); diff --git a/src/data/device_registry.ts b/src/data/device_registry.ts index e137ef8ff9..873d6f9c9c 100644 --- a/src/data/device_registry.ts +++ b/src/data/device_registry.ts @@ -10,7 +10,7 @@ export interface DeviceRegistryEntry { model?: string; name?: string; sw_version?: string; - hub_device_id?: string; + via_device_id?: string; area_id?: string; name_by_user?: string; } diff --git a/src/data/google_assistant.ts b/src/data/google_assistant.ts new file mode 100644 index 0000000000..982f3c456a --- /dev/null +++ b/src/data/google_assistant.ts @@ -0,0 +1,10 @@ +import { HomeAssistant } from "../types"; + +export interface GoogleEntity { + entity_id: string; + traits: string[]; + might_2fa: boolean; +} + +export const fetchCloudGoogleEntities = (hass: HomeAssistant) => + hass.callWS({ type: "cloud/google_assistant/entities" }); diff --git a/src/data/lovelace.ts b/src/data/lovelace.ts index 32bebb98ff..246dadb038 100644 --- a/src/data/lovelace.ts +++ b/src/data/lovelace.ts @@ -61,10 +61,10 @@ export type ActionConfig = | NoActionConfig; export const fetchConfig = ( - hass: HomeAssistant, + conn: Connection, force: boolean ): Promise => - hass.callWS({ + conn.sendMessagePromise({ type: "lovelace/config", force, }); @@ -82,3 +82,7 @@ export const subscribeLovelaceUpdates = ( conn: Connection, onChange: () => void ) => conn.subscribeEvents(onChange, "lovelace_updated"); + +export interface WindowWithLovelaceProm extends Window { + llConfProm?: Promise; +} diff --git a/src/dialogs/config-flow/step-flow-external.ts b/src/dialogs/config-flow/step-flow-external.ts index 39ece5dc29..2dca5b5921 100644 --- a/src/dialogs/config-flow/step-flow-external.ts +++ b/src/dialogs/config-flow/step-flow-external.ts @@ -75,8 +75,9 @@ class StepFlowExternal extends LitElement { return; } - const step = await fetchConfigFlow(this.hass, this.step.flow_id); - fireEvent(this, "flow-update", { step }); + fireEvent(this, "flow-update", { + stepPromise: fetchConfigFlow(this.hass, this.step.flow_id), + }); }, "data_entry_flow_progressed" ); diff --git a/src/entrypoints/core.ts b/src/entrypoints/core.ts index 17f2794167..bc515431c9 100644 --- a/src/entrypoints/core.ts +++ b/src/entrypoints/core.ts @@ -15,6 +15,7 @@ import { subscribeThemes } from "../data/ws-themes"; import { subscribeUser } from "../data/ws-user"; import { HomeAssistant } from "../types"; import { hassUrl } from "../data/auth"; +import { fetchConfig, WindowWithLovelaceProm } from "../data/lovelace"; declare global { interface Window { @@ -61,6 +62,9 @@ const connProm = async (auth) => { } }; +if (__DEV__) { + performance.mark("hass-start"); +} window.hassConnection = authProm().then(connProm); // Start fetching some of the data that we will need. @@ -74,6 +78,10 @@ window.hassConnection.then(({ conn }) => { subscribePanels(conn, noop); subscribeThemes(conn, noop); subscribeUser(conn, noop); + + if (location.pathname === "/" || location.pathname.startsWith("/lovelace/")) { + (window as WindowWithLovelaceProm).llConfProm = fetchConfig(conn, false); + } }); window.addEventListener("error", (e) => { diff --git a/src/html/authorize.html.template b/src/html/authorize.html.template index 7adeebd2cc..6833ede06e 100644 --- a/src/html/authorize.html.template +++ b/src/html/authorize.html.template @@ -2,7 +2,7 @@ Home Assistant - + -