Config files

I first would like to thank everyone in this forum as well as the developers. I have been considering home automation for a while and when I discovered sonoff decided to give it a shot. I’ve read the openhab manual (every word) at least 3 times, the tasmoda wiki a lot, and everything I can find on mqtt and mosquitto.

I have Openhab 2.1 and mosquitto installed on a Pi B+ through openhabian. I can Ssh in, and I can “Hello World”. I have Tasmota flashed to 1 sonoff basic installed on an extension cord and can toggle it through it built in web page.
I have installed the mqtt binding and the mqtt action in the paper UI. My config files are as follows:

Mqtt.cfg

mosquitto.url=tcp://localhost:1883
mosquitto.clientId=openhab
mosquitto.retain=true
mosquitto.async=false

lights.items

Switch cord1 “cord”
{ mqtt=">[mosquitto:cmnd/cord1/POWER:command:*:default],
<[mosquitto:stat/cord1/POWER:state:default]" }

lights.things

//Thing <binding_id>:<type_id>:<thing_id> “Label” @ “Location” [ ]

Thing mqtt:Switch:cord1 “cord”
[ mqtt=">[mosquitto:cord1/POWER:command:ON:1],[mosquitto:cord1/POWER:command:OFF:0]
<[mosquitto:stat/cord1/POWER:state:default]"]

On my Sonoff Basic Module

MQTT parameters

Host (domus1)
openhabianpi

Port (1883)
1883

Client Id (DVES_9702D5)
cord1

User (DVES_USER)
openhabian

Password
•••••••••

Topic = %topic% (sonoff)
lights

Full Topic (%prefix%/%topic%/)
diana/lights/cord/power

I’m sure there’s something simple I’ve missed but days searching this forum has me all the more confused. Thank you for your suggestions.

Hello,
I would use a MQTT-Client like MQTTLens to check whitch part of the communication fails.
You can see, if and what openHAB sends and can try to switch the Sonoff manualy.
I think also, you don’t need MQTT Action.
I dont know tasmoda but ESPEasy may be a alternative and it doesn’t need a .thinks-definition.
My mqtt.cfg

 mosquitto.url=tcp://openHABianPi:1883
 mosquitto.clientId=openHAB
 mosquitto.user=openhabian
 mosquitto.pwd=xxx
 mosquitto.qos=1
 mosquitto.retain=true
 mosquitto.async=false

and a item

Switch D4 "LED" {mqtt=">[mosquitto:esp16256864/gpio/2:command:*:default],<[mosquitto:openHAB/esp16256864/gpio/2:state:default]"}

I have never seen a thing been defined using the mqtt binding. I believe that this is wrong and it won’t work.
Did you find any material giving such an example?

I found it here, ( in the openhab docs under things)
In the defining things using files section.
http://docs.openhab.org/configuration/things.html

Started from scratch. Please have a look.

mqtt.cfg

mosquitto.url=tcp://localhost:1883
mosquitto.clientId=openhabian
//mosquitto.user=openhabian
mosquitto.qos=1
mosquitto.retain=true
mosquitto.async=false

cord.items

Switch cord1 “Cord” {mqtt="<[mosquitto:diana/lights/cord1:state:default], >[mosquitto:diana/lights/cord1:command:ON:1], >[mosquitto:diana/lights/cord1:command:OFF:0]"}

lights.items

Switch cord1 “cord” { channel=“network:device:192_168_1_201:online” }

lights.sitemap

sitemap lights label=“diana_lane” {
Frame label=“Date” {
Text item=Date
}
Frame label=“Lights” {
Switch item=cord1 label=“Cord”

    }

}

lights.things ( i get a “missing EOF at ‘Switch’” error on the first line and a grayed out x on the next)

//Thing <binding_id>:<type_id>:<thing_id> “Label” @ “Location” [ ]

Switch mqtt:Device:cord1 “cord”
{ mqtt:">[mosquitto:cmnd/cord1/POWER:command:*:default],
<[mosquitto:stat/cord1/POWER:state:default]"}

no need for that. delete that file. MQTT is a 1.x binding and doesn’t use the concept of Things (this is valid only for 2.x bindings)

Your configs look good but you are using 2 (switch type) items with the same name (cord1)… don’t do that :slight_smile:
Why do you need another item bound to the network channel?

To avoid a known issue, do the following:

@Dim
Thank you I’ve already read and exercised your linked topic.
@hr3
Thank you. Trying to figure out MQTTLens now. And, thank you for the example item.

1 Like