ITEAD Sonoff switches and sockets - cheap ESP8266 Wifi+MQTT hardware

Yes, there is again one more binding/server which i have to install, learn, maintain…

Thought as much. Had the same thought myself back then.
Are you by any chance running openHABian? There is an option for that :slight_smile:

No, i´m running openhab on debian in a virtual machine on a xeon server.

Installing mosquitto is dead-easy. there are also docker containers if you prefer that.

Again, I hope this is useful. On this video I go through the settings i typically use with Sonoff devices in my Openhab2 controlled home automation setup.

2 Likes

I like ESPEasy too but it seems we will not see any further development with this project due to the recent announcement from the author.

That depends… If someone is prepared to take over control of the Git then i don’t see why the project cannot continue.I would volunteer, but I could not do the task justice.

I would like to share here my recent experience with the itead inching switch
https://www.itead.cc/smart-home/inching-self-locking-wifi-wireless-switch.html
that I purchase from banggood. I think it may be of help to other users.

The switch is compatible with arendst MQTT firmware by using the generic SONOFF switch, but in order to use it there are a couple of difficulties that need to be overcome.

  1. both the RX and TX pins are not connected while GND and 3.3V are ok. In order to program the switch following the guides shown in this thread it is necessary to connect directly to the esp8266 board. I found this information in the itead forum at the following link [(1 channel inching switch)], (http://support.iteadstudio.com/support/discussions/topics/11000009218) , which shows a very useful pinout of the esp2866 board. In that thread, only TX pin is reported to be not connected.
  2. arendst MQTT firmware works on this switch (a user reported success in using it), but I actually found that GPIO12 and GPIO13 are reversed. I therefore sligthly modified the user config file of arendst project.

In summary, it seems to me that there are many similar switches around that may have some defects (some components seem to be manually soldered and the ESP2866 board is not perfectly aligned), with sligthly different pinouts.

I would recommend to test the switch with the app before reflashing: it is not possible infact to flash the original firmware back. In the official ITEAD website there are not many informations on how to reprogram this switch (possibly due to the fact that there too many versions around, see my previous post on outdated products).

I hope that this may help somebody,
LionHe
PS The new version (tasmota) of arendst firmware works correctly without any modification.

Hi Joe
I’m not sure if you did find an answer but you can switch power on/off with http-command like this:

http://192.168.8.103/?o=1

Hi Ole,
thanks for answering! I did follow the programmer on github and there are a lot more commands possible sending via http-request for controlling the Sonoff-devices:
https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/issues/89
_ttps://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Commands

Though I was trying to find a way to get a simple response to the http-request rather than getting a more complex “web-page” it is now possible to get a very simple text-respnose with the actual version. Along with that another brilliant thing is that it is now possible to compile the scetch without MQTT-support which was a not-needed featrue in my case:
https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/issues/200

So, now I’m very happy to use those very cheap but relieable devices!
At least again: Thanks once more to Thom Dietrich for helping me out of the darkness by giving support about the first steps in flashing the Sonoff-devices!

I don’t understand why so many try to avoid mqtt at all costs. Mqtt is imo really brilliant and pretty much a no brainer for iot and headless machine to machine communication. It’s worth the investment to set it up and it can serve as a base for plenty of openhab integrations.

Regards s

4 Likes

Hi Seaside,

I understand your point of view very well. I have got an homematic system running in my home and if I want to use the already built in components along with MQTT devices I have to use a MQTT-server in addition to the homematic control center (CCU).

So the easiest way for me is to get devices which can be controlled by simple http-commands, because there is a plugin (CUx Daemon) which is providing such a capability.

Now you migh say … well why don’t you stick to the homematic-components… and the reason is the price (e.g. a homatic wall plug costs about 50€ while a Sonoff S20 just costs 15€ and so on…)

That’s why I not using MQTT.

Regards
Joe

I started first with HTTP commands and found them not to be very reliable, so I changed to MQTT and everything is working fine now.
So if you experience any problems on the long run, consider changing to MQTT :slight_smile:

1 Like

So you are not actually using openHAB? You should consider it. Replace your CCU by a RPi with busware SCC and homegear and you can additionally use all openHAB bindings or install a MQTT broker besides other things. That’s what I did and I would never want to go back to the few (good!) functionalities the CCU gave me.

If you want to stay with Homematic only, maybe have a look at this project of mine. It’s still doing a great job in my home and the home of a friend:

1 Like

Article update

Hey guys, I’ve updated the above article.

The article is now more oriented towards arendst’s new Sonoff-Tasmota firmware. It’s a great firmware and arendst constantly adds new modules and functions to it!
I’ve given a step-by-step tutorial on how to flash and configure the module. I did keep it short here as I tried to cover most of what is needed in the wiki of the project GitHub project itself. The process is now pretty simple as you can simply use PlatformIO instead of an Arduino IDE with a bunch of additional steps.

I did also add a few more pictures. I have recently flashed 14 Itead Sonoff modules and decided to go with a Pogo Pins “programmer” instead of soldering pins to each and every module. The whole process went great and I’ve saved myself a lot of time there :hourglass_flowing_sand: :wink:

Lastly I’ve given an example on how to integrate a Sonoff Basic module in openHAB. If you have other modules, please post your configuration so I can add them to the first post. (@Seaside?)

Please let me know if you see any errors! :slight_smile:

Happy Hacking!

6 Likes

Firmware update requires items updates

There was a problem with Sonoff-Tasmota’s usage of JSON, in combination with openHAB: https://github.com/arendst/Sonoff-Tasmota/issues/4 This was fixed with the new firmware revision, but you will have to adapt your MQTT topics used. I’ve updated the wiki article on openHAB, so this should be easy.

2 Likes

@ThomDietrich thanks again for supporting my issue :wink:

1 Like

Hey Andrew, sure thing. That’s what a community is for after all, right!? :wink:
How many different Sonoff modules do you own? Would you post some of your items?

At the moment I have just 2 Sonoff Basic modules. One of them had to be TH10, but I made a mistake with the order.
I will share what I have on top of the basic relay control.

I have the button logically ‘detached’ and controlled from the OH.
So first the buttontopic needs to be set to something different from the main topic, in my case it is “sonbutt1”. This can be done from any mqtt client like mosquitto_pub or MQTTLens.

Switch	WiFiSwitch1 "Sonoff #1" <poweroutlet> { mqtt=">[broker:cmnd/sonoff1/power:command:ON:default], >[broker:cmnd/sonoff1/power:command:OFF:default]" }
Switch	WiFiButton1 "Sonoff #1 pushbutton" { mqtt="<[broker:cmnd/sonbutt1/POWER:state:ON]" }

Then some logic needs to be implemented by using a rule:

// Sonoff button
rule "Button"
when
	Item WiFiButton1 received update
then 
	if (WiFiSwitch1.state != ON) {
		WiFiSwitch1.sendCommand(ON)
	}
	else if (WiFiSwitch1.state != OFF) {
		WiFiSwitch1.sendCommand(OFF)
	}
end

Another example is a special ‘maintenance’ menu I have. It can be used to send some commands to Sonoff from OH instead of using the standalone mqtt client. The main use case for me is the upgrade - I just need to put the bin file on my server and click the button. Other functions could be added easily.

Item:

String	Sonoff1action "Sonoff #1 action" <switch> { autoupdate="false" }

Sitemap:

Switch item= Sonoff1action mappings=[queryFW="Query FW", restart="Restart", upgrade="Upgrade"]

And the rule:

// Sonoff maintanance actions
rule "Sonoff"
when
	Item Sonoff1action received command
then 
	switch (receivedCommand) {
		case "restart" : 
			publish("broker", "cmnd/sonoff1/restart", "1") 
  		case "upgrade" :
			publish("broker", "cmnd/sonoff1/upgrade", "1")
		case "queryFW" :
			publish("broker", "cmnd/sonoff1/status", "2")
		}
end
2 Likes

Hey Andrew! Thanks :wink:

I love your maintenance idea! If you added one more thing, setting the upgrade URL, the whole thing could go to the wiki article :wink: You could use the URL here as default: https://github.com/arendst/Sonoff-Tasmota/issues/19

How do you look at the result of your commands? Do you have an item subscribing to RESULT or do you check your MQTT broker manually?