@@ -194,7 +194,7 @@ def init_bridge(self, from_transport : transport_base):
194
194
self .__write_topics = {}
195
195
#subscribe to write topics
196
196
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 :
198
198
#__write_topics
199
199
topic : str = self .base_topic + "/write/" + entry .variable_name .lower ().replace (' ' , '_' )
200
200
self .__write_topics [topic ] = entry
@@ -230,6 +230,7 @@ def mqtt_discovery(self, from_transport : transport_base):
230
230
if item .write_mode == WriteMode .READDISABLED : #disabled
231
231
continue
232
232
233
+
233
234
clean_name = item .variable_name .lower ().replace (' ' , '_' )
234
235
235
236
if False :
@@ -250,8 +251,8 @@ def mqtt_discovery(self, from_transport : transport_base):
250
251
disc_payload ['unique_id' ] = "hotnoob_" + from_transport .device_serial_number + "_" + clean_name
251
252
252
253
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
255
256
256
257
disc_payload ['state_topic' ] = self .base_topic + '/' + from_transport .device_identifier + writePrefix + "/" + clean_name
257
258
@@ -264,6 +265,10 @@ def mqtt_discovery(self, from_transport : transport_base):
264
265
self .client .publish (discovery_topic ,
265
266
json .dumps (disc_payload ),qos = 1 , retain = True )
266
267
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
+
267
272
time .sleep (0.07 ) #slow down for better reliability
268
273
269
274
self .client .publish (disc_payload ['availability_topic' ],"online" ,qos = 0 , retain = True )
0 commit comments