Non-Flashers rejoice! There’s a custom component for Home Assistant that lets you use Sonoff Devices without changing the firmware, and best of all, it doesn’t use the cloud either :0
Let me give you 2 min of DIY smart home history. Way back in 2017 Sonoff made the cheapest smart switch (they still do). When other switches cost $30 the Sonoff Basic was only $5. The problem was, you could only use it with their app. Until geniuses like Theo Arends (He’s the TA in TASMOTA) started writing new firmware for Sonoffs that would allow these $5 switches to be used with a whole host of different smart home hubs, including Home Assistant. The process for flashing Sonoffs with new firmware has been easy for some people, and not so easy for others. Countless hours have been spent across the world fidgeting with jumper wires, grounding GPIO-0 and sorting out espcomm errors. That’s all over now! Okay, maybe that’s a little too dramatic, but it is fair to say that if you’ve been struggling to flash your Sonoffs, relief is here!
I gotta give the Sonoff folks some credit. They listened to their customers who wanted to have more control over their devices. In 2019 they included a local area network option for controlling their devices. They didn’t really communicate very well how it worked though so it wasn’t very accessible to most of us. There have been a couple components for Home Assistant that allowed you to use Sonoffs without changing the firmware. I’ve had mixed success with them, until now.
This guy AlexxIT, has made a beautifully simple custom component that sets up your Sonoffs to work in HA without using the cloud. I verified that once you have your non-flashed sonoffs setup this way, you can totally disconnect your house from the internet and they will still be controllable through HA. Are you excited now? Good, you should be! Let’s go through the setup.
The Hero of the Day is AlexxIT. This is his work, so give him a high five when you see him on the street. Or buy him a coffee on github.
All the instructions are on this Github page: https://github.com/AlexxIT/SonoffLAN
- Install Home Assistant Community Store
- Quick demo on how to do that
- Jenny’s video – https://youtu.be/7HXFaD_ZLec
- On the HACS settings page, under Custom Repositories, put AlexxIT/SonoffLAN and for Category select “integration”
- Go to Integrations and search for SonoffLAN
- Select it and Install it
- Restart Home Assistant
- Now we have to get the API_KEY for each of your sonoff devices.
- Alex describes a way to do that without connecting to the eWeLink app
- If you’ve already connected your sonoffs to the ewelink app that method might not work, at least it didn’t for me.
- Setup your Sonoff Device with the eWeLink App
- Put the email or phone number you used and your password in your secrets file
- In your configuration.yaml:
- There are other options
- reload: When HA restarts it’ll connect to the itead servers and get info about your devices. It puts that info in a file called .sonoff.json
- If you want it to retrieve info about new devices every time HA restarts you can make this “Always”, otherwise it’ll only do it once. If you add more devices, delete .sonoff.json, if that file isn’t there it will connect to the sonoff servers and download the information again.
- Once that file is created you can delete your user and password if you want. The component doesn’t need to connect to the sonoff servers ever again as long as that .sonoff.json file is there.
- There are other options
- Check the config, and restart HA
- Go to States page and search for switch.sonoff-xxxx
- Customize it how you want, add it to the UI, make automations etc.
There are some more options and specific examples on Alexx’s github page.
That’s it! You’ve got control of your sonoff device in HA, without flashing and without the cloud!
My new little sonoff micro that I was all sad about not being able to flash, is now working with HA without ever connecting to the Sonoff servers. How great is that!?!
I expect I will still flash Tasmota on at least some of my Sonoff devices. I like to add other functions like Temperature & Motion Sensors. You can’t do that with the stock firmware. But if you’re not planning to add any other sensors to the device, you certainly don’t NEED to change the firmware anymore. Thanks Alex!
In the near future Alex is planning to:
- add this component to the official version of HA
- Also need to rewrite the component for asynchronous mode.
- Also I planned to try to keep a constant connection to devices. Some users experience device discovery issues after restart HA.
If you speak russian Alex also has a blog about smart home stuff: https://sprut.ai/client/blog/2308
There are other options for Local control of sonoff devices: