How-to delete a mqtt topic?

  • Platform information:
    • openHAB version: 3.4.0
  • Issue of the topic: in a JS rule, I would like to delete a MQTT topic

Hello,

in my JS rules, I can easily add topics thanks to mqttActions.publishMQTT
but in order to customize a AWtrix custom app, I need to delete its topic to make it disapear

This is the code to make it UP:

    val mqttActions = getActions("mqtt","mqtt:broker:openhab2MQTTbroker")
	mqttActions.publishMQTT("awtrix_1234/custom/amusic","{\"text\":\""+myMusic+"\", \"icon\":\"44966\"}", true)

I’m not able to find members of Actions. Do we only have publishMQTT ?
If so, is it possible to use it to delete a topic ?

Thanks for your help

A topic only exists on MQTT if it’s currently holding a retained message. To remove a retained message, publish an empty retained message.

MQTT topics don’t exist independently of the messages. When I client connects, only those topics that have retained messages will exist until a new message is published after it connects. And then it really only exists for that instant when the message is published.

1 Like