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

:roll_eyes:…sometimes its that easy :)…THX Thomas :wink:

1 Like

It doesn’t seem as anybody here is really interested in using sonoff without flashing them. Anyway: here is code that emulates the sonoff cloud, and can easily being interested with the http binding into openhab.

Thanks for the hint, it’s great to hear, that there is a way.

For me and I believe most others the reasoning for flashing is probably the following: The Sonoff Tasmota firmware is free, open source, feature rich and cloud-decoupled. The module will henceforth communicate via MQTT and offer many functions and options not available with the original firmware. In retrospective I’d go as far and say that the Sonoff modules become especially interesting for home automation because of the Tasmota firmware.

1 Like

Is this also applicable to the sonoff led lights?

What is? Please remember that others can only work with details you provide.

I have been using Sonoff-Tasmota for my own build LED drivers with ESP-01 --> Sonoff "own build" and javascript

Sorry about that I’m hindsight that was not the most well phrased question.

The question(s) that I wanted to ask was: does flashing firmware with sonota/tosmota also work with the LED lights from sonoff, specifically the B1 LED light?
Has any one made an implementation of the sonoff LED lights with openhab, with dimming, color change and the works?

I see. Yes it’s supported and as far as I know all of these features work. See:

I have several sonoffs with tasmota already up and running with openhab but today I added a sonoff RF bridge with tasmota. I already let it learn my rf switches’ signals but now I have the problem of adding them to openhab.

Does anyone have the code (or an idea) to do it? I get messages like this (topic / content): sonoffs/tele/sonoffRFBridge/RESULT = {“RfReceived”:{“Sync”:8130, “Low”:270, “High”:800, “Data”:“4536B4”, “RfKey”:3}}
so I guess I need to react to the right message only in Openhab.

Something like:

Switch SonoffrfBridgeBtn3 "Button 3 is: [%s]" { mqtt="<[mosquitto:sonoffs/tele/rfbridge/???]" }

where I am unsure about the last part.

Thanks for the help!

You’ll need to work with the JsonPath transformation. That is documented here: https://github.com/arendst/Sonoff-Tasmota/wiki/openHAB#integration

Switch SonoffrfBridgeBtn3 "Button 3 is: [%s]" { "<[mosquitto:sonoffs/tele/sonoffRFBridge/RESULT:state:JSONPATH($.RfReceived.RfKey)]" }

Hi not sure if this is the right post,I can’t place my sonoff basic in programming mode,I push the button on the sonoff and I’ve soldered the pins to sonoff and USB to computer but not working?

You need to:

  • power of the sonoff
  • push the button and keep it pressed
  • power on the sonoff

Now you can release the button and start programming. Did you do that? Also you have switched RX/TX lines on your programmer?

1 Like

Have tried that ,I have looked online new sonoff basic have problems getting into programming mode?

Sonoff Pow Switches state undefined after Openhab 1.8.3 startup

I’m running OpenHAB 1.8.3 on a RaspBerry with two Sonoff Pow with Arendst Tasmota firmware 4.0.3: I know these are not the last versions, but as almost everything works I am reluctant to update!
From the OpenHAB web page I can operate the two switches. If I operate the switches from their web page, the openHAB web page is updated. The problem is that at OpenHAB startup the status of the switches is Undefined (this is happening daily as I stop and restart openhab after a backup) and they appear as OFF while in reality they are ON.

Here’s my item definition (the line is split for improved readability)

Switch SonoffPow1 "Appl1 "  <heat> (SwitchStatus)  {mqtt=">[broker:cmnd/sonoff-pow1/power:command:ON:1],
>[broker:cmnd/sonoff-pow1/power:command:OFF:0],
<[broker:stat/sonoff-pow1/POWER:state:default]", autoupdate="false"} 

I’ve subscribed to the topic “stat/sonoff-pow1/POWER” with mosquitto_sub and I’ve seen that nothing appears when OpenHAB starts.

I then modified the item adding the tele/sonoff-pow1/STATE topic as follows

Switch SonoffPow1 "SAppl1 "  <heat> (SwitchStatus)    {mqtt=">[broker:cmnd/sonoff-pow1/power:command:ON:1],
>[broker:cmnd/sonoff-pow1/power:command:OFF:0],
<[broker:stat/sonoff-pow1/POWER:state:default],
<[broker:tele/sonoff-pow1/STATE:state:JSONPATH($.POWER)]", autoupdate="false"} // :.*

This solution works but I wonder if I’m following the right path or if there are some other ways to solve this problem.
Should I force OpenHAB to submit a message “stat/sonoff-pow1/POWER” in the startup rule (if yes how?) so that the item SonoffPow1 will be updated?

You could probably do something with persistence to make it so that OH remembers the last state?
But what happens if the state is changed while your OH is rebooting…
I had the same question and the Tasmota guys reckon the “tele” topic and it’s STATE is a decent approach.

1 Like

Thank for your reply.
Would it be worth updating the wiki with these findings?

Not a bad idea… Do you know how to do it cause I never have?
This is an example of the “tele” topic from a 4 channel Sonoff named “sonoff4ch01”.
I see it publishing this topic every 5 minutes.

Topic : tele/sonoff4ch01/STATE
Payload : {“Time”:“2017-11-13T07:52:27”, “Uptime”:0, “Vcc”:3.157, “POWER1”:“OFF”, “POWER2”:“ON”, “POWER3”:“ON”, “POWER4”:“ON”, “Wifi”:{“AP”:1, “SSId”:“MyWifiDontTouch”, “RSSI”:82, “APMac”:“AA:BB:CC:DD:EE:FF”}}

I understand your hesitation and concerns but still need to mention that at least once:
In my personal opinion you should upgrade to openHAB 2.1 before investing any more time improving your outdated 1.8 installation, not even to speak of the old openHAB 1.8 wiki which will soon be deprecated.

openHAB 2.1 is very stable and offers many new/improved features compared to 1.8. Old bindings still work with openHAB 2.1 while new are added every other day. There is really no sane reason to stay with 1.8 any longer. The only valid reason is of cause the initial effort. See http://docs.openhab.org/tutorials/migration.html

2 Likes

I would be very interested in knowing how you set it up I’ve tried on Ubuntu 16.04 LTS and it cannot find the sitemaps. I noticed with the raspberry Pi3 when you changed a sitemap or items a lot was written to the events file (or was it syslog) that doesn’t happen with ubuntu

can you help me in connecting the switch to openhabb server