public string Build() { if (ObjectId == null) { throw new InvalidOperationException($"You must call {nameof(WithObjectId)} before building"); } var discoveryTopicComponentType = ComponentType.GetHomeAssistantDiscoveryMqttValue() ?? ComponentType.GetHomeAssistantMqttValue(); if (NodeId != null) { return($"{DiscoveryPrefix}/{discoveryTopicComponentType}/{NodeId}/{ObjectId}/config"); } else { return($"{DiscoveryPrefix}/{discoveryTopicComponentType}/{ObjectId}/config"); } }