Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add connection identifiers to device-config #946

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
24 changes: 24 additions & 0 deletions docs/node/device-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,27 @@ The software version of the device
- Type: `string`

The hardware version of the device

### MAC Address

- Type: `string`

The network MAC address of the device

### Bluetooth Identifier

- Type: `string`

The Bluetooth identifier of the device

### UPnP Identifier

- Type: `string`

The UPnP identifier of the device

### Zigbee Identifier

- Type: `string`

The Zigbee identifier of the device
6 changes: 5 additions & 1 deletion locales/en-US/device-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"manufacturer": "Manufacturer",
"model": "Model",
"hw_version": "Hardware Version",
"sw_version": "Software Version"
"sw_version": "Software Version",
"macIdentifier": "MAC address",
"bluetoothIdentifier": "Bleutooth Identifier",
"upnpIdentifier": "UPnP Identifier",
"zigbeeIdentifier": "Zigbee Identifier"
}
}
}
15 changes: 15 additions & 0 deletions src/common/integration/UnidirectionalEntityIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface DeviceInfo {
manufacturer?: string;
model?: string;
sw_version?: string;
connections?: Array<Array<string>>;
}

export interface DiscoveryMessage extends MessageBase {
Expand Down Expand Up @@ -138,6 +139,19 @@ export default class UnidirectionalIntegration extends Integration {
}

const config = this.deviceConfigNode.config;
const deviceConnections = [];
if (config.macIdentifier) {
deviceConnections.push(['mac', config.macIdentifier]);
}
if (config.bluetoothIdentifier) {
deviceConnections.push(['bluetooth', config.bluetoothIdentifier]);
}
if (config.upnpIdentifier) {
deviceConnections.push(['upnp', config.upnpIdentifier]);
}
if (config.zigbeeIdentiefier) {
deviceConnections.push(['zigbee', config.zigbeeIdentiefier]);
}

return {
id: config.id,
Expand All @@ -146,6 +160,7 @@ export default class UnidirectionalIntegration extends Integration {
manufacturer: config.manufacturer,
model: config.model,
sw_version: config.swVersion,
connections: deviceConnections,
};
}

Expand Down
32 changes: 32 additions & 0 deletions src/nodes/device-config/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,35 @@
></label>
<input type="text" id="node-config-input-hwVersion" />
</div>

<div class="form-row">
<label
for="node-config-input-macIdentifier"
data-i18n="ha-device-config.label.macIdentifier"
></label>
<input type="text" id="node-config-input-macIdentifier" />
</div>

<div class="form-row">
<label
for="node-config-input-bluetoothIdentifier"
data-i18n="ha-device-config.label.bluetoothIdentifier"
></label>
<input type="text" id="node-config-input-bluetoothIdentifier" />
</div>

<div class="form-row">
<label
for="node-config-input-upnpIdentifier"
data-i18n="ha-device-config.label.upnpIdentifier"
></label>
<input type="text" id="node-config-input-upnpIdentifier" />
</div>

<div class="form-row">
<label
for="node-config-input-zigbeeIdentifier"
data-i18n="ha-device-config.label.zigbeeIdentifier"
></label>
<input type="text" id="node-config-input-zigbeeIdentifier" />
</div>
8 changes: 8 additions & 0 deletions src/nodes/device-config/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export interface DeviceConfigEditorNodeProperties extends EditorNodeProperties {
manufacturer: string;
model: string;
swVersion: string;
macIdentifier: string;
bluetoothIdentifier: string;
upnpIdentifier: string;
zigbeeIdentiefier: string;
}

const DeviceConfigEditor: EditorNodeDef<DeviceConfigEditorNodeProperties> = {
Expand All @@ -21,6 +25,10 @@ const DeviceConfigEditor: EditorNodeDef<DeviceConfigEditorNodeProperties> = {
manufacturer: { value: 'Node-RED', required: false },
model: { value: '', required: false },
swVersion: { value: '', required: false },
macIdentifier: { value: '', required: false },
bluetoothIdentifier: { value: '', required: false },
upnpIdentifier: { value: '', required: false },
zigbeeIdentiefier: { value: '', required: false },
},
icon: 'font-awesome/fa-device',
label: function (): string {
Expand Down
4 changes: 4 additions & 0 deletions src/nodes/device-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export interface DeviceConfigNodeProperties extends BaseNodeProperties {
manufacturer?: string;
model?: string;
swVersion?: string;
macIdentifier?: string;
bluetoothIdentifier?: string;
upnpIdentifier?: string;
zigbeeIdentiefier?: string;
}

export interface DeviceConfigNode extends BaseNode {
Expand Down