From d2177ca0040e8d4fa99e5730f62ef8dc612b2fa2 Mon Sep 17 00:00:00 2001 From: awilliams <645192+awilliams@users.noreply.github.com> Date: Sat, 21 Oct 2023 21:31:16 -0600 Subject: [PATCH] Reformat entity name to not include device name --- internal/hass/messages.go | 1 + internal/hass/mqtt.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/hass/messages.go b/internal/hass/messages.go index 7020ecd..bf11747 100644 --- a/internal/hass/messages.go +++ b/internal/hass/messages.go @@ -23,6 +23,7 @@ type DeviceTracker struct { Device Device `json:"device,omitempty"` // Information about the device this device tracker is a part of that ties it into the device registry. At least one of identifiers or connections must be present to identify the device. Icon string `json:"icon,omitempty"` // Icon for the entity. https://materialdesignicons.com JSONAttributesTopic string `json:"json_attributes_topic,omitempty"` // The MQTT topic subscribed to receive a JSON dictionary payload and then set as device_tracker attributes. Usage example can be found in MQTT sensor documentation. + Name string `json:"name,omitempty"` // The name of the MQTT device_tracker. ObjectID string `json:"object_id,omitempty"` // Used instead of name for automatic generation of entity_id. PayloadAvailable string `json:"payload_available,omitempty"` // Default: online. The payload that represents the available state. PayloadHome string `json:"payload_home,omitempty"` // Default: home. The payload value that represents the ‘home’ state for the device. diff --git a/internal/hass/mqtt.go b/internal/hass/mqtt.go index b55a1d4..5966120 100644 --- a/internal/hass/mqtt.go +++ b/internal/hass/mqtt.go @@ -186,6 +186,7 @@ func (m *MQTT) RegisterDeviceTracker(ctx context.Context, dsc Discovery) error { }, Icon: icon, JSONAttributesTopic: m.topics.DeviceJSONAttrs(dsc.MAC), + Name: fmt.Sprintf("%s %s", dsc.MAC, m.apName), // This cannot start with 'dsc.Name' ObjectID: deviceID, PayloadAvailable: StatusOnline, PayloadNotAvailable: StatusOffline,