Need Help in configuring Openhab to Tasmota Firmware Sonoff switch

Host (domus1)

192.168.0.99

Port (1883)

1883

Client (DVES_00BEE7)

DVES_%06X

User (DVES_USER)

DVES_USER

Password

•••••••••

Topic = %topic% (sonoff)

Masterlight

Full Topic (%prefix%/%topic%/)

%prefix%/%topic%/

The above is my settings in MQTT Server setup on the sonoff switch

Switch Masterlight “Masterlight” [ “Switchable” ]
{mqtt=">[broker:cmnd/Masterlight/POWER:command:ON],>
[broker:cmnd/Masterlight/POWER:command:OFF]"}

The above is the text in my home item file

sorry i seem to have no clue on what i am doing but i can turn on and off the device from MQTT fx but not for openhab2

Can you guide me what i doing wrong

Please use code fences in future when pasting contents of your items, logs etc - it prevents formatting getting lost.

The thing that jumps out at me is that your Item is configured with the default (which makes it seem like you’ve copied and pasted from a tutorial) of “broker”

How does your mqtt.cfg file in the conf/services directory identify your MQTT configuration? Is it called “broker” in there too?

In mine, it is defined as:

mosquitto.url=tcp://192.168.10.200:1883

and in my .items file I’d then have:

Switch Garage_Lights "Garage Lights"  <light> (gGarage) { mqtt=">[mosquitto:cmnd/sonoff-garage-t1/POWER:command:*:default],
                                                                <[mosquitto:stat/sonoff-garage-t1/POWER:state:default]",
                                                                autoupdate="false"}

(I like to put my outgoing and incoming commands onto separate lines so that I can easily see what is what, but that’s just personal preference, it can all be on a single line)

Okay lets start.
We need input.

Give us your /etc/openhab2/services/mqtt.cfg
Give us your /etc/openhab2/items/mqtt.items
Give us a Screenshot of your Sonoff Device>Configuration>MQTT
Do you use openHABian?
openHAB 2.X ? Which one?
Did you read the MQTT Docs ?
Did you read this Topic ? ITEAD Sonoff switches and sockets - cheap ESP8266 Wifi+MQTT hardware
Did you check out the Tasmota Wiki?

mqtt.items example

Switch a_Licht_Outdoor_Sonoff4Channel_2_Biertisch               "Lichterketten Biertisch"         (g_Outdoor, g_MYSQL) { mqtt=">[mosquitto:cmnd/sonoff-80786B/POW
ER2:command:*:default], <[mosquitto:stat/sonoff-80786B/POWER2:state:default]" }

mqtt.cfg example

#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
#<broker>.url=tcp://<host>:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a default one is generated.
#<broker>.clientId=<clientId>

# Optional. User id to authenticate with the broker.
#<broker>.user=<user>

# Optional. Password to authenticate with the broker.
#<broker>.pwd=<password>

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>
mosquitto.clientId=SmartOffice
#mosquitto.url=tcp://192.168.107.2:1883
#mosquitto.url=tcp://107.0.0.1:1883
mosquitto.url=tcp://192.168.107.2:1883
mosquitto.user=openhabian
mosquitto.pwd=NoWayYouGetMyPass
mosquitto.qos=1
mosquitto.retain=true
mosquitto.async=true

# The Sonoff Tasomate Broker
#maddox.url=tcp://sonoff.maddox.co.uk:1883

Example Screenshot of my 4Ch Sonoff

https://puu.sh/yrn1X/c2d47700ac.png

I could bet your broker is not named broker, for me I named it mosquitto. Followed the wiki.

1 Like

Thanks a ton you have given lot of things to work with and go through let me go through the same and get back to you

Thanks a lot for your reply

1 Like

MQTT CFG File - i am sorry but dont think i ever configured it because all the videos tutorials i went through did have anything

#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
broker.url=tcp://192.168.0.99:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
#<broker>.clientId=<clientId>

# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false
# Optional. User id to authenticate with the broker.
#<broker>.user=<user>

# Optional. Password to authenticate with the broker.
#<broker>.pwd=<password>

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>
# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>

/etc/openhab2/items/mqtt.items - This is blank again

The details of my mqtt setting on sonoff device

Host (domus1)

192.168.0.99


Port (1883)

1883


Client (DVES_00BEE7)

DVES_%06X


User (DVES_USER)

DVES_USER


Password

•••••••••


Topic = %topic% (sonoff)

Masterlight


Full Topic (%prefix%/%topic%/)

%prefix%/%topic%/


`I am using openhab2.10

Thanks and sorry for looking like a fool but i went through tons on online video and all just end up confusing

How did you setup the MQTT Broker. Is it running? Where is it running ?

MQTT fx? whats this?
Sorry for confusion but /etc/openhab2/items/mqtt.items is how I named my MQTT items. I have seperate items files for each type of binding. Like mqtt.items hue.items network.items

You need to configure your mqtt.cfg ! Like this. the first part mosquitto is THAT what you will use later inside your items.
It could also be something else like ULTRAMQTT but you need to remember that broker name!

--> mqtt.cfg with mosquitto. <--
{ mqtt=">[mosquitto:cmnd/sonoff-80786B/POW
ER2:command:*:default], <[mosquitto:stat/sonoff-80786B/POWER2:state:default]" }

--> mqtt.cfg with ULTRAMQTT <--
{ mqtt=">[ULTRAMQTT:cmnd/sonoff-80786B/POW
ER2:command:*:default], <[ULTRAMQTT:stat/sonoff-80786B/POWER2:state:default]" }
mosquitto.clientId=SmartOffice
mosquitto.url=tcp://The_Broker_IP
mosquitto.user=The_User_You_created_for_mosquitto_broker
mosquitto.pwd=The_password_you_set_for_mosuitto_broker
mosquitto.qos=1
mosquitto.retain=true
mosquitto.async=true

binding-mqtt1 - 1.10.0
That is the only thing install as per the video i went through

Should i install another addon??

You clearly did not read the docs…
The broker, how did you set it up ???
Which IP does your broker have: ?
Which user did you set for the broker: ?
which password did you set for the broker: ?

Please follow the instructions I gave in the other thread

1 Like

Hi!

Sorry i am confused from what i know i have setup a broker and the ip of the same is 192.168.0.99

I can use app called MQTT.Fx and send the following commands to my switch

cmnd/Masterlight/POWER
On - Switches on the switch

cmnd/Masterlight/POWER
Off - Switches off the switch

And for the MQTT.Fx these commands work perfectly

congrats!

Now you can continue with step 4 of my list :wink:

1 Like
# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>
mosquitto.clientId=SmartOffice
#mosquitto.url=tcp://192.168.107.2:1883
#mosquitto.url=tcp://107.0.0.1:1883
mosquitto.url=tcp://192.168.107.2:1883
mosquitto.user=openhabian
mosquitto.pwd=NoWayYouGetMyPass
mosquitto.qos=1
mosquitto.retain=true
mosquitto.async=true

# The Sonoff Tasomate Broker
#maddox.url=tcp://sonoff.maddox.co.uk:1883

Do i need to add these lines in cfg file ??

1 Like

Thanks got it working now,

Thanks a ton you were kind enough to bear with my stupid question without losing your cool :grinning::grinning:

No Problem. Reading Docs and understand it can be hard sometimes but its worth it.

Number LivingRoom_Light_RSSI "Living Room Light: RSSI [%d %%]" (gRSSI)
    { mqtt="<[broker:tele/sonoff-A00EEA/STATE:state:JSONPATH($.Wifi.RSSI)]" }

How do i add this to site mapp what would be the code as for switch we use switch item

Ok managed to add this but signal percentage shows zero any clue why

The part of the documentation you need to study to answer this question: http://docs.openhab.org/configuration/sitemaps.html

Hi!

Got Yahoo weather i can get the temperature on Classic UI but the same is not visible on habpanel or app any ideas what i need to do for the same

Whenever i turn a device on or off i get the offline message in the bottom only happens in this UI