Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
}
`,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions src/panels/config/devices/ha-config-device-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
2 changes: 2 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,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.",
Expand Down Expand Up @@ -1813,6 +1814,7 @@
"failed": "Failed"
},
"node": {
"button": "Node Details",
"not_found": "Node not found"
},
"services": {
Expand Down