diff --git a/src/components/ha-chips.ts b/src/components/ha-chips.ts index df2fe418c219..15a7c7569b9a 100644 --- a/src/components/ha-chips.ts +++ b/src/components/ha-chips.ts @@ -55,6 +55,10 @@ export class HaChips extends LitElement { static get styles(): CSSResult { return css` ${unsafeCSS(chipStyles)} + .mdc-chip { + background-color: rgba(var(--rgb-primary-text-color), 0.15); + color: var(--primary-text-color); + } `; } } diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index 968f92af24ab..b6a3cbb6d616 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -264,7 +264,7 @@ export class HaAutomationEditor extends LitElement { } ); } - + console.log(changedProps); if (changedProps.has("creatingNew") && this.creatingNew && this.hass) { const initData = getAutomationEditorInitData(); this._dirty = initData ? true : false; diff --git a/src/panels/config/devices/device-detail/ha-device-automation-card.ts b/src/panels/config/devices/device-detail/ha-device-automation-card.ts index 1d512b68a655..c2ca072ab6c1 100644 --- a/src/panels/config/devices/device-detail/ha-device-automation-card.ts +++ b/src/panels/config/devices/device-detail/ha-device-automation-card.ts @@ -1,4 +1,11 @@ -import { LitElement, TemplateResult, html, property } from "lit-element"; +import { + LitElement, + TemplateResult, + html, + property, + CSSResult, + css, +} from "lit-element"; import { HomeAssistant } from "../../../../types"; import { DeviceAutomation } from "../../../../data/device_automation"; @@ -76,4 +83,12 @@ export abstract class HaDeviceAutomationCard< data[this.type] = [automation]; showAutomationEditor(this, data); } + + static get styles(): CSSResult { + return css` + h3 { + color: var(--primary-text-color); + } + `; + } } diff --git a/src/panels/config/devices/device-detail/ha-device-automation-dialog.ts b/src/panels/config/devices/device-detail/ha-device-automation-dialog.ts index d7409e3e4a3e..fee2977eee02 100644 --- a/src/panels/config/devices/device-detail/ha-device-automation-dialog.ts +++ b/src/panels/config/devices/device-detail/ha-device-automation-dialog.ts @@ -113,7 +113,9 @@ export class DialogDeviceAutomation extends LitElement { ` : ""} ` - : html``} + : this.hass.localize( + "ui.panel.config.devices.automation.no_device_automations" + )} Close @@ -126,54 +128,17 @@ export class DialogDeviceAutomation extends LitElement { this._params = undefined; } - static get styles(): CSSResult[] { - return [ - css` + static get styles(): CSSResult { + return css` + ha-dialog { + --mdc-dialog-title-ink-color: var(--primary-text-color); + } + @media only screen and (min-width: 600px) { ha-dialog { - --mdc-dialog-title-ink-color: var(--primary-text-color); - --justify-action-buttons: space-between; + --mdc-dialog-min-width: 600px; } - @media only screen and (min-width: 600px) { - ha-dialog { - --mdc-dialog-min-width: 600px; - } - } - .form { - padding-bottom: 24px; - } - .location { - display: flex; - } - .location > * { - flex-grow: 1; - min-width: 0; - } - .location > *:first-child { - margin-right: 4px; - } - .location > *:last-child { - margin-left: 4px; - } - ha-location-editor { - margin-top: 16px; - } - ha-user-picker { - margin-top: 16px; - } - mwc-button.warning { - --mdc-theme-primary: var(--google-red-500); - } - .error { - color: var(--google-red-500); - } - a { - color: var(--primary-color); - } - p { - color: var(--primary-text-color); - } - `, - ]; + } + `; } } diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts index c278250d9c29..ad89f24db077 100644 --- a/src/panels/config/devices/ha-config-device-page.ts +++ b/src/panels/config/devices/ha-config-device-page.ts @@ -41,6 +41,7 @@ import { RelatedResult, findRelated } from "../../../data/search"; import { SceneEntities, showSceneEditor } from "../../../data/scene"; import { navigate } from "../../../common/navigate"; import { showDeviceAutomationDialog } from "./device-detail/show-dialog-device-automation"; +import { isComponentLoaded } from "../../../common/config/is_component_loaded"; export interface EntityRegistryStateEntry extends EntityRegistryEntry { stateName?: string; @@ -152,144 +153,165 @@ export class HaConfigDevicePage extends LitElement {
- ${ - this._related?.automation?.length - ? this._related.automation.map((automation) => { - const state = this.hass.states[automation]; - return state - ? html` -
- - - ${state.attributes.friendly_name || - automation} - - - - ${!state.attributes.id - ? html` - ${this.hass.localize( - "ui.panel.config.devices.cant_edit" - )} - - ` - : ""} -
- ` - : ""; - }) - : html` - ${this.hass.localize( - "ui.panel.config.devices.automation.no_automations" - )} - ` - } -
- - ${this.hass.localize( - "ui.panel.config.devices.automation.create" - )} - -
-
+ ${ + isComponentLoaded(this.hass, "automation") + ? html` + ${this._related?.automation?.length + ? this._related.automation.map((automation) => { + const state = this.hass.states[automation]; + return state + ? html` +
+ + + ${state.attributes.friendly_name || + automation} + + + + ${!state.attributes.id + ? html` + ${this.hass.localize( + "ui.panel.config.devices.cant_edit" + )} + + ` + : ""} +
+ ` + : ""; + }) + : html` + ${this.hass.localize( + "ui.panel.config.devices.automation.no_automations" + )} + `} +
+ + ${this.hass.localize( + "ui.panel.config.devices.automation.create" + )} + +
+
+ ` + : "" + }
- ${ - this._related?.scene?.length - ? this._related.scene.map((scene) => { - const state = this.hass.states[scene]; - return state - ? html` -
- - - ${state.attributes.friendly_name || scene} - - - - ${!state.attributes.id - ? html` - ${this.hass.localize( - "ui.panel.config.devices.cant_edit" - )} - - ` - : ""} -
- ` - : ""; - }) - : html` - ${this.hass.localize( - "ui.panel.config.devices.scene.no_scenes" - )} - ` - } -
- - ${this.hass.localize( - "ui.panel.config.devices.scene.create" - )} -
-
- ${ - this._related?.script?.length - ? this._related.script.map((script) => { - const state = this.hass.states[script]; - return state - ? html` - ${this._related?.scene?.length + ? this._related.scene.map((scene) => { + const state = this.hass.states[scene]; + return state + ? html` +
+ + + ${state.attributes.friendly_name || + scene} + + + + ${!state.attributes.id + ? html` + ${this.hass.localize( + "ui.panel.config.devices.cant_edit" + )} + + ` + : ""} +
+ ` + : ""; + }) + : html` + ${this.hass.localize( + "ui.panel.config.devices.scene.no_scenes" + )} + `} + ${entities.length + ? html` +
+ + ${this.hass.localize( + "ui.panel.config.devices.scene.create" + )} + +
+ ` + : ""} +
+ ` + : "" + } + ${ + isComponentLoaded(this.hass, "script") + ? html` + ${this._related?.script?.length + ? this._related.script.map((script) => { + const state = this.hass.states[script]; + return state + ? html` + + + ${state.attributes.friendly_name || + script} + + + + ` + : ""; + }) + : html` + + ${this.hass.localize( + "ui.panel.config.devices.script.no_scripts" + )} - - ${state.attributes.friendly_name || script} - - - - ` - : ""; - }) - : html` - - ${this.hass.localize( - "ui.panel.config.devices.script.no_scripts" - )} - ` - } -
- - ${this.hass.localize("ui.panel.config.devices.script.create")} - -
-
+ `} +
+ + ${this.hass.localize( + "ui.panel.config.devices.script.create" + )} + +
+ + ` + : "" + }
diff --git a/src/panels/config/scene/ha-config-scene.ts b/src/panels/config/scene/ha-config-scene.ts index f086301b3e7a..ccc3521d7a99 100644 --- a/src/panels/config/scene/ha-config-scene.ts +++ b/src/panels/config/scene/ha-config-scene.ts @@ -50,6 +50,10 @@ class HaConfigScene extends HassRouterPage { }); }); + public disconnectedCallback() { + super.disconnectedCallback(); + } + protected updatePageEl(pageEl, changedProps: PropertyValues) { pageEl.hass = this.hass; pageEl.narrow = this.narrow; @@ -65,6 +69,7 @@ class HaConfigScene extends HassRouterPage { (!changedProps || changedProps.has("route")) && this._currentPage === "edit" ) { + pageEl.creatingNew = undefined; const sceneId = this.routeTail.path.substr(1); pageEl.creatingNew = sceneId === "new" ? true : false; pageEl.scene = diff --git a/src/panels/config/scene/ha-scene-editor.ts b/src/panels/config/scene/ha-scene-editor.ts index f63dce96b9c9..283195e62ac6 100644 --- a/src/panels/config/scene/ha-scene-editor.ts +++ b/src/panels/config/scene/ha-scene-editor.ts @@ -86,7 +86,7 @@ export class HaSceneEditor extends SubscribeMixin(LitElement) { @property() private _entityRegistryEntries: EntityRegistryEntry[] = []; private _storedStates: SceneEntities = {}; private _unsubscribeEvents?: () => void; - private _deviceEntityLookup: DeviceEntitiesLookup = {}; + @property() private _deviceEntityLookup: DeviceEntitiesLookup = {}; private _activateContextId?: string; private _getEntitiesDevices = memoizeOne( @@ -411,8 +411,8 @@ export class HaSceneEditor extends SubscribeMixin(LitElement) { entities: {}, ...initData, }; + this._initEntities(this._config); if (initData) { - this._initEntities(this._config); this._dirty = true; } } @@ -433,6 +433,12 @@ export class HaSceneEditor extends SubscribeMixin(LitElement) { ) { this._deviceEntityLookup[entity.device_id].push(entity.entity_id); } + if ( + this._entities.includes(entity.entity_id) && + !this._devices.includes(entity.device_id) + ) { + this._devices = [...this._devices, entity.device_id]; + } } } } diff --git a/src/translations/en.json b/src/translations/en.json index 6eaae9ff6127..74af9fff7e70 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1286,7 +1286,8 @@ }, "actions": { "caption": "When something is triggered..." - } + }, + "no_device_automations": "There are no automations available for this device." }, "script": { "scripts": "Scripts",