Add option "Treat topic as hostname"

This commit is contained in:
Theo Arends 2025-09-07 16:02:28 +02:00
parent 46fa6cabe1
commit ede11b1795

View File

@ -17,6 +17,7 @@ class mqttdata_cls
var line_highlight # Highlight latest change duration var line_highlight # Highlight latest change duration
var line_highlight_color # Highlight color var line_highlight_color # Highlight color
var line_duration # Duration option var line_duration # Duration option
var line_topic_is_hostname # Treat topic as hostname
var list_buffer # Buffer storing lines var list_buffer # Buffer storing lines
def init() def init()
@ -27,6 +28,7 @@ class mqttdata_cls
self.line_highlight = 10 # Highlight latest change duration in seconds self.line_highlight = 10 # Highlight latest change duration in seconds
self.line_highlight_color = "yellow" # Highlight HTML color like "#FFFF00" or "yellow" self.line_highlight_color = "yellow" # Highlight HTML color like "#FFFF00" or "yellow"
self.line_duration = 0 # Show duration of last state message (1) self.line_duration = 0 # Show duration of last state message (1)
self.line_topic_is_hostname = 0 # Treat topic as hostname (1)
self.list_buffer = [] # Init line buffer list self.list_buffer = [] # Init line buffer list
@ -149,9 +151,14 @@ class mqttdata_cls
if ipaddress if ipaddress
msg += format("<td><a target=_blank href='http://%s.'>%s</a></td><td><a target=_blank href='http://%s'>%s</a></td>", msg += format("<td><a target=_blank href='http://%s.'>%s</a></td><td><a target=_blank href='http://%s'>%s</a></td>",
topic, topic, ipaddress, ipaddress) topic, topic, ipaddress, ipaddress)
else
if self.line_topic_is_hostname
msg += format("<td><a target=_blank href='http://%s.'>%s</a></td><td>&nbsp</td>",
topic, topic)
else else
msg += format("<td>%s</td><td>&nbsp</td>", topic) msg += format("<td>%s</td><td>&nbsp</td>", topic)
end end
end
if last_seen >= (now - self.line_highlight) # Highlight changes within latest seconds if last_seen >= (now - self.line_highlight) # Highlight changes within latest seconds
msg += format("<td align='right' style='color:%s'>%s</td>", self.line_highlight_color, uptime) msg += format("<td align='right' style='color:%s'>%s</td>", self.line_highlight_color, uptime)