Migrating MQTT1 items to MQTT2.4 items

Tags: #<Tag:0x00007f01484a9cf0>

(Sascha Billian) #41

Please post your complete item definition.

(4KAUTO) #42


Group  GF_Sonoff_RF                "RF Bridge"                                <sonoff_rf>    (Sonoff_RF)
Switch GF_Sonoff_RF_Button_1 “Button 1” <none> (GF_Sonoff_RF) { channel=“mqtt:topic:9770d4aa:sonoff:button1”, autoupdate=“false”}


Switch GF_Sonoff_RF_Button_1 "Button 1" <none> (GF_Sonoff_RF) { channel="mqtt:topic:9770d4aa:sonoff:button1", autoupdate="false"}


2019-01-04 22:28:33.904 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Group
2019-01-04 22:28:33.904 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'GF_Sonoff_RF' for widget org.eclipse.smarthome.model.sitemap.Group
2019-01-04 22:28:33.912 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'GF_Sonoff_RF' for widget org.eclipse.smarthome.model.sitemap.Group
2019-01-04 22:28:33.912 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'GF_Sonoff_RF' for widget org.eclipse.smarthome.model.sitemap.Group
2019-01-04 22:28:36.301 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Group

Thank you all for the inputs.

(Anders Alfredsson) #43

You should only define your item once, now you have the same item in two different files. Then, since you apparently copy pasted the item definition from the forum instead of typing it yourself, like @vzorglub said, the quotation-marks are wrong. If you look in your log at the time you saved your file it would have warned about validation issues. If something is wrong with the syntax in a file, none of the items in that file gets created.

How do you edit your files? I would recommend using VScode with the OpenHAB plugin, then these errors can be detected easily.

(Kees Van Gelder) #44

Thanks for your quick ‘how too’ I decided to revert back to the ‘old’ binding. Seemed more straightforward and simpler

(4KAUTO) #45

Thanks for the feedback. I was using notepad now I am using vscode. I correct the errors but now in the basic UI I am seeing KEY1 instead of a button. Any suggestions?

(Sascha Billian) #46

I’m totally unclear what that means.
Are you seing the text KEY1 instead of the text BUTTON 1?
Please post your sitemap. Since you can override labels in the sitemap it could be that the cause lies in here.
And also please post a screenshot of what you currently see in your sitemap

(4KAUTO) #47


sitemap default label="Some Place" {

Frame label="Ground Floor" icon="groundfloor" {

Group item=GF_Sonoff_RF {

Switch item=GF_Sonoff_RF_Button_1 label="RfKey1" mappings=[ON="Key 1"]




(Jürgen Baginski) #48

You mapped ON to show “Key 1”!, delete the mapping and it will show ON!

(4KAUTO) #49

Thanks. I am seeing the buton now but unable to command rfkey1 to the sonoff. My mqtt command topic is cmnd/sonoff-rf/RFKEY1

(Sascha Billian) #50

Use mqtt.fx to check if the correct MQTT payload is sent to the broker. Do the logs show any error?

(Martin Mailloux) #51

Thanks, great help!

(Joachim Boeddeker) #52

Will this also include JavaScript transformations (incoming & outgoing)?

(Kaju666) #53

Thank you Sascha_Billian.
I’ve searched for a whole day to how te setup mqtt in openhab2 and everithing is to version 1.
Now i have working sonoff swith :slight_smile:

But can somebody help me what to add here or change to have my switch to know when it’s turned on by RF Pilot or the hardware button?

(Sascha Billian) #54

Sonoff will publish always the same state if is triggered. that means a MQTT command or pressing the button on the sonoff will always publish the same state.
So i am afraid there is no way to do it like this, but in OpenHab you could have a proxy item (= an item without channel) that then publishes a MQTT command to the sonoff. So if sonoff switches on without this item being set to on => somebody triggered the sonof remotely.
Otherwise sonoff is triggered by openhab:

Switch SonoffProxy
rule "Switch Sonoff from OH"
   item SonoffProxy changed from OFF to ON
  logInfo("sonoff rule", "sonoff triggered from OH")

(Alex Spitz) #55

So if I understand it right, there is no way (without using a proxy item) to reflect on an openHAB sitemap a change to an item that occurred when a physical button was pressed?
I mean, I want my Basic UI switch item to show as ON when my wife switched the light by using the light switch and not the app. Is that possible?

(Vincent Regaud) #56


(Kaju666) #57

[Q] So in new MQTT 2.4 there is no possibility to configure it using files. The paperUI and adding through Things is the only way?

(Jürgen Baginski) #58

[A] Wrong. Search the forum, I have posted several examples on how to configure MQTT2 with files.

(Kaju666) #59

@Sascha_Billian @alexspitz This configuraion knows when the hardware button or rf button was pressed and change state in basicui.

This is now my working settings

Bridge mqtt:broker:mosquitto "Mosquitto MQTT Broker" @ "MQTT" [ host="localhost", secure=false, port=1883, clientID="Oh2Mqtt2"]
    // Main Light
    Thing mqtt:topic:SonoffMainLight "Main Light" @ "MQTT"  {
          Type switch : switch "Power Switch" [ 
          Type string : state02 "Switch State 02" [ 
    // Bed Light
    Thing mqtt:topic:SonoffBedLight "Bed Light" @ "MQTT"  {
          Type switch : switch "Power Switch" [ 
          Type string : state02 "Switch State 02" [ 
     // Sonoff Amplifier
    Thing mqtt:topic:SonoffAmplifier "Sonoff Amplifier" @ "MQTT"  {
          Type switch : switch "Power Switch" [ 
          Type string : state02 "Switch State 02" [ 


  Main Light
Switch SonoffMainLight_Switch "Main Light Switch" <lightbulb> ["Lighting"] { channel="mqtt:topic:SonoffMainLight:switch" }
String SonoffMainLight_State "Main Light State"  { channel="mqtt:topic:SonoffMainLight:state02", channel="mqtt:topic:SonoffMainLight:switch" }
  Bed Light
Switch SonoffBedLight_Switch "Bed Light Switch" <lightbulb> ["Lighting"] { channel="mqtt:topic:SonoffBedLight:switch" }
String SonoffBedLight_State "Bed Light State"  { channel="mqtt:topic:SonoffBedLight:state02", channel="mqtt:topic:SonoffBedLight:switch" }
Switch SonoffAmplifier_Switch "Amplifier Switch" <player> ["Switchable"] { channel="mqtt:topic:SonoffAmplifier:switch" }
String SonoffAmplifier_State "Amplifier State"  { channel="mqtt:topic:SonoffAmplifier:state02", channel="mqtt:topic:SonoffAmplifier:switch" }

EDIT (added SONOFF MQTT Config Screen):

Stability of myopenhab & google home for everyday use
(Vincent Regaud) #60

Thanks @kaju666
Are these working settings or do you still have problems?