Advice on MQTT configuration (e.g. setting Tasmota options)

Been a while, I’ve been running Openhab2 for ages, and Openhab3 side by side for a year or so now, but finally decided to upgrade to the latest 3.3 and move everything onto the one system - all is going well.

One issue I’ve been toying with is the configuration of MQTT devices. For example devices that need a one time setting (like setting Tasmota blinktime and blinkcount options to pulse a relay).

I was having issues trying to send several back to back MQTT transactions, maybe my script syntax is bad.

actions.get("mqtt","mqtt:broker:7217f8c3ca").publishMQTT("cmnd/bedroomfan/blinkcount", "1", true);
actions.get("mqtt","mqtt:broker:7217f8c3ca").publishMQTT("cmnd/bedroomfan/blinktime", "5", true);
actions.get("mqtt","mqtt:broker:7217f8c3ca").publishMQTT("cmnd/bedroomfan/POWER", "1", true);

Any thoughts?

Maybe try to use backlog instead.

1 Like

Hi,
I’m not sure, if your syntax is right.
I allways use e.g.:

val mqttActions = getActions(“mqtt”,“MQTTBroker”)
mqttActions.publishMQTT(“/path/to/topic”, “TESTED”)

Joerg

OK, thanks both - really helpful. I only started with Tasmota on Friday - migrating all of my home made automation away from Homie and putting the intelligence into Openhab scripts. Much easier to support moving forward.

So, my initial syntax was correct. Seems that the actions.get is in the default scope, which is super easy. Then using the Tasmota “backlog” makes this a doddle.

Cheers all, now working well.

// This is an example using the individal commands for a single pulse of the relay
//actions.get("mqtt", "mqtt:broker:7217f8c3ca").publishMQTT("cmnd/test1/blinkcount", "1");
//actions.get("mqtt", "mqtt:broker:7217f8c3ca").publishMQTT("cmnd/test1/blinktime", "5");
//actions.get("mqtt", "mqtt:broker:7217f8c3ca").publishMQTT("cmnd/test1/power1", "3");

// and this is the one using the backlog command
actions.get("mqtt", "mqtt:broker:7217f8c3ca").publishMQTT("cmnd/test1/backlog", "blinkcount 1; blinktime 5; power1 3");

2 Likes