mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 03:36:44 +00:00
Add node details shortcut to OZW device pages (#6791)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
2adeb88fe6
commit
fcc22ba560
@ -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`
|
||||
<mwc-button @click=${this._nodeDetailsClicked}>
|
||||
${this.hass.localize("ui.panel.config.ozw.node.button")}
|
||||
</mwc-button>
|
||||
<mwc-button @click=${this._refreshNodeClicked}>
|
||||
${this.hass.localize("ui.panel.config.ozw.refresh_node.button")}
|
||||
</mwc-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;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
}
|
@ -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")}
|
||||
</div>
|
||||
<mwc-button @click=${this._refreshNodeClicked}>
|
||||
Refresh Node
|
||||
</mwc-button>
|
||||
`;
|
||||
}
|
||||
|
||||
private async _refreshNodeClicked() {
|
||||
showOZWRefreshNodeDialog(this, {
|
||||
node_id: this.node_id,
|
||||
ozw_instance: this.ozw_instance,
|
||||
});
|
||||
}
|
||||
|
||||
static get styles(): CSSResult[] {
|
||||
return [
|
||||
haStyle,
|
||||
|
@ -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`
|
||||
<ha-device-info-ozw
|
||||
.hass=${this.hass}
|
||||
.device=${device}
|
||||
></ha-device-info-ozw>
|
||||
<div class="card-actions" slot="actions">
|
||||
<ha-device-actions-ozw
|
||||
.hass=${this.hass}
|
||||
.device=${device}
|
||||
></ha-device-actions-ozw>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
if (integrations.includes("zha")) {
|
||||
|
@ -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": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user