Sonoff SV Air Conditioning Control Project - Currently Failing Miserably

Hi Guys

I’m a newbie to Home Assistant - inspired by Dr. Zzs videos (thanks man!). BUT - I need some help from the Genius Community here.

I’ve purchased a sonoff sv to control my AC from Home Assistant (HASSio).

What I’ve done so far:

  • Set up HASSio on Raspberry Pi 3

  • Set up MQQT, SAMBA and Configurator via HASSIO (all are showing with green jig-saw pieces anyway)

  • Flashed my sonoff SV with Tasmota and can toggle the switch on & off from the Tasmota home page

  • Removed the two resistors from the sonoff SV to allow for an external power source so I can use my sonoff as a volt free relay

  • Tried and failed to write some YAML to do what I want to do with my AC unit - in fact I haven’t been able to get Home Assistant to communicate with my sonoff at all (after about 6 hours of failure after failure - I really suck at this)

What I want to do is shown in the attached diagram that I’ve drawn up. Essentially:

  • turn on and off my AC controller by soldering across the on/off switch. This will need the sonoff to short
    these contacts for ~200ms (tested with some wire and that works)

  • Get feedback from the AC fan coil to check if the AC is actually on or off - via GPIO14 and GND.

Does anyone have a similar YAML code they wouldn’t mind sharing? Also, information on how to configure Tasmota and the switchmodes etc. to work with this? I tried Dr. Zzs garage door code and it just hasn’t worked for me (it has an up, down stop button on HASS, but even using that I couldn’t speak to my device). I’m almost at the stage where I’d give up on the feedback portion just to get it working.

Any help would be greatly appreciated!

Cheers
Blue

Apparently this is an issue with the current version of HASS.IO

Back to your issue…

Have you confirmed that both HASS.IO and your Sonoff can talk to the MQTT server ?
If not, and youre running Chrome browser, install MQTT lens from the Chrome Web Store and you can connect your MQTT server and confirm if everything is OK on that side of things.

It might also be helpful if you post your yaml for the MQTT server setup and your sonoff, and the MQTT setup on the Tasmota side

Thanks jivesinger,

This is where it get a bit beyond me - looks so simple in the videos!

In my tasmota console I’ve configured:

switchmode 1 0
switchmode2 1
switchtopic2 2

in my configuration.yaml I have:

mqtt:
broker: localhost
port: 1883
client_id: hassio
keepalive: 60
username: redacted
password: redacted
protocol: 3.1.1

#and because I have given up on the feedback component for now:

switch:
platform: mqtt
name: “AC Switch”
command_topic: “cmnd/sonoff/POWER”
state_topic: “stat/sonoff/POWER”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true

I installed mqqtlens, but honestly, no idea what to do with it.

Cheers!

also - in the mqqt i actually have “redacted” for username and password. I didn’t set one up I don’t believe so I’m not sure if I can put nothing in there? I just copied this from another forum post where the MQQT wasn’t working and where home assistant was telling me it didn’t understand my request for mqqt. It now does, but it just doesn’t work. That might be the root of one of the issues I’m having.

If you are not using username or password, I’d delete those lines completely from your yaml

With MQTT lens, start by adding a new connection, give it a name, enter the IP address, everything else can probably stay as default.
Click save, then the play button.

If all is well, it will connect and the play button will turn into a pause button.
If there is a problem, it will keep trying to connect and turn from play to pause and back again.

thanks for your help jivesinger but lens won’t connect to the ip address I use to connect to the Tasmota page

The IP address entered into Lens should be the IP of your MQTT server.
In your case, as you’re using the built in server in HASS.IO, it will be the IP of your rasPi
Leave the port at the default 1883

Yep - that worked!

Hmm, I’ve just fired up Lens myself to guide you through the next step and it appears to be broken.
The icons are so big you cant see the publish and subscribe sections.

Is yours the same ?

No I can see them on version 0.0.14

(I also used the username and password for my raspberry pi on mqqtlens, which I now realise was probably a mistake not to put these in my configuration.yaml file? I added them in, but unfortunately it hasn’t made any difference)

When you installed and configured the MQTT server in HASSIO, did you specify a username and password ?
If not, you don’t need one in any of your configs ( config.yaml, Lens, Tasmota )

This is my HASSIO add on:

No username and password. But I deleted the username and password for my raspberry pi from mqqtlens and now it constantly cycles between “connected” and “disconected”

I feel like I need this password/username now?

I also haven’t touched the standard Tasmota configuration (i’ve actually just restored it to defaults so I don’t have any switchmodes or switchtopic modifications in case this was the issue)

sorry mate - scratch that. I deleted the connection on mqqtlens and started again without a username or password and now this works (no cycling - stays connected)

I got the mqqt to work between the sonoff and hassio!

I changed the MQQT settings on my sonoff to my raspberry pi’s IP address with no username or password and all works! albeit a little bit buggy/intermittent

Now I just have to figure out how to configure the switchmodes and write the yaml code I need for my AC

Awesome !
So now in Lens you should have a Subscribe and Publish section.

In the topic box type “/test” and then hit the Subscribe button

Go to Home Assistant and under Developer Tools there is an icon which when you hover over it, it says ‘MQTT’
Click it !
In the ‘Publish a Packet’ box under ‘topic’ type ‘/test’
and under ‘Payload’ type ‘Boo!’ and hit the publish button.

What happens in Lens when you hit the Publish button in Home Assistant ?

Thanks for you continued help with this.

I followed your steps and in home assistant it said message published/sent (can’t remember which)

on MQQTLENS I recieved the message: Boo!

I’m pretty sure the MQQT part is working A OK now!

I can’t see the sonoff’s IP address anymore though, nor can I access the tasmota homepage as a result. Is this normal?

****Also, I’m told I’ve reached the maximum number of replies in a 24hr period on this forum :frowning:

Congratulations !

You just proved that your MQTT server and Home Assistant are connected and talking to each other.

Now for the tricky bit. I know NOTHING about Tasmota. I use ESPEasy on my Sonoffs and ESP’s.

I did hovever find this :

Which might help you.

But from looking at your Tasmota screen shot above, you will need to change Host to the IP of your MQTT server ( rasPi ), leave Port and Client, delete User / Pass.

For simplicity’s sake delete %prefix%/ from Full Topic so that you are left with %topic%/ and hit save.

You may need to restart the sonoff for the changes to take affect

Just read your edit re: max posts.

Check your messages :slight_smile:

Mate, im trying to achieve something similar - I cant even get the Sonoff SV to flash! any tips on how you achieved it as non of the tutorials seems to work for me