OpenHAB3 MQTT Configuration with Text Files on Windows 10

Thanks. I implemented

    val apples = getActions("mqtt","mqtt:systemBroker:some-mqtt-broker")
   .apples.publishMQTT("Some/Topic", "SomePayload")

in both rules and the OH3 errors. OH3 does not like the decimal before apples.
Is the getActions a time hog? I trigger the 2nd rule every 10 seconds.

I checked the addons.cfg' file. No UI is listed #ui = but I still get the message. When I fired the system up for the 1st time I did haveclassic` listed. Does OH3 remember (persist) despite numerous computer reboots since then?

I tried the

myString.postUpdate("my message string.....")

method before receiving your message and learned the hard way it doesn’t work.

I also tried

mqttActions.publishMQTT("Some/Topic", myString.state)
and 
mqttActions.publishMQTT("Some/Topic", myString.state.toString)
and
and mqttActions.publishMQTT("Some/Topic", myString.state.toString, "true" )

and both fail. And I don’t understand what the true retention does?

Do you see what I overlooked?

It’s a typo. I’m sure you worked that out really.

There is a “working copy” tucked away somewhere as filename addons.config ,note the extension.
Have a look in there for classic.
If that’s the source, the best bet is to simply delete it so that it gets recreated fresh at next boot.

In what way? Does the rule even run?

This is an MQTT feature, a potential property of every message you send to a broker.

That example is Rules DSL In Rules DSL, ‘val’ denotes a ‘final’, variable that doesn’t change after it’s defined. ‘val’ is correct in this context.

It’s been years since using MQTT1 but if that’s how it used to work it was wrong.

Beyond that, what rosdko57 said.

$OH_USERDATA/config/org/openhab

Again, many thanks to the Community.

OH3 mqtt is now working. For the benefit of others that might follow down my torturous path due to my lack of knowledge I’m going to herein summarize my findings:

  • The addons.config file that spawned nuisance log errors is located in the \user\config\org\openhab folder. I blew it and a copy of it away and the error log is now clean :slight_smile:

  • mqtt does NOT send packets identical to mqtt1. mqtt1 installs a preface (the topic with an = sign behind it) at the beginning of the string packet. This might? have something to do with publish on postUpdate with mqtt1 and publish on sendCommand with mqtt. IE,

OHOB_WM_String.postUpdate(OHOB_String)
vs
mqttActions.publishMQTT("/WatchMan/OHOB_WM_String", OHOB_WM_String.state.toString)
  • Here are my text configuration files:
    OH3.things
	Bridge mqtt:broker:hsbroker "hsbroker" [ host="10.0.0.9", secure=false ] {
 
		Thing topic WatchManThing "From WatchMan" 
		{
			Channels:
			Type string: HS5150ToWM			"OpenHAB to Arduino"	    [commandTopic="/WatchMan/OHOB_WM_String"]	// OpenHAB Send  to Arduino
			Type string: WMReplyToHS5150	"OHC_MsgStamp"              [stateTopic="/OHIB/OHM/MsgStamp"]           // Arduino Reply to OpenHAB
			
			Type string: WMC10				"OHC_Carport_Front"         [stateTopic="/OHIB/OHC/10"]
			Type string: WMC11				"OHC_Carport_Rear"          [stateTopic="/OHIB/OHC/11"]
			Type string: WMC12				"OHC_Driveway_South"        [stateTopic="/OHIB/OHC/12"]
			Type string: WMC13				"OHC_Driveway_Center"       [stateTopic="/OHIB/OHC/13"]
			Type string: WMC14				"OHC_Driveway_North"        [stateTopic="/OHIB/OHC/14"]
			Type string: WMC15				"OHC_Front_Entry"           [stateTopic="/OHIB/OHC/15"]
			Type string: WMC16				"OHC_Backyard_HT"           [stateTopic="/OHIB/OHC/16"]
			Type string: WMC17				"OHC_Northside_Front"       [stateTopic="/OHIB/OHC/17"]
			Type string: WMC18				"OHC_Northside_Rear"        [stateTopic="/OHIB/OHC/18"]
			Type string: WMC05				"OHC_Backyard_FR"           [stateTopic="/OHIB/OHC/05"]
			Type string: WMC08				"OHC_Backyard_BR"           [stateTopic="/OHIB/OHC/08"]
			Type string: WMC07				"OHC_NVR_Activity"          [stateTopic="/OHIB/OHC/07"]
etc.
etc.
}
}
  • And
    OH3 .items
String OHOB_WM_String    "Outbound String[%s]"{channel="mqtt:topic:hsbroker:WatchManThing:HS5150ToWM"}	// From OpenHAB to Arduino
Number OHC_MsgStamp      "Health Status Stamp [%d]"(gControl) {channel="mqtt:topic:hsbroker:WatchManThing:WMReplyToHS5150"}

Number OHC_Carport_Front            "Carport Front [%d]"        (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC10"}
Number OHC_Carport_Rear             "Carport Rear [%d]"         (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC11"}
Number OHC_Driveway_South           "Driveway South [%d]"       (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC12"}
Number OHC_Driveway_Center          "Driveway Mid   [%d]"       (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC13"}
Number OHC_Driveway_North           "Driveway North [%d]"       (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC14"}
Number OHC_Front_Entry              "Front Steps [%d]"          (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC15"}
Number OHC_Backyard_HT              "Backyard HT [%d]"          (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC16"}
Number OHC_Northside_Front          "North Front [%d]"          (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC17"}
Number OHC_Northside_Rear           "North Rear [%d]"           (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC18"}
Number OHC_Backyard_FR              "Backyard FR [%d]"          (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC05"}
Number OHC_Backyard_BR              "Backyard BR [%d]"          (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC08"}
Number OHC_NVR_Activity             "Cameras [%d]"              (gControl)                      {channel="mqtt:topic:hsbroker:WatchManThing:WMC07"}
  • And
    OH3 .rules
In my initializations rule that is triggered by `System start`

var mqttActions = getActions("mqtt","mqtt:broker:hsbroker")
mqttActions.publishMQTT("CommandTopic", "SomePayload")

and in my publication rule that is trigger by cron

var	mqttActions = getActions("mqtt","mqtt:broker:hsbroker")
mqttActions.publishMQTT("/WatchMan/OHOB_WM_String", OHOB_WM_String.state.toString)

With 20/20 hindsight this is all extremely simple :slight_smile:

Before this thread is closed as SOLVED I’ll give the community an opportunity to make losing comments.

And I have 2 questions:
1 - I agree per above that the rule trigger System started is now implemented as it should be, on system start, not configuration file updates. Is there a back door method to trigger a rule when configuration files are updated/saved? I find that .things file saves are particularly troublesome, and I have had OH3 hang upon .rules and .sitemap file saves :frowning: -

2 - If I was to put the openhab-addons-3.0.1 file into the addons folder should it be named openhab-addons-3.0.1 or openhab-addons ? With documentation lacking these subtleties drive me crazy :frowning:

1 Like

As I mentioned above, you can manually run your System started rules from MainUI or the Karaf console when you reload the file it is define in.

I can’t help with 2. I suspect that the way the jar file is named when you download it is the way openHAB expects it to be named in the addons folder.

How do I close this thread as SOLVED

By checking a post as the Solution, which appears to have already been done.