Adding Sonoff Basic R2 flashed with Tasmota to Home Assistant
I used a couple Sonoff Basics to automate my Christmas lights this year. I setup a few automations based on how we wanted them to turn on and off. We are going to walk through manually adding a Sonoff Basic R2 flashed with the Tasmota software without using auto discovery. Then we will setup a basic automation. If you haven’t already flashed and configured Tasmota you might want to checkout my article about that first.
Switch Template:
The template is pretty straight forward, and you can reference the docs for adding an MQTT Switch and all the different configuration options that are available. You can copy the template below into config/configuration.yaml.
This switch template is assuming you used the same topic formatting in my other article. Be sure your topics match what you configured in the Tasmota web ui.
The Automation
This automation will turn on the lights in the morning around when I get up, then shut them off again around work. They then come on at night and shut off around bed time.
If you were using this automation for outdoor lights you might want to use the trigger for sunrise and sunset.
trigger:
platform: sun
event: sunrise
Wrapping Up
All thats left to do at this point is to check the config, and if there are no errors then restart Home Assistant. In the left nav click on Configuration and then Server Control. You’ll see this screen.
Once you’re here click the Check Config button and give it a minute. You should see a Configuration valid message. If not you will see errors telling you the lines that have the issue.
After the configuration is validated, click the restart button down at the bottom to restart Home Assistant.
Now you’re set to go with some automated Christmas lights.