I am new to the Home Assistant community but I am excited with all its capabilities! However, I am at a little hiccup.
I have a Pi with Hass.io installed. I also have 2 sonoff switches that I flashed to Tasmota. However I can’t get the Sonoff Switches to work on Hass.io. Every time I add the config for the switches on the configuration.yaml file the Pi crashes. I’ve tried using many different configurations to add to the switches on Home Assistant.
Based on what I’ve read throughout many forums I assume it has something to do with MQTT not being used correctly. I’ve installed MQTT though Hass.io and added "mqtt:"on the config.yaml file since I am only hosting the MQTT locally.
Any tips on what I am doing wrong? Any tips would be awesome!
Awesome! I made those changes but I an still unable to add my sonoff switches, When adding the sonoff info into the config file I get this when I reboot Home Assistant
"Invalid Config;
The following components and platforms could not be set up:
state_topic
platform
command_topic:
payload_off: “OFF”
optimistic
name
Show links to resources in log and frontend
introduction:
Enables the frontend
frontend:
Enables configuration UI
config:
http:
Uncomment this to add a password (recommended!)
api_password: PASSWORD
Uncomment this if you are using SSL/TLS, running in Docker container, etc.
base_url: example.duckdns.org:8123
Checks for available updates
Note: This component will send some information about your system to
the developers to assist with development of Home Assistant.
For more information, please see: https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
Optional, allows Home Assistant developers to focus on popular components.
include_used_components: true
Discover some devices automatically
discovery:
Allows you to issue voice commands from the frontend in enabled browsers
conversation:
Enables support for tracking state changes over time
history:
Ok so that’s for the Hassio Config and MQTT broker add-on parameters, but what would we need to do in the actual switch device config (a Sonoff S20 in my case) ?
The switch has these MQTT settings available via it’s web interface.
Yes Bruh Automation was one of the 20 or so I watched on Sunday about HA, Hassio and MQTT. I think the problem for me is that I expected MQTT principals to be easy to understand in plain terms, and on the surface they look simple (any MQTT network diagram looks very simple on screen) , but as I know very little of Python or any scripting languages at all I have struggled to understand the odd terms I see dotted around the configuration at the clients and the broker.
I consider myself fortunate to muddle through the Raspberry Pi HA and Sonoff S20 firmware installs successfully at all really given this is the first Pi thing I’ve ever done.
Today I found these tutorials and I understand better some of the names and terms others found ‘easy’. It seems to me with the info I found today I need to start configuring at the publishing client end first, maybe that will make more sense… https://www.hivemq.com/mqtt-essentials/
I avoided MQTT for ages because I didn’t understand it, then decided to have a go and just take everything at face value and then discovered how stupidly easy it was to set up and use, particularly thanks to the way it’s been built in to HA so you don’t even have to see any of the workings.
Don’t bother to try and understand, just copy and paste from the likes of Bruh and others, tweak to your needs and then you’ll see why people say it’s easy.
The problem is you stopped following the guide before you had it working, the Sonoff has no idea what it’s talking to and I’ve already got you going with the differences in hass.io so if you stuck with it you’d be fine. You’ve started ad-libbing with the names and topics with no idea what they related to is what’s messed you up.
Go back to basics and paste this into your config…
If you followed Bruh’s guide without messing your Sonoff should already be subscribed to the topic ‘sonoff’ and have the MQTT settings sorted with your Pi’s IP and username/password if you set one up in the MQTT add-on, restart HA and it should magically work, if you’ve messed with anything else it may not!
When you have it working you can start changing things to suit your set up. Essentially that would just be the ‘name:’ which is whatever you want to refer to your device as elsewhere in HA and ‘sonoff’ in both of the topics to something else if you have more than one, then just change the ‘topic’ in the MQTT set up to match. Most people just add a number on the end as all the guides say. Leave everything else alone!
Got to love the ‘magic’. At that point I’d not messed with anything related to MQTT, however that changed now…
I tried your suggested switch: device block above, did a copy and paste into configuration.yaml and restarted HA via browser.
This stops HA from working after a restart (and a long long wait for that restart to finish), so I have to rip it out of the config again to get back to where I was. Tried three times to be sure of it.
(SAMBA is still running so I do have access via Windows File Explorer thankfully).
Not sure why your block fails, syntax seems OK to me.
Doing more reading here about the Sonoffs:
Of the many things that puzzle me is host and broker ‘domus1’, as I don’t or didn’t see that as a setting in hassio config for addon MQTT.
If you’d followed Bruh’s guide you would’ve replaced domus1 in the Tasmota MQTT config with your Pi’s IP before flashing!
Regarding your errors in your config yaml, obvious thing to try would be type the correct topics over the top of your incorrect ones, then you’d guarantee the context is OK.
If you’re going to follow a guide it’s a good idea to actually follow it so then it should be quite easy to track down what’s wrong if it doesn’t work
In my defence I think I used Bruh’s guide to hass.io installation and then adding MQTT and I think I then used Tasmota guide to the Sonoff firmware. I reckon I watched Bens guide to MQTT and Owntracks on Sunday but don’t recall ever seeing him talk about Sonoff firmware in relation to MQTT and what the critical settings to match in both are (have you seen the array of videos he’s produced, the list is overwhelming for a somebody on day one or two of home automation creation).
Anyway, see how I go as these little bits of info fall into place…
No probs, should hopefully fill in the basics you were missing.
As I’ve said to others, it’s best to take everything at face value with this until you’re up and running, then it should become clear what’s going on and you can adapt accordingly. Saves all the pain
Hey, I’ve read about 10 different forum messages and still haven’t been able to figure out why my HA doesn’t see that a sonoff switch is on (I can go from off to on, and after a second it’ll jump back to off even though the switch is on)