4 item switches don't work seperately. Wrong Item/Thing configuration

I have a plug “Gosund P1” flashed with Tasmota 8.2.0 with 4 sockets.
I try to turn on and off every socket individually with a one of the 4 switches I defined in the BasicUI.

It works perfectly via the Tasmota console. So the plug configuration is fine, but it doesn’t work from my BasicUI because whatever Switch Item I turn on. Always all four turn on or off at the same time in the BasicUI.
On the hardware plug itself always the choosen socket plus always socket 1 turn on/off.
Where is my coding mistake here?

mqtt.things

Bridge mqtt:broker:mosquitto "MQTTBroker"  [ host="localhost", port=1883, secure=false, username="***", password="*****", clientID="openHAB2", keepAlive="60" ]
{
Thing topic plug_tasmota_19 "Plug Tasmota 19 - Gosund P1 PM 3-fach Steckdosenleiste mit 3 USB" @ "MQTT" {
        Channels:
	    Type switch : powerswitch1    	"Steckdose 1 (links)" 			[ stateTopic="stat/plug/tasmota/19/POWER1", commandTopic="cmnd/plug/tasmota/19/POWER1", on="ON", off="OFF" ]
		Type switch : powerswitch2    	"Steckdose 2 (mitte)" 			[ stateTopic="stat/plug/tasmota/19/POWER2", commandTopic="cmnd/plug/tasmota/19/POWER2", on="ON", off="OFF" ]
		Type switch : powerswitch3    	"Steckdose 3 (rechts)" 			[ stateTopic="stat/plug/tasmota/19/POWER3", commandTopic="cmnd/plug/tasmota/19/POWER3", on="ON", off="OFF" ]
		Type switch : powerswitch4    	"Steckdose 4 (USB)" 			[ stateTopic="stat/plug/tasmota/19/POWER4", commandTopic="cmnd/plug/tasmota/19/POWER4", on="ON", off="OFF" ]
    } 	   
}

plugs.items

Group  gPlugT19					"T19" <settings> 							(gPlugs)
Switch PlugT19_Switch1 		    "Steckdose 1 (links)" 	        			(gPlugT19)					{ channel="mqtt:topic:mosquitto:plug_tasmota_19:powerswitch1" }
Switch PlugT19_Switch2 		    "Steckdose 2 (mitte)" 	        			(gPlugT19)					{ channel="mqtt:topic:mosquitto:plug_tasmota_19:powerswitch2" }
Switch PlugT19_Switch3 		    "Steckdose 3 (rechts)" 	        			(gPlugT19)					{ channel="mqtt:topic:mosquitto:plug_tasmota_19:powerswitch3" }
Switch PlugT19_Switch4 		    "Steckdose 4 (USB)" 	        			(gPlugT19)					{ channel="mqtt:topic:mosquitto:plug_tasmota_19:powerswitch4" }

default.sitemap

sitemap default label="Smarthome Control Default"
{
  Group   item=gPlugT19
}

You’ve added the group to your sitemap, but not the individual switches. So when you toggle it, the group is sending commands to all four at once. That is the expected behaviour.

You have five items in your items file, so you would need all five of them in your sitemap if you want to control the group and the individual switches.

I don’t think this is correct. The group item shows me all the switches and the should all work by themself.
Anyway I did try what you suggested:

Group item=gPlugT19 {
	Switch item=PlugT19_Switch1 
	Switch item=PlugT19_Switch2
	Switch item=PlugT19_Switch3
	Switch item=PlugT19_Switch4
}

But this gives the same error. I think the problem is somewhere else.

Use a tool like mqtt.fx to satisfy yourself that openHAB is publishing to different topics.

No. As described in my first post I only get two topics. Always Socket 1 and then the one I choose.

This is what happens when I press Switch3:

21:16:00 MQT: stat/plug/tasmota/19/RESULT = {"POWER1":"ON"}
21:16:00 MQT: stat/plug/tasmota/19/POWER1 = ON
21:16:00 MQT: stat/plug/tasmota/19/RESULT = {"POWER3":"ON"}
21:16:00 MQT: stat/plug/tasmota/19/POWER3 = ON

Yes, that’s your tasmota reporting what it has done.

What did openHAB send to it on a cmnd/ topic ?

(I think your tasmota is set up incorrectly, but let’s prove it instead of guessing.)

Yeah sorry, I read your sitemap incorrectly as I was confused by “Always all four turn on or off at the same time in the BasicUI.” your first post. I was thinking you were using the group item as a single switch, in which case it made sense that all four turn on/off at once in BasicUI.

So just to make sure we’re on the same page, when you toggle Switch3 in BasicUI to ON, all four of the switches change to ON. However, on the actual device, only POWER1 and POWER3 turn on. Is that correct?

This is absolut correct!

This is my first tasmota switch which is using rules in the configuration.
But it works all right if I give the following statement in teh Tasmota console:

cmnd/plug/tasmota/19/POWER3 ON

Then only socket 3 turns on.

In my mqqt spy I receive only the result topics. I don’t receive anything listing to the cmd topic. But the switch is working:

When I publish the command in the mqqt spy I can also get it in the subscription:

So maybe my mqqt configuration is wrong in openhab for this plug?
I posted it in the first post in my Thing file.

Are you really using rule(s) for this tasmota device? If yes, please post them!

1 Like

And show us your events.log for an attempted switching

Something gets sent to your tasmota, you see stuff happening. You ought to find out what, as it is not on the topic you were expecting.

I put this rules in the tasmota console:

Rule1 ON Button1#State DO Power4 2 ENDON
Rule1 1
Rule2 ON Analog#range<22 DO Power3 2 BREAK ON Analog#range<46 DO Power2 2 BREAK ON Analog#range<73 DO Power1 2 ENDON
Backlog Rule1 1; Rule2 5

Here is what happens when I use the console with the commands Rule, Rule1, Rule2, Backlog:

13:32:33 CMD: Rule
13:32:33 MQT: stat/plug/tasmota/19/RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":477,"Rules":"ON Button1#State DO Power4 2 ENDON"}
13:32:47 CMD: Rule1
13:32:47 MQT: stat/plug/tasmota/19/RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":477,"Rules":"ON Button1#State DO Power4 2 ENDON"}
13:32:50 CMD: Rule2
13:32:50 MQT: stat/plug/tasmota/19/RESULT = {"Rule2":"ON","Once":"ON","StopOnError":"OFF","Free":401,"Rules":"ON Analog#range<22 DO Power3 2 BREAK ON Analog#range<46 DO Power2 2 BREAK ON Analog#range<73 DO Power1 2 ENDON"}
13:34:38 CMD: Backlog
13:34:38 MQT: stat/plug/tasmota/19/RESULT = {"Backlog":"Empty"}

This happend in the event.log when I change PlugT19_Switch3 in the BasicUI from OFF to ON:

2020-05-03 13:37:17.112 [ome.event.ItemCommandEvent] - Item 'PlugT19_Switch3' received command ON
2020-05-03 13:37:17.132 [nt.ItemStatePredictedEvent] - PlugT19_Switch3 predicted to become ON
2020-05-03 13:37:17.143 [vent.ItemStateChangedEvent] - PlugT19_Switch3 changed from OFF to ON
2020-05-03 13:37:17.224 [vent.ItemStateChangedEvent] - PlugT19_Switch2 changed from OFF to ON
2020-05-03 13:37:17.225 [vent.ItemStateChangedEvent] - PlugT19_Switch1 changed from OFF to ON
2020-05-03 13:37:17.225 [vent.ItemStateChangedEvent] - PlugT19_Switch4 changed from OFF to ON

In the BasicUI also all 4 switches Turn ON? It should only turn switch 3 ON.

In the Tasmota Console it looks like this:

13:37:16 MQT: stat/plug/tasmota/19/RESULT = {"POWER1":"ON"}
13:37:16 MQT: stat/plug/tasmota/19/POWER1 = ON
13:37:16 MQT: stat/plug/tasmota/19/RESULT = {"POWER3":"ON"}
13:37:16 MQT: stat/plug/tasmota/19/POWER3 = ON

The device turns socket 1 and socket 3 to ON.
It should only turn socket 3 to ON.

Okay, openHAB will try to publish one message for that.
From your Things, that should be to topic cmnd/plug/tasmota/19/POWER3 with a payload ON

You say you cannot see that in mqqt spy
But we know that something is published, because the tasmota reacts.
Either
openHAB publishes to a different topic - use mqtt.spy to find out.
Or
openHAB publishes to a different broker than the one you are looking at.

I think this the first mystery I would try to solve.
Once you know what arrives at the tasmota, you can begin to wok out why it doesn’t do what you expect. Can’t you see incoming topics/payloads on the tasmota console?

Reference the rules, your statement sounded as if you would be using openHAB rules. You do not do that and IMHO your tasmota rules do not relate to the observed problem.

Regarding the messages on the tasmota console you see ( and don’t see) when switching via BasicUI, are you using only mqtt commands? When switching via a http command, I do see only the MQTT stat message!

Okay I did try again and got the cmd this time.
I pressed only PlugT19_Switch3 to ON and received:

So the plug behaves correct to turn socket 1 and 3 to ON because there are actually 2 cmds.
So there is an error in my Thing or Item configuration which I didn’t change since my first post here.

I have no openhab rules regarding the Item PlugT19_Switch3

Check that you have not defined Things in both PaperUI and xxx.things files.

Assuming you’ve only created your Things in files, and you have checked that you do not have two files with near-duplicate Thing definitions - reinitialise the binding so that it is not using older edited versions of your Things. (reboot openhab if you do not know how to do that). Bindings can sometimes not fully pick up edits of Things until a restart.

Ours of your and my time and the only thing needed was a restart. Maybe from reasons Rossko57 was mentioning. There is and was only one Thing file but it seems the binding didn’t get the changed correctly.

After a restart everything is working. :frowning: :confounded:

1 Like