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

The code at Github works fine. I have 1 here working with that code and I just ordered 1 more. What is the problem?

switch:

  • platform: mqtt
    name: “PR Suite”
    state_topic: “home/sonoffth/1/stat”
    command_topic: “home/sonoffth/1”
    qos: 0
    payload_on: “on”
    payload_off: “off”
    retain: true

  • platform: mqtt
    name: “Il Suite”
    state_topic: “home/sonoffpow/1/stat”
    command_topic: “home/sonoffpow/1”
    qos: 0
    payload_on: “on”
    payload_off: “off”
    retain: true

  • platform: mqtt
    name: “Ilum”
    state_topic: “home/Sonoff_4ch_1/1/stat”
    command_topic: “home/sonoff_4ch_1/1”
    qos: 0
    payload_on: “1on”
    payload_off: “1off”
    retain: true

That is my code to fisrt works fine is a sonoff pow and sonoff th the tird is for a 4ch but not work

send me your file on you are the code for switch sonoff 4ch .yaml to [email protected] please.

Please mind your manners.

1 Like

For anyone interested, the new Sonoff RF Bridge looks very interesting. They’ve built everything onto the circuit board and aren’t using modules. Receiver is based on a SYN470R which is a good chip (not the best) but certainly very sensitive and should have very good reception over long distances.

Anyway this is not available yet. This is an engineering sample that I have but the stock product is designed to be exactly what it’s name suggests, an RF bridge for 433Mhz using their eWeLink App not your own broker. It’s desiged to learn an RF code and re-transmit it at will. As I said earlier, my plans are to make it a mqtt / PIR / Door Switch / Smoke Detector gateway for HA similar to what I have now.

Looks very promising :smiley:

Check more at the link for now. I will study circuit diagram but looks like they have an additional microcontroller in there that captures received packets and talks back to the ESP via serial. Without looking into it I think it would sample the OOK sent to it, store it and present it to the ESP as a mem location that can be triggered via a serial command. That’s just a guess but suffice to say it’s going to take some reverse engineering to work out what exactly is happening.

https://www.itead.cc/wiki/Sonoff_RF_Bridge_433

3 Likes

hi guys. I just finished trawling through this epic thread after a friend bought some of these devices for a project hes working on. Awesome work BTW @KmanOz! :slight_smile:

I’ve found this Sonoff that will work for a low voltage application that I have in mind but I don’t see anyone here that has tried to get one working with @KmanOz’s code. https://www.itead.cc/inching-self-locking-wifi-wireless-switch.html

How difficult of a task would it be getting existing code working with this?

If you want to flash custom firmware on the 1 Channel Inching /Self-Locking WiFi Wireless Switch 5V 12V for mqtt I would recommend Sonoff-Tasmota https://github.com/arendst/Sonoff-Tasmota/

Received a new batch of Sonoff Basics today. Looks like the quality of the screw connectors has become somewhat better. They just don’t twist like the use when you tightened them with a screw driver.

1 Like

ALL

The new Sonoff Basics I have received are using a different EEPROM. They use a PN25F08B. That means that programming them with the standard settings you’ve used before is not going to work. They will accept the flash but will not boot correctly unless you use FLASH MODE = DOUT in the settings.

Everything else stays the same. Cheers

4 Likes

Any chance a double click and long press could be added to the sonoff touch?

Hey Turu,

Has you code been pretty solid, I have under floor heating and thinking about adding on of these devices with the sensor you have…

After reading through this entire LOOONG thread i think I’ve come up with the required steps to make the basic sonoff work with a standard wall switch:

Make the following modifications to the ESPsonoff-v1.01p firmware:

  1. after -> #define LED 13 // (Don’t Change for Original Sonoff, Sonoff SV, Sonoff Touch, Sonoff S20 Socket)

add:

#define WALLSWITCH 14

  1. after -> int kRetries = 10; // WiFi retry count. Increase if not connecting to router.

add:

int wallSwitch = 1; // (Do not Change)
int lastWallSwitch = 1; // (Do not Change)

  1. after -> pinMode(BUTTON, INPUT);

add:

pinMode(WALLSWITCH, INPUT);

  1. after -> checkStatus();

add:

checkWallSwitch();

  1. BEFORE -> void timedTasks() {

add:

void checkWallSwitch() {
wallSwitch = digitalRead(WALLSWITCH);
if (wallSwitch != lastWallSwitch) {
digitalWrite(RELAY, !digitalRead(RELAY));
sendStatus = true;
}
lastWallSwitch = wallSwitch;
}

Then to use a “proper” wall switch I connect a 10k resistor between the ground pin and GPIO14 on the 5 pin header and connect my external switch between GPIO14 (on the header) and 3.3VDC.

And by “proper” I assume you mean a US standard in wall toggle light switch from home depot, lowes, et al.

After all of the modifications above I should be able to use my wall switch as a toggle switch to control my basic sonoff switch (in addition to the standard home assistant MQTT command and the little installed pushbutton on the front)?

2 Likes

I want to control a 5v USB fan. Got a spare switch at home. What’s the best way of doing this or is it not possible?

Does the input need to be 90v!?

Sonoff is an 240V AC switch, the USB Fan is a 5V DC device! The only way you could do it is to take the input from the mains that’s going to a AC/DC power plug that the fan plugs into and switch that.

This link will tell you how to modify a sonoff to separate the 110v input from the outout to turn the sonoff into a wifi controlled dry contact relay.

http://www.boized.com/2017/02/how-to-convert-wifi-sonoff-into-dry.html

Needs a little mechanical ability and soldering skills but nothing too major.

1 Like

Thanks @finity @keithh666 just been looking st the S20 and SV.

Might be easier to go down that route :slight_smile:

Cheers again

Yep, I use 433mhz plugin sockets for anything like dc fans.

1 Like

Dear KmanOz,
Thank you very much for your great works. I have just received Sonoff Touch T1, 2 and 3 gangs with 433Mhz. I could successfully flash them with your ESPsonoff-v1.0p. (I don’t want to use 433MHz). The switches show the connected status to my network. As I could see the local IP of the switch listed. But I couldn’t control them with Home Assistant. I used this same firmware of yours with old type 1-gang Sonoff Touch without any problem. This new T1 model is much better than I thought. The installation design flaw of the old 1-gang Sonoff Touch has been eliminated in the new T1 model. and also T1 model has self-illuminating lights showing both ON and OFF states in each switch. I could clearly see the switches in the dark not like in the old 1-gang touch switch. Do you have any plan to make new firmware for this T1 model? If you have any comments please kindly advise. Thank you in advanced. Here below is the inside of T1 switches.

1 Like

Hi

That’s great it works. ITEAD are pretty smart. They don’t reinvent the wheel every time. I don’t have one here to test. To be honest Sonoff have been kind to me and have sent many samples but not this unit, I will ask them, leave it with me. I need to spend some time updating the firmware but have not spent any time on it of late. I will get onto it soon. I have some other ideas as well :smiley:

Have you solved this?