From 8ae6a8f2337cfcc038990c06a7be73a6d017af2e Mon Sep 17 00:00:00 2001 From: sleevezipper Date: Thu, 7 Jan 2021 22:26:04 +0100 Subject: [PATCH] use {devicename}/{sensorname} for mqtt topics --- hass-workstation-service/Communication/MQTT/MqttPublisher.cs | 2 +- hass-workstation-service/Domain/Sensors/ActiveWindowSensor.cs | 2 +- hass-workstation-service/Domain/Sensors/CPULoadSensor.cs | 2 +- .../Domain/Sensors/CurrentClockSpeedSensor.cs | 2 +- hass-workstation-service/Domain/Sensors/DummySensor.cs | 2 +- hass-workstation-service/Domain/Sensors/MemoryUsageSensor.cs | 2 +- .../Domain/Sensors/MicrophoneActiveSensor.cs | 2 +- hass-workstation-service/Domain/Sensors/NamedWindowSensor.cs | 2 +- .../Domain/Sensors/UserNotificationStateSensor.cs | 2 +- hass-workstation-service/Domain/Sensors/WMIQuerySensor.cs | 2 +- hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hass-workstation-service/Communication/MQTT/MqttPublisher.cs b/hass-workstation-service/Communication/MQTT/MqttPublisher.cs index 163566c..c9f0bc8 100644 --- a/hass-workstation-service/Communication/MQTT/MqttPublisher.cs +++ b/hass-workstation-service/Communication/MQTT/MqttPublisher.cs @@ -113,7 +113,7 @@ namespace hass_workstation_service.Communication PropertyNameCaseInsensitive = true }; var message = new MqttApplicationMessageBuilder() - .WithTopic($"homeassistant/sensor/{config.Name}/config") + .WithTopic($"homeassistant/sensor/{this.DeviceConfigModel.Name}/{config.Name}/config") .WithPayload(clearConfig ? "" : JsonSerializer.Serialize(config, options)) .WithRetainFlag() .Build(); diff --git a/hass-workstation-service/Domain/Sensors/ActiveWindowSensor.cs b/hass-workstation-service/Domain/Sensors/ActiveWindowSensor.cs index 1f13278..d431f14 100644 --- a/hass-workstation-service/Domain/Sensors/ActiveWindowSensor.cs +++ b/hass-workstation-service/Domain/Sensors/ActiveWindowSensor.cs @@ -16,7 +16,7 @@ namespace hass_workstation_service.Domain.Sensors Name = this.Name, Unique_id = this.Id.ToString(), Device = this.Publisher.DeviceConfigModel, - State_topic = $"homeassistant/sensor/{this.Name}/state", + State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state", Icon = "mdi:window-maximize", }); } diff --git a/hass-workstation-service/Domain/Sensors/CPULoadSensor.cs b/hass-workstation-service/Domain/Sensors/CPULoadSensor.cs index 2b8b31e..fbbb9f4 100644 --- a/hass-workstation-service/Domain/Sensors/CPULoadSensor.cs +++ b/hass-workstation-service/Domain/Sensors/CPULoadSensor.cs @@ -21,7 +21,7 @@ namespace hass_workstation_service.Domain.Sensors Name = this.Name, Unique_id = this.Id.ToString(), Device = this.Publisher.DeviceConfigModel, - State_topic = $"homeassistant/sensor/{this.Name}/state", + State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state", Icon = "mdi:chart-areaspline", Unit_of_measurement = "%" }); diff --git a/hass-workstation-service/Domain/Sensors/CurrentClockSpeedSensor.cs b/hass-workstation-service/Domain/Sensors/CurrentClockSpeedSensor.cs index d1ced62..921a96d 100644 --- a/hass-workstation-service/Domain/Sensors/CurrentClockSpeedSensor.cs +++ b/hass-workstation-service/Domain/Sensors/CurrentClockSpeedSensor.cs @@ -16,7 +16,7 @@ namespace hass_workstation_service.Domain.Sensors Name = this.Name, Unique_id = this.Id.ToString(), Device = this.Publisher.DeviceConfigModel, - State_topic = $"homeassistant/sensor/{this.Name}/state", + State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state", Icon = "mdi:speedometer", Unit_of_measurement = "MHz" }); diff --git a/hass-workstation-service/Domain/Sensors/DummySensor.cs b/hass-workstation-service/Domain/Sensors/DummySensor.cs index b887338..5960104 100644 --- a/hass-workstation-service/Domain/Sensors/DummySensor.cs +++ b/hass-workstation-service/Domain/Sensors/DummySensor.cs @@ -20,7 +20,7 @@ namespace hass_workstation_service.Domain.Sensors Name = this.Name, Unique_id = this.Id.ToString(), Device = this.Publisher.DeviceConfigModel, - State_topic = $"homeassistant/sensor/{this.Name}/state" + State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state" }); } diff --git a/hass-workstation-service/Domain/Sensors/MemoryUsageSensor.cs b/hass-workstation-service/Domain/Sensors/MemoryUsageSensor.cs index 75ebf38..78fce3d 100644 --- a/hass-workstation-service/Domain/Sensors/MemoryUsageSensor.cs +++ b/hass-workstation-service/Domain/Sensors/MemoryUsageSensor.cs @@ -38,7 +38,7 @@ namespace hass_workstation_service.Domain.Sensors Name = this.Name, Unique_id = this.Id.ToString(), Device = this.Publisher.DeviceConfigModel, - State_topic = $"homeassistant/sensor/{this.Name}/state", + State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state", Icon = "mdi:memory", Unit_of_measurement = "%" }); diff --git a/hass-workstation-service/Domain/Sensors/MicrophoneActiveSensor.cs b/hass-workstation-service/Domain/Sensors/MicrophoneActiveSensor.cs index 8c9fa92..8e04aa6 100644 --- a/hass-workstation-service/Domain/Sensors/MicrophoneActiveSensor.cs +++ b/hass-workstation-service/Domain/Sensors/MicrophoneActiveSensor.cs @@ -22,7 +22,7 @@ namespace hass_workstation_service.Domain.Sensors Name = this.Name, Unique_id = this.Id.ToString(), Device = this.Publisher.DeviceConfigModel, - State_topic = $"homeassistant/sensor/{this.Name}/state", + State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state", Icon = "mdi:microphone", }); } diff --git a/hass-workstation-service/Domain/Sensors/NamedWindowSensor.cs b/hass-workstation-service/Domain/Sensors/NamedWindowSensor.cs index fe6c620..7cf7989 100644 --- a/hass-workstation-service/Domain/Sensors/NamedWindowSensor.cs +++ b/hass-workstation-service/Domain/Sensors/NamedWindowSensor.cs @@ -23,7 +23,7 @@ namespace hass_workstation_service.Domain.Sensors Name = this.Name, Unique_id = this.Id.ToString(), Device = this.Publisher.DeviceConfigModel, - State_topic = $"homeassistant/sensor/{this.Name}/state", + State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state", Icon = "mdi:window-maximize", }); } diff --git a/hass-workstation-service/Domain/Sensors/UserNotificationStateSensor.cs b/hass-workstation-service/Domain/Sensors/UserNotificationStateSensor.cs index 25f0252..e98e1d9 100644 --- a/hass-workstation-service/Domain/Sensors/UserNotificationStateSensor.cs +++ b/hass-workstation-service/Domain/Sensors/UserNotificationStateSensor.cs @@ -16,7 +16,7 @@ namespace hass_workstation_service.Domain.Sensors Name = this.Name, Unique_id = this.Id.ToString(), Device = this.Publisher.DeviceConfigModel, - State_topic = $"homeassistant/sensor/{this.Name}/state", + State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state", Icon = "mdi:laptop", }); } diff --git a/hass-workstation-service/Domain/Sensors/WMIQuerySensor.cs b/hass-workstation-service/Domain/Sensors/WMIQuerySensor.cs index 0e9204d..bf5002e 100644 --- a/hass-workstation-service/Domain/Sensors/WMIQuerySensor.cs +++ b/hass-workstation-service/Domain/Sensors/WMIQuerySensor.cs @@ -24,7 +24,7 @@ namespace hass_workstation_service.Domain.Sensors Name = this.Name, Unique_id = this.Id.ToString(), Device = this.Publisher.DeviceConfigModel, - State_topic = $"homeassistant/sensor/{this.Name}/state", + State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state", }); } diff --git a/hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs b/hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs index 65829d0..d3323a0 100644 --- a/hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs +++ b/hass-workstation-service/Domain/Sensors/WebcamActiveSensor.cs @@ -38,7 +38,7 @@ namespace hass_workstation_service.Domain.Sensors Name = this.Name, Unique_id = this.Id.ToString(), Device = this.Publisher.DeviceConfigModel, - State_topic = $"homeassistant/sensor/{this.Name}/state", + State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state", Icon = "mdi:webcam", }); }