@@ -170,13 +170,13 @@ def write_data(self, data : dict[str, str], from_transport : transport_base):
170170 if (self .json ):
171171 # Serializing json
172172 json_object = json .dumps (data , indent = 4 )
173- self .client .publish (self .base_topic + from_transport .device_identifier , json_object , 0 , properties = self .mqtt_properties )
173+ self .client .publish (self .base_topic + '/' + from_transport .device_identifier , json_object , 0 , properties = self .mqtt_properties )
174174 else :
175175 for entry , val in data .items ():
176176 if isinstance (val , float ) and self .max_precision >= 0 : #apply max_precision on mqtt transport
177177 val = round (val , self .max_precision )
178178
179- self .client .publish (str (self .base_topic + from_transport .device_identifier + '/' + entry ).lower (), str (val ))
179+ self .client .publish (str (self .base_topic + '/' + from_transport .device_identifier + '/' + entry ).lower (), str (val ))
180180
181181 def client_on_message (self , client , userdata , msg ):
182182 """ The callback for when a PUBLISH message is received from the server. """
@@ -253,7 +253,7 @@ def mqtt_discovery(self, from_transport : transport_base):
253253 if from_transport .write_enabled and item .write_mode == WriteMode .WRITE :
254254 writePrefix = "" #home assistant doesnt like write prefix
255255
256- disc_payload ['state_topic' ] = self .base_topic + from_transport .device_identifier + writePrefix + "/" + clean_name
256+ disc_payload ['state_topic' ] = self .base_topic + '/' + from_transport .device_identifier + writePrefix + "/" + clean_name
257257
258258 if item .unit :
259259 disc_payload ['unit_of_measurement' ] = item .unit
0 commit comments