Expose converter options (#9110)

* Expose converter options

* Updates
This commit is contained in:
Koen Kanters 2021-10-23 10:27:16 +02:00 committed by GitHub
parent 88314f1c6a
commit b665106d44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View File

@ -14,6 +14,10 @@ import Group from '../model/group';
const requestRegex = new RegExp(`${settings.get().mqtt.base_topic}/bridge/request/(.*)`);
type Scene = {id: number, name: string};
type DefinitionPayload = {
model: string, vendor: string, description: string, exposes: zhc.DefinitionExpose[], supports_ota:
boolean, icon: string, options: zhc.DefinitionExpose[],
};
export default class Bridge extends Extension {
private zigbee2mqttVersion: {commitHash: string, version: string};
@ -671,20 +675,21 @@ export default class Bridge extends Extension {
'bridge/groups', stringify(groups), {retain: true, qos: 0}, settings.get().mqtt.base_topic, true);
}
getDefinitionPayload(device: Device):
{model: string, vendor: string, description: string, exposes: unknown[], supports_ota: boolean, icon: string} {
getDefinitionPayload(device: Device): DefinitionPayload {
if (!device.definition) return null;
let icon = device.settings.icon ? device.settings.icon : device.definition.icon;
if (icon) {
icon = icon.replace('${zigbeeModel}', utils.sanitizeImageParameter(device.zh.modelID));
icon = icon.replace('${model}', utils.sanitizeImageParameter(device.definition.model));
}
return {
model: device.definition.model,
vendor: device.definition.vendor,
description: device.definition.description,
exposes: device.definition.exposes,
supports_ota: !!device.definition.ota,
options: device.definition.options,
icon,
};
}

View File

@ -112,6 +112,7 @@ declare global {
fromZigbee: FromZigbeeConverter[]
icon?: string
description: string
options: zhc.DefinitionExpose[],
vendor: string
exposes: DefinitionExpose[]
configure?: (device: zh.Device, coordinatorEndpoint: zh.Endpoint, logger: Logger) => Promise<void>;

File diff suppressed because one or more lines are too long