Skip to content

Commit

Permalink
Add backported get_topic_lwt
Browse files Browse the repository at this point in the history
  • Loading branch information
ejohb committed Sep 17, 2023
1 parent 053fa37 commit fc01830
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion module/hct_entity.be
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import hct_logger as logger
var Config=hct_config.Config

var TOPIC=tools_be.mqtt.get_topic()
var TOPIC_LWT=tools_be.mqtt.get_topic_lwt()
var TOPIC_LWT=tools.get_topic_lwt()
var MAC=tools_be.network.get_mac()
var MAC_SHORT=tools_be.network.get_mac_short()
var MAC_LAST_SIX=tools_be.network.get_mac_last_six()
Expand Down
20 changes: 16 additions & 4 deletions module/hct_tools.be
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,31 @@ def update_hct(url)
return tools_be.update.update_tapp_github_asset(url, constants.ORG, constants.NAME, constants.ASSET_FILENAME, constants.PATH_MODULE)
end

def get_topic_lwt()

import string

var topic_mask=tasmota.cmd('FullTopic')['FullTopic']
var prefix=tasmota.cmd('prefix')['Prefix3']

var topic=topic_mask
topic=string.replace(topic,'%topic%',tools_be.mqtt.get_topic())
topic=string.replace(topic,'%prefix%',prefix)

return string.format('%sLWT',topic)

end

var mod = module("hct_tools")

mod.tools_be=tools_be

mod.to_bool=tools_be.converter.to_bool
mod.from_bool=tools_be.converter.from_bool

mod.sanitize_name=sanitize_name

mod.add_rule_once=add_rule_once


mod.update_hct=update_hct
mod.get_topic_lwt=get_topic_lwt


mod.get_random=tools_be.random.get_random
Expand Down

0 comments on commit fc01830

Please sign in to comment.