diff --git a/src/panels/config/devices/device-detail/integration-elements/ozw/ha-device-actions-ozw.ts b/src/panels/config/devices/device-detail/integration-elements/ozw/ha-device-actions-ozw.ts new file mode 100644 index 0000000000..7f0cac03f2 --- /dev/null +++ b/src/panels/config/devices/device-detail/integration-elements/ozw/ha-device-actions-ozw.ts @@ -0,0 +1,88 @@ +import { + CSSResult, + customElement, + html, + LitElement, + property, + TemplateResult, + css, + PropertyValues, +} from "lit-element"; +import { DeviceRegistryEntry } from "../../../../../../data/device_registry"; +import { haStyle } from "../../../../../../resources/styles"; +import { HomeAssistant } from "../../../../../../types"; +import { + getIdentifiersFromDevice, + OZWNodeIdentifiers, +} from "../../../../../../data/ozw"; +import { showOZWRefreshNodeDialog } from "../../../../integrations/integration-panels/ozw/show-dialog-ozw-refresh-node"; +import { navigate } from "../../../../../../common/navigate"; +import "@material/mwc-button/mwc-button"; + +@customElement("ha-device-actions-ozw") +export class HaDeviceActionsOzw extends LitElement { + @property({ attribute: false }) public hass!: HomeAssistant; + + @property() public device!: DeviceRegistryEntry; + + @property() + private node_id = 0; + + @property() + private ozw_instance = 1; + + + protected updated(changedProperties: PropertyValues) { + if (changedProperties.has("device")) { + const identifiers: + | OZWNodeIdentifiers + | undefined = getIdentifiersFromDevice(this.device); + if (!identifiers) { + return; + } + this.ozw_instance = identifiers.ozw_instance; + this.node_id = identifiers.node_id; + } + } + + protected render(): TemplateResult { + if (!this.ozw_instance || !this.node_id) { + return html``; + } + return html` + + ${this.hass.localize("ui.panel.config.ozw.node.button")} + + + ${this.hass.localize("ui.panel.config.ozw.refresh_node.button")} + + `; + } + + private async _refreshNodeClicked() { + showOZWRefreshNodeDialog(this, { + node_id: this.node_id, + ozw_instance: this.ozw_instance, + }); + } + + private async _nodeDetailsClicked() { + navigate( + this, + `/config/ozw/network/${this.ozw_instance}/node/${this.node_id}/dashboard` + ); + } + + static get styles(): CSSResult[] { + return [ + haStyle, + css` + :host { + display: flex; + flex-direction: column; + align-items: flex-start; + } + `, + ]; + } +} diff --git a/src/panels/config/devices/device-detail/integration-elements/ozw/ha-device-info-ozw.ts b/src/panels/config/devices/device-detail/integration-elements/ozw/ha-device-info-ozw.ts index 2197fe689b..ce639c75b8 100644 --- a/src/panels/config/devices/device-detail/integration-elements/ozw/ha-device-info-ozw.ts +++ b/src/panels/config/devices/device-detail/integration-elements/ozw/ha-device-info-ozw.ts @@ -18,7 +18,6 @@ import { getIdentifiersFromDevice, OZWNodeIdentifiers, } from "../../../../../../data/ozw"; -import { showOZWRefreshNodeDialog } from "../../../../integrations/integration-panels/ozw/show-dialog-ozw-refresh-node"; @customElement("ha-device-info-ozw") export class HaDeviceInfoOzw extends LitElement { @@ -83,19 +82,9 @@ export class HaDeviceInfoOzw extends LitElement { ? this.hass.localize("ui.common.yes") : this.hass.localize("ui.common.no")} - - Refresh Node - `; } - private async _refreshNodeClicked() { - showOZWRefreshNodeDialog(this, { - node_id: this.node_id, - ozw_instance: this.ozw_instance, - }); - } - static get styles(): CSSResult[] { return [ haStyle, diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts index 0287b084cd..22c2ea190a 100644 --- a/src/panels/config/devices/ha-config-device-page.ts +++ b/src/panels/config/devices/ha-config-device-page.ts @@ -517,12 +517,19 @@ export class HaConfigDevicePage extends LitElement { `); } if (integrations.includes("ozw")) { + import("./device-detail/integration-elements/ozw/ha-device-actions-ozw"); import("./device-detail/integration-elements/ozw/ha-device-info-ozw"); templates.push(html` +
+ +
`); } if (integrations.includes("zha")) { diff --git a/src/translations/en.json b/src/translations/en.json index 775859bb11..9977bae247 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1764,6 +1764,7 @@ "complete": "Interview process is complete" }, "refresh_node": { + "button": "Refresh Node", "title": "Refresh Node Information", "complete": "Node Refresh Complete", "description": "This will tell OpenZWave to re-interview a node and update the node's command classes, capabilities, and values.", @@ -1818,6 +1819,7 @@ "failed": "Failed" }, "node": { + "button": "Node Details", "not_found": "Node not found" }, "services": {