@@ -194,7 +194,7 @@ def init_bridge(self, from_transport : transport_base):
194194 self .__write_topics = {}
195195 #subscribe to write topics
196196 for entry in from_transport .protocolSettings .get_registry_map (Registry_Type .HOLDING ):
197- if entry .write_mode == WriteMode .WRITE :
197+ if entry .write_mode == WriteMode .WRITE or entry . write_mode == WriteMode . WRITEONLY :
198198 #__write_topics
199199 topic : str = self .base_topic + "/write/" + entry .variable_name .lower ().replace (' ' , '_' )
200200 self .__write_topics [topic ] = entry
@@ -230,6 +230,7 @@ def mqtt_discovery(self, from_transport : transport_base):
230230 if item .write_mode == WriteMode .READDISABLED : #disabled
231231 continue
232232
233+
233234 clean_name = item .variable_name .lower ().replace (' ' , '_' )
234235
235236 if False :
@@ -250,8 +251,8 @@ def mqtt_discovery(self, from_transport : transport_base):
250251 disc_payload ['unique_id' ] = "hotnoob_" + from_transport .device_serial_number + "_" + clean_name
251252
252253 writePrefix = ""
253- if from_transport .write_enabled and item .write_mode == WriteMode .WRITE :
254- writePrefix = "" #home assistant doesnt like write prefix
254+ if from_transport .write_enabled and ( item .write_mode == WriteMode .WRITE or item . write_mode == WriteMode . WRITEONLY ) :
255+ writePrefix = "" #home assistant doesnt like write prefix
255256
256257 disc_payload ['state_topic' ] = self .base_topic + '/' + from_transport .device_identifier + writePrefix + "/" + clean_name
257258
@@ -264,6 +265,10 @@ def mqtt_discovery(self, from_transport : transport_base):
264265 self .client .publish (discovery_topic ,
265266 json .dumps (disc_payload ),qos = 1 , retain = True )
266267
268+ #send WO message to indicate topic is write only
269+ if item .write_mode == WriteMode .WRITEONLY :
270+ self .client .publish (disc_payload ['state_topic' ], "WRITEONLY" )
271+
267272 time .sleep (0.07 ) #slow down for better reliability
268273
269274 self .client .publish (disc_payload ['availability_topic' ],"online" ,qos = 0 , retain = True )
0 commit comments