Mqtt problem

Hi

i have a problem whit my mqtt after opdating to 3.0

my item is

Number Temperature_Vaerksted “Temperatur værksted [%.2f °C]” {mqtt="<[mybroker:/Sonoffth1/Temp_Vaerksted/Temperature:state:default]"}

Number Humidity_Vaerksted “Humidity [%.1f %%]” {mqtt="<[mybroker:/Sonoffth1/Temp_Vaerksted/Humidity:state:default]"}

Number Temperature_Terrasse “Temperatur Terrasse [%.2f °C]” (gHistory) {mqtt="<[mybroker:/Sonoffth3/Temp_Terrasse/Temperature:state:default]"}

String Temperature_Terrasse_Min “- Min. Temp [%.1f °C]”

String Temperature_Terrasse_Max “- Max. Temp [%.1f °C]”

Number Humidity_Terrasse “Humidity [%.1f %%]” (gHistory) {mqtt="<[mybroker:/Sonoffth3/Temp_Terrasse/Humidity:state:default]"}

Number Temperature_Rugemaskine “Temperatur Rugemaskine [%.2f °C]” {mqtt="<[mybroker:/Sonoffth2/Temp_Rugemaskine/Temperature:state:default]"}

Number Humidity_Rugemaskine “Humidity Rugemaskine [%.1f %%]” {mqtt="<[mybroker:/Sonoffth2/Temp_Rugemaskine/Humidity:state:default]"}

Switch Varme_Vaerksted “Varme Værksted” {mqtt=">[mybroker:/Sonoffth1/gpio/12:command:ON:1],>[mybroker:/Sonoffth1/gpio/12:command:OFF:0]"}

Switch Varme_Vaerksted_Signal “Varme Værksted signal”

Switch Julelys1 “Julelys1” (gJulelys) {mqtt=">[mybroker:/Sonoff4/gpio/12:command:ON:1],>[mybroker:/Sonoff4/gpio/12:command:OFF:0]"}

Switch Sonoffvg1 “Sonoff vægstik 1” (gJulelys) {mqtt=">[mybroker:/Sonoffvg1/gpio/12:command:ON:1],>[mybroker:/Sonoffvg1/gpio/12:command:OFF:0]"}

Switch Sonoffvg2 “Sonoff vægstik 2” (gJulelys) {mqtt=">[mybroker:/Sonoffvg2/gpio/12:command:ON:1],>[mybroker:/Sonoffvg2/gpio/12:command:OFF:0]"}

Switch Sonoffvg3 “Sonoff vægstik 3” (gJulelys) {mqtt=">[mybroker:/Sonoffvg3/gpio/12:command:ON:1],>[mybroker:/Sonoffvg3/gpio/12:command:OFF:0]"}

and my item broker is

as you can see is broker online but my items do not work like they did in openhab 2.0

They won’t as you are using Item notation for the v1 MQTT Binding, which no longer exists in openHAB3. You will have to move your configuration over to the v2/v3 syntax with Things and Items.

This page has a v1 to v2/v3 conversion example:

1 Like

Hi

I have try to do this but i cant get it to work can you help me

this is one og my sonoof whit easyesp the default.items line is

Number Temperature_Vaerksted “Temperatur værksted [%.2f °C]” {mqtt="<[mybroker:/Sonoffth1/Temp_Vaerksted/Temperature:state:default]"}

how do the demo.things line lock for this items line

my broker is mybroker
ip is 192.168.1.85 (not the same as openhab )
usernavn for broker is admin
password for broker is nbovler76

try this… use > instead of <
Number Temperature_Vaerksted “Temperatur værksted [%.2f °C]” {mqtt=“>[mybroker:/Sonoffth1/Temp_Vaerksted/Temperature:state:default]”}

Please share, using code fences (sandwich your code between three backticks ```), the current state of your configuration which is not working.

```

like
this

``\

default.items

Number Temperature_Vaerksted “Temperatur værksted [%.2f °C]” {mqtt=“<[mybroker:/Sonoffth1/Temp_Vaerksted/Temperature:state:default]”}

i dont know how to make the code in the demo.things

can yoy help me convert it

my broker is mybroker
ip is 192.168.1.85 (not the same as openhab )
usernavn for broker is admin
password for broker is nbovler76

What editor program did you use to make your default.items file? You should be able to use the same editor to make an mqtt.things file, but you need to put it in folder /things, which is a sister folder to folder /items.

As said before, this syntax is for version 1 ONLY and will NOT work in OH3 (neither with < nor with >)!

Is but i dont know how i Convert my item like the ex.

Bridge mqtt:broker:myUnsecureBroker [ host=“192.168.0.42”, secure=false ]
{
Thing topic mything “My Thing” {
Channels:
Type switch : heatpumpChannel “Heatpump Power” [ stateTopic=“heatpump”, commandTopic=“heatpump/set”, transformationPattern=“JSONPATH:$.power” ]
}
}

I have try evrryting i can think off whitout lock but if somebody can help my how my item should lock like in the things fil

Number Temperature_Vaerksted “Temperatur værksted [%.2f °C]” {mqtt=“<[mybroker:/Sonoffth1/Temp_Vaerksted/Temperature:state:default]”}

You Item does not go in the xxx.things file. Your Item stays in the xxx.items file.

The {mqtt= } is version 1 syntax and willnot work with the Things and channels.
So you get rid of that and replace it with {channel= } and put in the id of your new channel as shown in the examples given before.

From earlier -

Your xxx.things file -

Do you think you should make a change here?

Hello again

Now I have tried again and I am sorry but I can not make it work so hope you can see what is wrong

default.items fil

Number Temperature_Vaerksted “Temperatur værksted [%.2f °C]” { channel=“mqtt:topic:mybroker:mything:Temperature_VaerkstedChannel”

The demo.things fil

Bridge mqtt:broker:mybroker [ host=“192.168.1.85”, secure=false ]
{
Thing topic mything “My Thing” {
Channels:
Type number : Temperature_VaerkstedChannel “Temperature_Vaerksted” [ stateTopic=“Temperature_Vaerksted”, commandTopic=“Temperature_Vaerksted/set”, state=“default” ]
}
}

Your new topic

doesn’t seem to quite match with your old topic

Is this a different device?

Hi
No it’s the same item
what should I correct, I have gone completely in blank

OK, so a few things:

  • stateTopic and commandTopic need to contain your MQTT topics
  • Your original v1 MQTT configuration didn’t have a command topic, so you don’t need commandTopic for the v2.
  • You said that your broker has a username and password, but you didn’t configure your bridge to use a username and password.
  • You don’t have the correct syntax as shown to you in the link previously posted. Importantly, strings must be encapsulated by speech marks: "192.168.1.85"

Try the following:

Things

Bridge mqtt:broker:mybroker [
    host="192.168.1.85",
    secure=false,
    username="admin",
    password="nbovler76"
    ]
{
    Thing topic mything "My Thing" {
        Channels:
            Type number : Temperature_VaerkstedChannel "Temperature_Vaerksted" [
                stateTopic="Sonoffth1/Temp_Vaerksted/Temperature"
            ]
    }
}

Item

Number Temperature_Vaerksted "Temperatur værksted [%.2f °C]" { channel="mqtt:topic:mybroker:mything:Temperature_VaerkstedChannel" }

Note that if you are now using Things and Items files you must first completely remove any attempts that you made using the UI.

Hi

Now I have tried to correct the code for what you have written above

but I still do not get a value in from my sonoff

223652: EVENT: Temp_Vaerksted # Temperature = 7.20
223655: EVENT: Temp_Vaerksted # Humidity = 70.60
243833: DHT: Temperature: 7.20
243833: DHT: Humidity: 70.60
243834: EVENT: Temp_Vaerksted # Temperature = 7.20
243837: EVENT: Temp_Vaerksted # Humidity = 70.60
247515: WD: Uptime 4 ConnectFailures 14 FreeMem 25024
247516: MQTT: Connection lost
248522: MQTT: Connected to broker
248528: Subscribed to: / Sonoffth1 / #

this is the log from my sonoff (easyesp)


I fandt it :clap: :clap: :clap: :clap:
ther need to be a / in the front of Sonoffth1/Temp_Vaerksted/Temperature

like this

Type number : Temperature_VaerkstedChannel “Temperature_Vaerksted” [stateTopic=“/Sonoffth1/Temp_Vaerksted/Temperature”

Hello again

i have a little trouble with the switch part in sonoff

i’ve tried this but it does not send the command to sonoff

Bridge mqtt: broker: mybroker [
host = “192.168.1.85”,
secure = false,
username = “admin”,
password = “nth74skn”
]
{
Thing topic mything “temp Workshop” {
Channels:
Type number: Temperature_VaerkstedChannel “Temperature_Vaerksted” [stateTopic = “/ Sonoffth1 / Temp_Vaerksted / Temperature”
]
Type number: Humidity_VaerkstedChannel “Humidity_Vaerksted” [stateTopic = “/ Sonoffth1 / Temp_Vaerksted / Humidity”
]
Switch type: Varme_VaerkstedChannel “Switch_varme_vaerksted” [stateTopic = “/ Sonoffth1 / gpio / 12, commandTopic =: / Sonoffth1 / gpio / 12”
]
}
}

You almost never want to be sending (command) and listening (state) to the exact same topic. So that’s a clue that something has been misunderstood.

What message do you need to send to your sonoff, and on what topic?
Do you have an example from your old MQTT v1 config?

Hi
yes I have and it was this line

Switch Varme_Vaerksted “Varme Værksted” {mqtt=“>[mybroker:/Sonoff1/gpio/12:command:ON:1],>[mybroker:/Sonoff1/gpio/12:command:OFF:0]”}