use {devicename}/{sensorname} for mqtt topics

pull/9/head^2
sleevezipper 4 years ago
parent 65edc8160e
commit 8ae6a8f233

@ -113,7 +113,7 @@ namespace hass_workstation_service.Communication
PropertyNameCaseInsensitive = true PropertyNameCaseInsensitive = true
}; };
var message = new MqttApplicationMessageBuilder() 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)) .WithPayload(clearConfig ? "" : JsonSerializer.Serialize(config, options))
.WithRetainFlag() .WithRetainFlag()
.Build(); .Build();

@ -16,7 +16,7 @@ namespace hass_workstation_service.Domain.Sensors
Name = this.Name, Name = this.Name,
Unique_id = this.Id.ToString(), Unique_id = this.Id.ToString(),
Device = this.Publisher.DeviceConfigModel, 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", Icon = "mdi:window-maximize",
}); });
} }

@ -21,7 +21,7 @@ namespace hass_workstation_service.Domain.Sensors
Name = this.Name, Name = this.Name,
Unique_id = this.Id.ToString(), Unique_id = this.Id.ToString(),
Device = this.Publisher.DeviceConfigModel, 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", Icon = "mdi:chart-areaspline",
Unit_of_measurement = "%" Unit_of_measurement = "%"
}); });

@ -16,7 +16,7 @@ namespace hass_workstation_service.Domain.Sensors
Name = this.Name, Name = this.Name,
Unique_id = this.Id.ToString(), Unique_id = this.Id.ToString(),
Device = this.Publisher.DeviceConfigModel, Device = this.Publisher.DeviceConfigModel,
State_topic = $"homeassistant/sensor/{this.Name}/state", State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state",
Icon = "mdi:speedometer", Icon = "mdi:speedometer",
Unit_of_measurement = "MHz" Unit_of_measurement = "MHz"
}); });

@ -20,7 +20,7 @@ namespace hass_workstation_service.Domain.Sensors
Name = this.Name, Name = this.Name,
Unique_id = this.Id.ToString(), Unique_id = this.Id.ToString(),
Device = this.Publisher.DeviceConfigModel, Device = this.Publisher.DeviceConfigModel,
State_topic = $"homeassistant/sensor/{this.Name}/state" State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state"
}); });
} }

@ -38,7 +38,7 @@ namespace hass_workstation_service.Domain.Sensors
Name = this.Name, Name = this.Name,
Unique_id = this.Id.ToString(), Unique_id = this.Id.ToString(),
Device = this.Publisher.DeviceConfigModel, Device = this.Publisher.DeviceConfigModel,
State_topic = $"homeassistant/sensor/{this.Name}/state", State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state",
Icon = "mdi:memory", Icon = "mdi:memory",
Unit_of_measurement = "%" Unit_of_measurement = "%"
}); });

@ -22,7 +22,7 @@ namespace hass_workstation_service.Domain.Sensors
Name = this.Name, Name = this.Name,
Unique_id = this.Id.ToString(), Unique_id = this.Id.ToString(),
Device = this.Publisher.DeviceConfigModel, Device = this.Publisher.DeviceConfigModel,
State_topic = $"homeassistant/sensor/{this.Name}/state", State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state",
Icon = "mdi:microphone", Icon = "mdi:microphone",
}); });
} }

@ -23,7 +23,7 @@ namespace hass_workstation_service.Domain.Sensors
Name = this.Name, Name = this.Name,
Unique_id = this.Id.ToString(), Unique_id = this.Id.ToString(),
Device = this.Publisher.DeviceConfigModel, 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", Icon = "mdi:window-maximize",
}); });
} }

@ -16,7 +16,7 @@ namespace hass_workstation_service.Domain.Sensors
Name = this.Name, Name = this.Name,
Unique_id = this.Id.ToString(), Unique_id = this.Id.ToString(),
Device = this.Publisher.DeviceConfigModel, Device = this.Publisher.DeviceConfigModel,
State_topic = $"homeassistant/sensor/{this.Name}/state", State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state",
Icon = "mdi:laptop", Icon = "mdi:laptop",
}); });
} }

@ -24,7 +24,7 @@ namespace hass_workstation_service.Domain.Sensors
Name = this.Name, Name = this.Name,
Unique_id = this.Id.ToString(), Unique_id = this.Id.ToString(),
Device = this.Publisher.DeviceConfigModel, Device = this.Publisher.DeviceConfigModel,
State_topic = $"homeassistant/sensor/{this.Name}/state", State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state",
}); });
} }

@ -38,7 +38,7 @@ namespace hass_workstation_service.Domain.Sensors
Name = this.Name, Name = this.Name,
Unique_id = this.Id.ToString(), Unique_id = this.Id.ToString(),
Device = this.Publisher.DeviceConfigModel, Device = this.Publisher.DeviceConfigModel,
State_topic = $"homeassistant/sensor/{this.Name}/state", State_topic = $"homeassistant/sensor/{Publisher.DeviceConfigModel.Name}/{this.Name}/state",
Icon = "mdi:webcam", Icon = "mdi:webcam",
}); });
} }

Loading…
Cancel
Save