Added Z2M description to the Accessory name

This should help you better identify devices if you have added some
description in zigbee2mqtt.
This commit is contained in:
Darell Tan
2024-11-22 04:31:06 +08:00
parent 4d51380873
commit 1922f57a6f

9
z2m.go
View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"regexp"
"strings"
"reflect"
"runtime"
@@ -113,8 +114,13 @@ func createAccessory(dev *Device) (*accessory.A, []*ExposeMapping, error) {
}
// create accessory first, then see if any handler wants to modify it
accName := dev.Definition.Description
devDesc := strings.TrimSpace(dev.Description)
if len(devDesc) > 0 {
accName = devDesc + " " + accName
}
acc := accessory.New(accessory.Info{
Name: dev.Definition.Description,
Name: accName,
SerialNumber: serialNum,
Manufacturer: dev.Manufacturer,
Model: dev.Definition.Model,
@@ -285,6 +291,7 @@ type Device struct {
PowerSource string `json:"power_source,omitempty"`
SoftwareBuildId string `json:"software_build_id,omitempty"`
DateCode string `json:"date_code,omitempty"`
Description string `json:"description,omitempty"`
Definition *DevDefinition `json:"definition,omitempty"`