@llgb Hi
Set the protocol to OpenHAB MQTT.
See also the Tools > Advanced that is filled Publish and Subscribe Template.
-
Sonoff - WiFi Wireless Smart Switch for MQTT COAP Smart Home
Pimatic = Smart Home
-
@wutu said in Sonoff - WiFi Wireless Smart Switch for MQTT COAP Smart Home:
@llgb Hi
Set the protocol to OpenHAB MQTT.
See also the Tools > Advanced that is filled Publish and Subscribe Template.Hey,
I’ve tried this in the last few days and checked a lot of possiblities (cleaned up my rapsbian packages, installed a clean working mosquitto, and so on) because sometimes my Sonoffs were working (I thought), I connected my lights to the Sonoff’s, switched them on via pimatic and after 5 minutes they were switched off -.-
I have 3 Sonoffs names: espeasy01, espeasy02, espeasy03.
The last two days I have only connected espeasy02 and it ran pretty stable. Got a huge uptime in its webGUI, Log was fine and I was possible to switch it via pimatic.
BUT (and here comes the strange thing) as soon as I powered on another Sonoff (espeasy03) BOTH of them showed the typical misbehaviour and restared every 5-7minutes.
Log looks like (content is repeating, counting up the ConnectFailures):
Log 127095 : Subscribed to: /espeasy02/# 156068 : WD : Uptime 2 ConnectFailures 8 FreeMem 29232 156068 : MQTT : Connection lost 157084 : MQTT : Connected to broker 157092 : Subscribed to: /espeasy02/# 158172 : SW : State 0.00 186069 : WD : Uptime 3 ConnectFailures 10 FreeMem 28368 186069 : MQTT : Connection lost 187088 : MQTT : Connected to broker 187096 : Subscribed to: /espeasy02/#
So as far as I connect only one Sonoff to my pi, it keeps its connection and everything is fine. But as soon as I power on another Sonoff (no lamp connected) BOTH of them seem to loese their connection.
This makes no sense to me! Does anyone of you have a clu what could cause this behaviour?
-
@llgb Hi, Please check if you’ve got Sets unique “Unit nr” on the Config page.
Each device must have a unique unit num. It is added to the client name when registering on the broker.
Pimatic = Smart Home
-
also have one of these running now but looks like connection is not reliable at all
using qos now with the plugin but I don’t know if the esp downgrades the qos.
Also not sure if the Wifi is strong enough where the device is located but had a wifi extender right next to it and it didn’t improve. Currently the RSSI is -50 dB could you post some reference value here?2213300 : MQTT : Connection lost 2214345 : MQTT : Connected to broker 2214396 : Subscribed to: /LichtBadezimmer/# 2233420 : EVENT: Clock#Time=Fri,22:27 2243301 : WD : Uptime 36 ConnectFailures 25 FreeMem 26440 2243301 : MQTT : Connection lost 2245396 : MQTT : Connected to broker 2245420 : Subscribed to: /LichtBadezimmer/# 2246501 : SYS : 36.00 2246502 : EVENT: #=36.00
looks like just mqtt is constantly reconnecting
I have the unique ID set and only on esp with espeasy running.
-
looks like network problems on the esp. I just took a look at the mosquitto log…
1464382961: New connection from xx on port 1883. 1464382961: New client connected from xx as ESPClient2 (c1, k15, u'xx'). 1464382976: Socket error on client ESPClient2, disconnecting. 1464382991: New connection from xx on port 1883. 1464382991: New client connected from xx as ESPClient2 (c1, k15, u'xx'). 1464383006: Socket error on client ESPClient2, disconnecting. 1464383021: New connection from xx on port 1883. 1464383021: New client connected from xx as ESPClient2 (c1, k15, u'xx'). 1464383036: Socket error on client ESPClient2, disconnecting.
ip and username replaced with xx
-
@thex hi, Yes, Espeasy downgrades QoS to 0.
What version ESPEasy you use? Also send screenshots of sites Config and Tools> Advanced.
My RSSI is -60dB (AP is in the same room).Pimatic = Smart Home
-
passwords and names and so on are there but I quickly removed them from the screenshot
-
@thex Hi,
everything seems ok.
If you have correctly created password file. Then set for web log level 4 and take a look what it displays.
You can also start mosquitto with the -v flag.Pimatic = Smart Home
-
working great so far. Have replaced 3X 433 Mhz switches with these sonOff. I also check if they are “online” with PING plugin.
Andyone tried SonOFF with DHT22 ? -
@hyperx said
Andyone tried SonOFF with DHT22 ?
Look at ESPEasy forum: http://www.esp8266.nu/forum/viewtopic.php?f=5&t=721&hilit=sonoff&start=140#p6980
P.S. I do not know if it’s a good idea.
Pimatic = Smart Home
-
@lxz i’m getting the error when i putt the plugin Mqtt in my config.json…any idea ?
{
“plugin”: “mqtt”
}logfile
Reconnecting to MQTT Broker
13:27:49.565 [pimatic-mqtt] MQTT Broker is offline
13:27:52.929 [pimatic-mqtt] Error on connecting to MQTT Broker operation timed out
13:27:54.573 [pimatic-mqtt] Reconnecting to MQTT Broker
13:27:54.628 [pimatic-mqtt] MQTT Broker is offline
13:27:59.636 [pimatic-mqtt] Reconnecting to MQTT Broker
13:27:59.685 [pimatic-mqtt] MQTT Broker is offline -
@krissie said in Sonoff - WiFi Wireless Smart Switch for MQTT COAP Smart Home
@lxz i’m getting the error when i putt the plugin Mqtt in my config.json…any idea ?
Hey,
You’ve installed and launched a MQTT broker? For example Mosquitto?Pimatic = Smart Home
-
@wutu
no , i have not installed an MQTT broker ? Is there a how to…for this ? link ? -
Hi @krissie,
if you are installing on Raspberry Pi - http://jpmens.net/2013/09/01/installing-mosquitto-on-a-raspberry-pi/.
byePimatic = Smart Home
-
@wutu thanks for the link. I have installed MQTT broker and the erro is gone. butt still nog communication with the Sonoff. Is there a way to check if to check if everything is correct.
is the a way to communicate with the ESP8266 with the IP-adres instead the name…to make pimatic find the sonoff ?
-
Have you checked the strings of the template?
in the configuration of the esp under tools-> advanced -> the first 2 strings?
Subscribe Template: /%sysname%/#
Publish Template: /%sysname%/%tskname%/%valname%they must “match” the topic string the the device configuration in pimatic:
e.g. :
{ "class": "MqttSwitch", "id": "sonoff_1", "name": "Ganglicht Decke", "topic": "/sonoff_1/gpio/12", "state" : "/sonoff_1/state", "onMessage": "1", "offMessage": "0" },
%sysname% is the device name of your Sonoff - in my case sonoff_1 (you find in in the webinterface of esp: -> config -> main settings -> name)
%tskname% is the task name (esp: -> devices -> name) or you can take gpio and in the next step the number of the gpio
%valname% is the name of the value (esp: -> devices -> values ) or the number of the gpio if you choose “gpio” as task namei´ve choosen the variante with “gpio/12” instead of “relay/state” so i´m not dependant on names!
and i tried it 2 times with names but no success…but i don´t know why!you can also check what´s send and received my the mqtt server.
use the command:
mosquitto_sub -d -t /#
(if the command is not found:
sudo apt-get install mosquitto-clients
)this will subscribe you to all messages that go over the mqtt server and will display them with debug information.
here you should see what happens…
here the log when pimatic send a command to the switch and get´s the answer from the sonoff back:
pi@raspberrypi ~ $ mosquitto_sub -d -t /#Client mosqsub/13253-raspberry received PUBLISH (d0, q0, r0, m0, '/sonoff_1/gpio/12', ... (1 bytes)) 1 Client mosqsub/13253-raspberry received PUBLISH (d0, q0, r0, m0, '/sonoff_1/relay/state', ... (1 bytes)) 1
hope this will help you!
-
thank you for rhe detailled information. Only +I use this configuration
{
“class”: “MqttSwitch”,
“id”: “sonoff_1”,
“name”: “Ganglicht Decke”,
“topic”: “/sonoff_1/gpio/12”,
“state” : “/sonoff_1/state”,
“onMessage”: “1”,
“offMessage”: “0”
},For the “state” option he is ginving an error… some other users use “StateTopic”…Is there a difference ?
-
Hey @krissie, @johnny11
In the state topic you’re missing %taskname"stateTopic": "/sonoff_1/%taskname/state"
EDIT:
@krissie said: is the a way to communicate with the ESP8266 with the IP-adres instead the name…to make pimatic find the sonoff ?
In MQTT, Pimatic not communicate with devices directly, but through brokers.
Pimatic is just another client, even though the most important. This has the advantage that you could Pimatic during maintenance, the use of another client, for example, CLI (mosquitto_sub, mosquitto_pub) or Android app. Or what do you pick@johnny11 said: i´ve choosen the variante with “gpio/12” instead of “relay/state” so i´m not dependant on names!
and i tried it 2 times with names but no success…but i don´t know why!This is normal, this is how ESPEasy behave.
Pimatic = Smart Home
-
Guys, sorry that I’ve written nothing for such a long time. I’m already working on the next projects and I’ve been in vacation for few weeks.
I just wanted to thank you ass rocking experts so much. My Sonoff devices are running fine since you supported me so paitently. I will donate you a beer if that will be possible once a day !
Keep on guys!
-
@llgb said in Sonoff - WiFi Wireless Smart Switch for MQTT COAP Smart Home:
I will donate you a beer if that will be possible once a day !
well, you can donate to pimatic if you like to
you can also receive some nice free stickers for your enclosures or whatever you like to stick them to …pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !