Sonoff-HomeAssistant (Alternative firmware for Sonoff Switches for use with mqtt/HA)

I have seen this warning on other posts about sonoff, but thanks for the reminder. Shame about your gear, what a bummer.

It’s not just Sonoff’s, it’s nearly all modern electronics. There is no isolation transformer any more. In the old days that transformer would isolate mains voltage from low level DC voltage. There was never an electrical path between them. Now with new switch mode supplies that is no longer the case. On a positive side power supplies have shrunk to the point where they can make a device like a Sonoff so small. It was a silly mistake because I was rushing, that’s all. When developing software it seems like you have uploaded firmware 1000 times. The only thing that actually bothers me about ESP modules is how slow they are to upload compared to Arduino’s but if your just send code 1 or twice it’s not big deal.

I don’t want people to be put off working on the them because they are awesome units for the price, JUST BE CAREFUL :smiley:

2 Likes

KmanOz,

You mention installing in the wall behind a switch. Were you able to fit a sonoff module inside the switch box mounted in the wall? At first look it seems like they would be too large to fit inside a standard switch box with the switch installed.

Thanks,
Ryan

It does help thank you.

I have one of the originals (none TH) that takes 1 Minute to start.and connect. Its over a minute before I see any lights flashing or control take place.

But my TH10 takes less than 10 seconds.

You have an issue for sure. These ESP chips are freaky. I have been playing with them (even before Sonoff) since they came out and I’v seen some strange behavior. Is it a location problem? Have you tried another one in that location?

Ryan I live in Australia and forget the US standard, which BTW I think is one of the best in the world. We don’t have wall boxes here behind any switches or powerpoints and internal cabling isn’t enclosed in conduit either if it’s in a wall or ceiling. It’s basically an open wall cavity so in Australia and countries where that happens, the original Sonoff is definitely small enough and drops down the wall and just stays there happily.

Hi folks, what about the included black button on Sonoff?

Can I use it with an external real switch by soldering two wires, but changing the way the button works - from momentary push button to a real switch with open and close state?

It works with a push button for sure haven’t had a try on normal wall switches yet since a long press resets the unit we would need to convert the wall switch somehow if I’m not mistaken someone has posted a solution for this somewhere I’ll check later and post back if I find it.

2 Likes

There’s an answer for this a little way up the thread. If only you scrolled up a little bit :smiley: Not much, just a few clicks.

2 Likes

ok, sorry. That was the problem, is was just a few clicks above… I recently got my Reader Status with exactly these posts, almost 20 min reading it, and thought my research was done when almost at the end… sorry again

So, I need to mix the @mudman’s modifications with which code? there are many different versions!
Is there a ready to copy and paste code for using a normal in wall switch?

Am I wrong or this is the cheapest way to turning my normal home switches into automated without changes their external aspect?
What do you guys use for automating home switches and knowing their status???

Thanks

Hi,
I’ve some trouble with DHT22 and a wall switch.
First, I’m not able to run with DHT22… it always answers with nan. I’ve used a 10k Resistor between data and 3.3v pin… should i lower this value?
Second, I’m using RX pin in INPUT mode to be able to switch the relay with a wall switch… the only point without solderings are the IO male-female connectors and the screw terminal for the wire to the wall-switch. Wall-switch works right, but when I shake the wire near the screw terminal, the sonoff start to change relay state many times… how can i solve this? I’m using interrupts with debounce of 500ms for the RX pin

long debouncing_time_sw = 500; //Debouncing Time in Milliseconds
volatile unsigned long last_micros;
[...]
attachInterrupt(digitalPinToInterrupt(RXPIN), handleWallSwitch, CHANGE);
[...]
void handleWallSwitch() {
  if((long)(micros() - last_micros) >= debouncing_time_sw * 1000) {
    blinkLED(LED, 40, 2);
    Serial.println("wall switch");
    digitalWrite(RELAY, !digitalRead(RELAY));
    sendRelayStatus = true; 
    last_micros = micros();
  }
}

OK well after my disaster of blowing everything up :slight_smile: and thanks to @RAWB which got me a Sonoff POW quickly, I will update the Github with POW code that’s been stable for 4 days running. I will give it another couple of days running solidly before I upload but by the weekend should be confident enough to share :smiley: Currently power is sent every 15sec but is changeable in the code to whatever you want.

{“Power”: 18.18, “Voltage”: 240.46}
{“Power”: 18.42, “Voltage”: 240.25}

I’m actually going to replace a lot of my power not light switches with a POW. It’s interesting to know what every device in house sucks up.

2 Likes

I ordered 2, now they are back in stock.

You recommend them? How do they fit inside the wall? They seem pretty thick to me to go inside electric socket wall (I live in Italy).

Is it obligatory to change firmware to use them in HA, or cannot work out of the box?

ALL MY ANSWERS IN CAPS ABOVE :smiley:

I did not understand this last answer … is it needed to change the firmware or not?

YES MOST DEFINITELY, you need to change it. Useless with HA out of the box.

1 Like

Ok, thanks. Is your first post the way to go, also for the POW model?

Wich function will have HA in terms of energy metering (that’s what I am more interested into).

ahh understand, no we have bricks. The wall socket are fitted making a hole in a brick. For that I will need to use a hammer and make, at the back of the wall socket, a bigger hole and fit the POW somehow.

I’m just about to update my Github with a version for the POW. At the moment there is no POW version. Will be on the weekend.

Yes unfortunately in some countries it’s almost impossible to mount behind the switch unless you demolish your house :smiley:

Excellent, I bought 2, will mount even more. Just want to make sure that will work with ha

@anon35356645 have you seen https://www.itead.cc/sonoff-touch.html ?

and there is a option to change the firmware https://github.com/davidmpye/Sonoff-Touch-MQTT