Migrating MQTT1 items to MQTT2.4 items

Please post your complete item definition.

1 Like

rfgroup.items

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”}

sonoff.items

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

log

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.

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.

1 Like

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

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?

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

sitemap

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"]

}

}

}

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

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

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

Thanks, great help!

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

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?

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"
when
   item SonoffProxy changed from OFF to ON
then
  MyRealSonoffItem.sendCommand(ON)
  logInfo("sonoff rule", "sonoff triggered from OH")
end
1 Like

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?
Thanks!

See:

[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?

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

1 Like

@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
mqtt.things

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"  {
      Channels:
          Type switch : switch "Power Switch" [ 
            stateTopic="tasmota/sonoff-mainlight/POWER", 
            commandTopic="tasmota/sonoff-mainlight/cmnd/POWER",
            on="ON",
            off="OFF"          
          ]
          Type string : state02 "Switch State 02" [ 
            stateTopic="stat/sonoff-mainlight/POWER",
            on="ON",
            off="OFF"
          ]
    }
    
    // Bed Light
    Thing mqtt:topic:SonoffBedLight "Bed Light" @ "MQTT"  {
      Channels:
          Type switch : switch "Power Switch" [ 
            stateTopic="tasmota/sonoff-bedlight/POWER", 
            commandTopic="tasmota/sonoff-bedlight/cmnd/POWER",
            on="ON",
            off="OFF"          
          ]
          Type string : state02 "Switch State 02" [ 
            stateTopic="stat/sonoff-bedlight/POWER",
            on="ON",
            off="OFF"
          ]
    }
    
     // Sonoff Amplifier
    Thing mqtt:topic:SonoffAmplifier "Sonoff Amplifier" @ "MQTT"  {
      Channels:
          Type switch : switch "Power Switch" [ 
            stateTopic="tasmota/sonoff-amplifier/POWER", 
            commandTopic="tasmota/sonoff-amplifier/cmnd/POWER",
            on="ON",
            off="OFF"          
          ]
          Type string : state02 "Switch State 02" [ 
            stateTopic="stat/sonoff-amplifier/POWER",
            on="ON",
            off="OFF"
          ]
    }
    
  
}

sonoff.items

/*
  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" }
/*
  Amplifier
*/
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):

6 Likes

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