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

We need to control 3 parameters. Colour (3 options) so a three position switch, brightness (so a slider) and power ON/OFF. I just feel a separate component would make it very easy for anyone to setup. Basically add component. add mqtt topic and everything comes up.

EDIT: I just saw MQTT Light component. I will play with it tomorrow and see. Yes it might be possible with just that.

For the colour temp the color_temp_command_topic can be used.

Did you finally tested the mqtt light component? Just received my LEDs, will try one this weekend with their app, but honestly, I would like HA integration if posible :wink:

No I didn’t have a chance. I will over the weekend.

Thanks KmanOz for your work on the Sonoff range and greetings from a fellow Aussie.

I have used your Git Hub code for the TH16 and it is working fine.
Takes a little time to connect but once connected is very solid in Home Assistant.
The switch works consistently and the temp and humidity values report to the HA dashboard.

Initially, I used the Itead app to “get into the game” of home automation and got used to the timers.
Do you have any suggestions for a beginner like myself how setting timers might be possible?

Thanks again and it is just great to see how you have assisted us all to use these inexpensive Itead products in Home Assistant,

Cheers
RAWB

No worries at all. Taking long to connect can be a a number of factors from your wireless router to signal strength etc. If you notice in the code there is a line that says:

int kRetries = 10;

If you find it’s not connecting quickly and it times out a lot (flashes 4 times over and over) before it connects, you can increase that retry value to say 20 or 30. The code sits in the connect loop longer if you do that rather than timing out early.

As for timers, now that you have it running with HA, you can do anything.

Check this HASS sprinkler

Good luck.

@KmanOz used your code on a sonoff switch and it worked first time. I am using the switch to control aquarium lighting and would like to implement a time schedule. The sprinkler example looks good but complex for my requirements. Just need to switch on and off for a period every day. I tend to like clean and simple solutions (that’s why I used your code :).

Tried looking around for some samples but wasn’t successful. Any tips about where I can find some sample code please?

LOL you probably need to start to get to know HomeAssistant. Here’s 2 simple automations. First one turns on the switch, second one turns it off.

- alias: Turn on Fishtank Lights at 9:00pm
  trigger:
    platform: time
    after: '21:00:00'
  action:
    service: switch.turn_on
    entity_id: switch.fishtank_lights

- alias: Turn off Fishtank Lights at 10:30pm
  trigger:
    platform: time
    after: '22:30:00'
  action:
    service: switch.turn_off
    entity_id: switch.fishtank_lights

That’s about as simple as it gets.

Is it possible to flash this without an arduino? I have a usb to serial and am trying to use easyesp but would rather use this if possible

You don’t actually need an Arduino board at all. You only need the Arduino IDE (Software) installed on your computer and an FTDI adapter. Hope that helps.

1 Like

Edit: found my issues.

Should the blue light be on all the time?

Also I have a different temp probe (DS18B20) Looks like it uses the one wire protocol not DHT :frowning:

Hi

Yes the blue light should be on all the time. It tells you that it’s connected to an Access Point and mqtt. Sorry no support for the DS18B20 and I haven’t actually got one here to try it. It wouldn’t take me very long at all if there was demand for it but it seems most use the DHT-22 because it also reports Humidity.

Hi
Can you also support https://www.itead.cc/sonoff-dual.html?

At the moment I am bilding my christmas lights. I would like to control with one board about 8 GPIO. Can you show me how I where I have to put the other GPIO’s in to your code so I get the same stability )

The dual is completely different. It has an additional processor. Haven’t started yet. It’s on the list for sure as is the Pow. On the weekend I am going to release firmware for the LED strip. Working OK and just testing fully before I release it.

1 Like

Can you help me to revise your program to activate the RELAY & LED only once when the sonoff has been switch ON (230V). I tried to revise your program but there is a problem on what I did, it always activate the RELAY&LED when the connection lost to the wifi then connect again. I only want to activate the RELAY & LED one time only when it power ON (230V). please help… thanks

Please describe your situation a little bit better. What exactly is happening to your network / switches / etc.

Sonoff-LEDS

I’ve finished the code for the Sonoff LED strip.

https://www.itead.cc/sonoff-led.html?acc=70efdf2ec9b086079795c442636b55fb

Inside the linked file below is everything you need to get going. Not sure how many people are interested in this product but it’s pretty good. Can easily replace the main lighting in your room because it’s VERY bright, and stays very cool at max brightness. I think for the price they are on a winner here. Anyway will release here first before I go to Github. Good luck.

http://gofile.me/6sw88/GWI1xY1Ur

NOTE: Once you replace the firmware in the LEDS, just like the Sonoff switches, there’s no going back to iTead’s software.

Kman

1 Like

Nice one @KmanOz !
Be interested to know your use cases on these, been wondering how I can use them around the house. Any pics of them in action?

I only have 1 unit and it’s on the workbench. Will definitely order some more. They’re not your typical strip of LEDS for mood lighting. These are so bright that they can literally light up a room and are designed for that exact purpose. I’ll come back with some usage (watts) in the next couple of days and see how efficient they are as well :smiley: Impressed though.

1 Like

Hey! I’ve been trying to make this tutorial work for just one switch, and after fiddling for way too long and not making it work, I decided to check out what the esp8266 says in serial port.

I get the “wifi failed” message periodically, so I guess my chip doesn’t even make it to my router.

Any ideas why? I quadruple checked my wifi ssid and password, and they’re fine, I had no issues with other esp devices connecting to my network before.

Any help is appreciated, thanks.