Hi all,
I try to get my Sonoff with the ESPEasy firmware working with OH2, and i am strugeling for several days with it. So i try te get some help.
I am rather new to OH started with 1.8.3, and switched over to OH2 Snapshot Release.
My configuration with Fibaro Wall Plugs is working nicely, including some cron rules.
So i thought i give the Sonoff device working with mqtt a try. Installed Mosquitto which is working. It tested OK with the two terminal window subscribe and publish methode. Also in PaperUI i installed the MQTT addon. But i am not able to get the configuration right.
This is my mqtt.conf:
mosquitto.url=tcp://192.168.178.54:1883
mosquitto.clientId=openhab
Everything else is commented out (#).
My mqtt-eventbus.cfg contains only:
broker=mosquitto
The Sonoff (ESP8266) is loaded with the ESP Easy firmware and configured as this:
For some reason the image is not showing, so i have it uploaded here:
https://deltabert.stackstorage.com/s/qU4Y19IfqdN6Bqn
When i look from the terminal to mosquitto with the command
mosquitto_sub -d -v -t \#
i get the following from my Sonoff device (there is only one Sonoff):
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r1, m0, 'openhab/out/EE_3_SW_WCD_1/state', ... (3 bytes))
openhab/out/EE_3_SW_WCD_1/state OFF
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r1, m0, 'openhab/out/EE_3_SW_WCD_1_power/state', ... (1 bytes))
openhab/out/EE_3_SW_WCD_1_power/state 0
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r1, m0, 'openhab/out/EE_3_SW_WCD_1_meter_kwh/state', ... (3 bytes))
openhab/out/EE_3_SW_WCD_1_meter_kwh/state 0.4
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r1, m0, 'openhab/out/EE_3_SW_WCD_1_meter_watts/state', ... (1 bytes))
openhab/out/EE_3_SW_WCD_1_meter_watts/state 0
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r1, m0, 'openhab/out/sonoff_1/state', ... (3 bytes))
openhab/out/sonoff_1/state OFF
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r1, m0, '/openHAB/out/EE_3_SW_WCD_1/command', ... (3 bytes))
/openHAB/out/EE_3_SW_WCD_1/command OFF
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r1, m0, '/openHAB/out/sonoff_1/command', ... (3 bytes))
/openHAB/out/sonoff_1/command OFF
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r0, m0, '/Sonoff_1/Wifi/', ... (3 bytes))
/Sonoff_1/Wifi/ -82
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r0, m0, 'openhab/out/CurrDateTime/state', ... (19 bytes))
openhab/out/CurrDateTime/state 2017-02-25T21:47:21
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r0, m0, 'openhab/out/Date/state', ... (19 bytes))
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r0, m0, 'openhab/out/Season/state', ... (6 bytes))
openhab/out/Season/state WINTER
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r0, m0, 'openhab/out/SeasonName/state', ... (6 bytes))
openhab/out/SeasonName/state WINTER
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r0, m0, '/Sonoff_1/Wifi/', ... (3 bytes))
/Sonoff_1/Wifi/ -82
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r0, m0, '/Sonoff_1/Wifi/', ... (3 bytes))
/Sonoff_1/Wifi/ -82
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r0, m0, '/Sonoff_1/Wifi/', ... (3 bytes))
/Sonoff_1/Wifi/ -82
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r0, m0, '/Sonoff_1/Uptime/Minutes', ... (5 bytes))
/Sonoff_1/Uptime/Minutes 54.70
Client mosqsub/13252-openhab received PUBLISH (d0, q0, r0, m0, '/Sonoff_1/Wifi/', ... (3 bytes))
/Sonoff_1/Wifi/ -83
^C
openhab@openhab:~ $
(I am also confused that some entries start with a slash (Sonoff) and some are not.)
I have looked at numeral examples and the online OH manual but i can’t get the thing working.
I think am am stuck at the moment…
I configured this for the Sonoff in my items file:
Swith sonoff_1 "Sonoff Switch 1 [%s]" {mqtt=">[mosquitto:/Sonoff_1/gpio/0:command:ON:1],>[mosquitto:/Sonoff_1/gpio/0:command:OFF:0]"}
String sonoffUptime "sonoffUptime [%s]" {mqtt="<[mosquitto:/Sonoff_1/Uptime:state:default]"}
And put this in my sitemap:
Switch item=sonoff_1 label="Sonoff-1 aan/uit" icon="light"
Text item=sonoffUptime
I get these errors in openhab.log:
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[83:org.eclipse.jetty.util:9.2.19.v20160908]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
2017-02-25 21:17:13.075 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'sonoff_1' for widget org.eclipse.smarthome.model.sitemap.Switch
2017-02-25 21:17:13.077 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Switch
2017-02-25 21:17:13.079 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'sonoff_1' for widget org.eclipse.smarthome.model.sitemap.Switch
2017-02-25 21:17:13.081 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'sonoff_1' for widget org.eclipse.smarthome.model.sitemap.Switch
2017-02-25 21:17:13.083 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'sonoff_1' for widget org.eclipse.smarthome.model.sitemap.Switch
openhab@openhab:~ $
And these in mosquitto.log:
openhab@openhab:~ $ tail -100 /var/log/mosquitto/mosquitto.log
1488002021: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488003822: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488005623: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488007424: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488009225: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488011026: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488012827: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488014628: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488015061: Client ESPClient0 has exceeded timeout, disconnecting.
1488015061: Socket error on client ESPClient0, disconnecting.
1488015109: New connection from 192.168.178.211 on port 1883.
1488015109: New client connected from 192.168.178.211 as ESPClient0 (c1, k15).
1488016429: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488018230: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488020031: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488021832: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488023633: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488025434: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488027235: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488029036: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488030837: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488032638: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488034439: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488036240: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488038041: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488039842: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488041643: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488043444: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488045245: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488046193: New connection from ::1 on port 1883.
1488046193: New client connected from ::1 as mosqsub/2127-openhab (c1, k60).
1488046209: Socket error on client mosqsub/2127-openhab, disconnecting.
1488046213: New connection from ::1 on port 1883.
1488046213: New client connected from ::1 as mosqsub/2146-openhab (c1, k60).
1488046234: Socket error on client mosqsub/2146-openhab, disconnecting.
1488046318: New connection from 192.168.178.46 on port 1883.
1488046318: New client connected from 192.168.178.46 as MQTT_FX_Client (c1, k60).
1488047046: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488048518: New connection from ::1 on port 1883.
1488048518: New client connected from ::1 as mosqsub/4880-openhab (c1, k60).
1488048541: Socket error on client mosqsub/4880-openhab, disconnecting.
1488048563: New connection from ::1 on port 1883.
1488048563: New client connected from ::1 as mosqsub/4939-openhab (c1, k60).
1488048599: Socket error on client mosqsub/4939-openhab, disconnecting.
1488048636: New connection from ::1 on port 1883.
1488048636: New client connected from ::1 as mosqsub/5035-openhab (c1, k60).
1488048712: Socket error on client mosqsub/5035-openhab, disconnecting.
1488048717: New connection from ::1 on port 1883.
1488048717: New client connected from ::1 as mosqsub/5124-openhab (c1, k60).
1488048847: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488049067: Socket error on client mosqsub/5124-openhab, disconnecting.
1488049080: New connection from ::1 on port 1883.
1488049080: New client connected from ::1 as mosqsub/5541-openhab (c1, k60).
1488049262: Client ESPClient0 has exceeded timeout, disconnecting.
1488049262: Socket error on client ESPClient0, disconnecting.
1488049307: New connection from 192.168.178.211 on port 1883.
1488049307: New client connected from 192.168.178.211 as ESPClient0 (c1, k15).
1488049313: Client MQTT_FX_Client has exceeded timeout, disconnecting.
1488049313: Socket error on client MQTT_FX_Client, disconnecting.
1488049333: Client ESPClient0 has exceeded timeout, disconnecting.
1488049333: Socket error on client ESPClient0, disconnecting.
1488049373: New connection from 192.168.178.211 on port 1883.
1488049373: New client connected from 192.168.178.211 as ESPClient0 (c1, k15).
1488050230: Socket error on client mosqsub/5541-openhab, disconnecting.
1488050648: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488051983: New connection from 192.168.178.46 on port 1883.
1488051983: New client connected from 192.168.178.46 as MQTT_FX_Client (c1, k60).
1488052292: New connection from ::1 on port 1883.
1488052292: New client connected from ::1 as mosqsub/9303-openhab (c1, k60).
1488052449: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1488052459: Socket error on client mosqsub/9303-openhab, disconnecting.
1488052465: New connection from ::1 on port 1883.
1488052465: New client connected from ::1 as mosqsub/9509-openhab (c1, k60).
1488052509: Socket error on client mosqsub/9509-openhab, disconnecting.
1488054250: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
openhab@openhab:~ $ ^C
As first step i would like to be able to switch the Sonoff from the commandline, and the second step from my sitemap.
I hope anyone can help me with the correct configuration for my Sonoff devices.