Configuring Openhab for tasmota things

Hi, I’m new to home automation, been trying to decide to go either Home assistant or Openhab. I am about to build a house and want to make it smart! I like the idea of getting out of the cloud ( internet is not really reliable in the country the phone line is strung up between trees ). I have converted some lights to Tasmota but I am stuck trying to find good documentation on configuration of Broker, Things, Channels and items as there is ambiguity in a lot of cases. I’m using what I think is stock standard Mosquitto 2.4, visual Studio code, Raspberry PI 3B+. Does any body know of a walk through of what to do.
Thanks in advance
Russell

Are you configuring via files or PaperUI?

Hi. I am trying by files

Great, I’m better at that!

Have a look through this link, and let me know if it helps:

In short:

  1. Connect the Tasmota device to your wifi network.
  2. Correctly setup the MQTT settings on the Tasmota device.
  3. Define an MQTT broker in a things file pointing to your Mosquitto broker.
  4. Add the Tasmota device to the MQTT broker via a things file (or the same things file)
  5. Connect items to the channels defined in step 4.
  6. Add the items to your sitemap, or into rules, or whatever else you want to do with him.

I can help with these steps if you get stuck!

Thanks hafniumzinc,
First of several questions in Things state topic you use tasmota/sonoff-ps01/POWER and for command topic tasmota/sonoff-ps01/cmnd/POWER.
I tried home assistant as I was getting nowhere and no hair.

Im using mqtt.fx and when I alter the setting I get homeassistant/sensor/32C77C_status/config sometimes as when I uninstalled home assistant it didn’t remove all it’s files but the normal is stat/Brilliant/state and

{“Time”:“2020-06-09T14:23:18”,“Uptime”:“0T02:27:08”,“UptimeSec”:8828,“Heap”:27,“SleepMode”:“Dynamic”,“Sleep”:10,“LoadAvg”:99,“MqttCount”:2,“POWER”:“ON”,“Dimmer”:40,“Color”:“102,0,0,0”,“HSBColor”:“0,100,40”,“White”:0,“Channel”:[40,0,0,0],“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“ON”,“Wifi”:{“AP”:1,“SSId”:“vickery”,“BSSId”:“3C:37:86:98:72:D9”,“Channel”:7,“RSSI”:50,“Signal”:-75,“LinkCount”:3,“Downtime”:“0T00:00:30”}}

what should the statements be ( not worrying about the home assistant bit)

I don’t use those state or command topics in the link I provided - where did you get those from?

Can you take a screenshot of the MQTT parameters page from Tasmota, and paste it into a reply. We can go from there. It should look something like below:

You mention HomeAssistant quite a few times - you’re in an OpenHAB forum, right?

Sorry I went to the wrong Tab you are right. Everything has just been getting confused:-)

Yes I am back using Openhab but Home assistant didn’t cleanly uninstall even though it was on the Raspberry Pi and I am using a new micro sd , it may be something to do with visual studio code.

OK, so your thing file could look something like this:

Bridge mqtt:broker:MosquittoMqttBroker "Mosquitto MQTT Broker" [host="192.168.0.20", secure=false]
{
	// Switch Light
	Thing mqtt:topic:Brilliant "Light switch" {
		Channels:
			Type switch : switch "Power Switch" [ 
				stateTopic="stat/Brilliant/POWER", 
				commandTopic="cmnd/Brilliant/POWER",
				on="ON",
				off="OFF"          
			]
	}
}

then an items file could include:

Switch sBrilliantSwitch "Brilliant Light Switch"  { channel="mqtt:topic:Brilliant:switch" }

and the sitemap could include:

Switch item=sBrilliantSwitch label="Brilliant Light" icon="light"

That covers the basic on/off for the light. I notice the MQTT payload includes dimmer and colour - is this a lightbulb? This link may also be useful, as it includes an example channel setup for the colour and dimmer:

EDIT: Also, make sure you have the MQTT binding installed (not v1), and the JSONPath transformation (for the dimmer and colour stuff). You can do this via the PaperUI.

  • PaperUI -> Add-ons -> Bindings -> MQTT Binding -> Install
  • PaperUI -> Add-ons -> Transformations -> JSONPath Transformation -> Install

Hi What I have is a color light
My Thing is

Bridge mqtt:broker:MosquittoMqttBroker “Mosquitto MQTT Broker” [
host=“192.168.0.20”,
secure=false,
]
Thing mqtt:topic:Brilliant “Light” {
Channels:
Type switch : switch “Power Switch” [
stateTopic=“stat/Brilliant/POWER”,
commandTopic=“cmnd/Brilliant/POWER”,
on=“ON”,
off=“OFF”
]
Type string : reachable “Reachable” [
stateTopic = “tele/Brilliant/LWT”
]
}
}

I have now done the items and sitemap but the sitemap does not display. Just has welcome

Assuming you’re putting all these files in the correct folders, with the correct extensions, then I suspect it’s the sitemap file itself which as gone wrong.

Start a new sitemap file, and try with this code:

sitemap our_home label="Our Home" {
	Frame label="Lights"{
		Switch item=sBrilliantSwitch label="Brilliant Light" icon="light"
	}
}

Save the file as our_home.sitemap

It should then popup under the “Welcome” in the BasicUI.

I now have Things:-
Bridge mqtt:broker:MosquittoMqttBroker “Mosquitto MQTT Broker” [

host=“192.168.0.20”,

secure=false,

]

Thing mqtt:topic:Brilliant “Light” {

Channels:

  Type switch : POWER "Light Power On/OFF" [ 

    stateTopic="stat/Brilliant/POWER", 

    commandTopic="cmnd/Brilliant/POWER",

    1="ON", 

    0="OFF"          

  ]

  Type string : reachable "Reachable" [

    stateTopic = "tele/Brilliant/LWT"

  ] 

  Type dimmer:dimmer "Dimmer" [

    stateTopic="stat/Brilliant/RESULT",

    commandTopic="cmnd/Brilliant/DIMMER",

    transformationPattern="JSONPATH:$.Dimmer"

  ]

  Type colorHSB:color "Colour" [

    stateTopic="stat/Brilliant/RESULT",

    commandTopic="cmnd/Brilliant/HSBColor",

    transformationPattern="JSONPATH:$.HSBColor"

  ]

  Type switch:state "State" [

    stateTopic="tele/Brilliant/STATE",

    transformationPattern="JSONPATH:$.POWER",

    1="ON",

    0="OFF"

  ]         

}

}

And Items:-
Switch sBrilliantswitch “Brilliant LED Light” (gLights, gIndoorLights, gUpstairsLights) {channel=“mqtt:topic:Brilliant:power”}

Dimmer dBrilliantswitch “Brilliant LED Light” {channel=“mqtt:topic:Brilliant:dimmer”}

Color cBrilliantswitch “Brilliant LED Light” {channel=“mqtt:topic:Brilliant:color”}

and Sitemaps:-
sitemap our_home label=“Our Home” {

Frame label="Lights"{

    Switch item=sBrilliantswitch label="Brilliant Light" icon="light"

    Colorpicker item=cBrilliantswitch label="RGB strip colour"

}

}

alter power or color and nothing happens but if changed in MQtt.fx publish cmnd/Brilliant/HSBcolor lamp changes color, or cmnd/Brilliant/POWER 0 or 1 turns the globe off or on.

This stuff is case sensitive; POWER/power

I have gone through all the code checked and changed any wrong case words but still nothing from openhab being picked up by MQTT.fx to mosquitto but able to pickup commands from Tasmota published to it. Any suggestions?

Look in your events.log to make sure commands are being received by the Item(s) that you expect.
Look in your openhab.log to make sure you established a broker connection.

As @rossko57 says, check that your broker connection works. In addition to looking at the logs, you can also use the PaperUI.

Go to Configuration -> Things and scroll down until you find the MQTT broker. It will look very similar to mine:

image

If it says “ONLINE” then at least that bit is working. If it doesn’t you need to double check the broker settings in the things file, including whether you need authentication or not (dependent upon how you setup the Mosquitto broker).

Yes the MQTT Broker is online. Checked using Frontail that the items changed values, no mention if the data was published.

To check if your Mosquitto broker is receiving commands, subscribe to the Brilliant topic using mosquitto_sub in a terminal.

On the same machine that is running Mosquitto (or another if you have the relevant packages installed), try the following command and watch when you try to switch or dim from OpenHAB:

mosquitto_sub -d -t +/Brilliant/#

I have a switch called swPorchLight, so subscribing to that topic and switching the openHAB power switch on and off shows the following:

pi@raspberrypi:~ $ mosquitto_sub -d -t +/swPorchLight/#
Client mosqsub/12211-raspberry sending CONNECT
Client mosqsub/12211-raspberry received CONNACK
Client mosqsub/12211-raspberry sending SUBSCRIBE (Mid: 1, Topic: +/swPorchLight/#, QoS: 0)
Client mosqsub/12211-raspberry received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/12211-raspberry received PUBLISH (d0, q0, r1, m0, 'tele/swPorchLight/LWT', ... (6 bytes))
Online
Client mosqsub/12211-raspberry received PUBLISH (d0, q0, r0, m0, 'cmnd/swPorchLight/POWER', ... (2 bytes))
ON
Client mosqsub/12211-raspberry received PUBLISH (d0, q0, r0, m0, 'stat/swPorchLight/RESULT', ... (14 bytes))
{"POWER":"ON"}
Client mosqsub/12211-raspberry received PUBLISH (d0, q0, r0, m0, 'stat/swPorchLight/POWER', ... (2 bytes))
ON
Client mosqsub/12211-raspberry received PUBLISH (d0, q0, r0, m0, 'cmnd/swPorchLight/POWER', ... (3 bytes))
OFF
Client mosqsub/12211-raspberry received PUBLISH (d0, q0, r0, m0, 'stat/swPorchLight/RESULT', ... (15 bytes))
{"POWER":"OFF"}
Client mosqsub/12211-raspberry received PUBLISH (d0, q0, r0, m0, 'stat/swPorchLight/POWER', ... (3 bytes))
OFF

EDIT: Doh, you’re already using MQTT.fx, which I guess does the same thing.

in terminal I am seeing :-
Client mosqsub|28925-openhab sending PINGREQ
Client mosqsub|28925-openhab received PINGRESP
and so mosquitto is communicating OK .
In frontail I can see sitemap initiating the item, but the item does not seem to initiate the things. the code in item is
Switch sBrilliantswitch “Brilliant LED Light” (gLights, gIndoorLights, gUpstairsLights) {channel=“mqtt:topic:Brilliant:POWER”}
and in Thing
Type switch : POWER “Light Power On/OFF” [
stateTopic=“stat/Brilliant/POWER”,
commandTopic=“cmnd/Brilliant/POWER”,
on =“ON”,
off =“OFF”

what is the “link” between items and things?