Wifi switch to control external device

Hello. Sorry if I am posting a repeat question or the wrong question. I don’t know the lingo very good so I am having trouble finding some answers to some questions I have.

This is what I have and what I am trying to do:

I have one ESP8266 set up with a relay (Fan Light) to turn a light on and off. This switch only works with Alexa or with HA dashboard, no physical switch. (Using Kapopappa GitHub)

I want to set up a second (different) ESP8266 chip with a touch sensor attached to it. Pressing button would toggle Fan Light off/on.

I have another ESP8266 chip setup, “LivingRoom”. To this chip I did add a touch sensor, so I can turn lights on/off with Alexa or with touch sensor. But this was easy since I can could control the actual pins on the actual board. On my new project I want to be able to turn on/off a relay on a different board all together.

Any advice or suggestions would be greatly appreciated

Connect them all to home assistant and control via automations.

can you give me better search words on exactly how I would do so. I know basic programming so I was able to add touch sensor on the same board.

I haven’t found a post for just a standalone wifi toggle switch with no relay attached

Do they support mqtt?

I am making the switch myself with an ESP8266 and a touch sensor. I think the ESP8266 does support mqtt if programmed right

I keep googling info but seems I am missing the correct keywords. When I google “wifi switch” I mostly get hits for things similar to the sonoff, which is an ESP8266 with a relay attached. I know there are different ways to set these relay’s/switches, some with mqtt, others with tasmota, etc.

All the instructions I find, show me how to set up the actual relay, and turn it on and off either with HomeAsssistant or with Alexa. What I am not being able to find is how to set up my own wifi “toggle switch”. I think main issue is me not having correct keywords to search as I am sure many have done this type of toggle switch before.

I know very little, almost nothing about mqtt, but if I understand correctly my wifi toogle swich would send an mqtt “on” request when touch sensor is touched, then mqtt “off” request when the toggle switch is touched again.

I have never used kakopappa’s software on an ESP Chip.

If you want to use MQTT for your switching why not look into an easy to use firmware such as the Tasmota one?

I did a post a while ago about two way switching like we have for wall switches in the UK.

I am about to play with Tasmota right now maybe while playing around with it I will find a solution.

I am so new at this that much of the lingo throws me off. I don’t know what mqtt is, and the other formats that HA supports.

Let me explain my set up better, and perhaps someone can give me suggestions.

At the moment my girlfriend and I live on different houses, but we share the same internet connection. Basically we are on the same internal network.

When I first started to play around I though I HAD TO HAVE Home Assistant in order to make the lights switches work with Alexa, but I just realized that is not the case.

My PERFECT toggle switch would work even if there is no internet connection (only local network), and no HA installed.

The way I set up my relays so far, they work with Alexa even if HA is off, and if I lose internet connection Alexa doesn’t work, but I can still use the touch sensor to turn light on and off. (touch sensor is connected directly to the chip)

I would love same outcome as above, but with my toggle switch on a different chip. Basically what I need to replicate are the commands that Alexa sends into the network to turn relay on and off.

Tasmota supports emulating Hue Bridge.
You will probably struggle long term to have items to work with Alexa with no HA (Without internet even more so). Especially once you get into more complicated devices than a switch or light.
I would concentrate on having HA working all the time compared to relying on a cloud based device such as an Alexa.

You are doing right though having physical switches in case you loose internet.

MQTT is a communication layer that allows many devices to communicate with each other and HA. It can be fully self hosted so not reliant on the internet and cloud devices.

Thank you for the suggestions. I should add that I am a bit tech savvy, but my girlfriend isn’t. Our relationship is somewhat rocky at the moment.

I definitely plan to run a hass.io on my raspberry pi, and take advantage of the so many toys like senors, routines, etc. Alexa would just provide the “voice” part of the equation, but HA would run the rest.

The toggle switches I want to set up at my girlfriends house. I know I need at least two, but she might want a third one. I have done a bit of cable work at her house before and know I wont be able to run wires on some conduits which is why I will need a separate wifi toggle switch.

If we do end up braking up, I know for a fact she won’t maintain a HA, she wouldn’t even want to fork out the $50 for the raspberry pi, case, card, etc.

For xmas, she is getting two echo spots and her daughter is getting another one. So I want to set it up so that she can still continue to use Alexa to turn lights on and off even if we break up and she has no HA. And since Alexa only works with internet, I have to set up some manual way to turn lights on and off.

I know very little, almost nothing about how all this technology works. But it seems that when I ask Alexa to do something it take my input, sends it to Amazon server, then Amazon server sends a reply to the Echo dot to send some type of command (payload?) onto my local network.

I want to replicate the last part, the part that Echo sends onto the local network. I understand if my local network goes down (the router dies) these switches would stop working.

One live example. The stair case lights. Upstairs would have the main touch sensor connected to the ESP8266 with the actual relay. Downstairs I would use the special touch toggle switch with another ESP8266. If network went down, upstairs touch switch would still work, but downstairs wouldn’t.

Perhaps you could look at the Sonoff T1 range for wall switches?

I personally would re-flash them with Tasmota.
But in stock form you can use them with Google or Alexa and still control them with HA either through the Tuya integration or IFTTT

Them wall switches do need Neutral feeds though.

If you don’t want ha installed why are you even here?

1 Like

nickrout you are totally right! At one point I noticed that if I don’t want them to depend on HA then the HA might not be the best board to be asking. I was going to mention it but figured why make my post lengthier.

At the moment we are like “one house” even though our homes are not physically together. On my end I do totally want to take advantage of HA. Extremely disappointed I can’t do port forwarding. I will do some more research but seems I will have to get on the $5 per month plan and use hass cloud as many of the toys I am interested in require me talking to HA from the outside.

For those 2 or 3 special wifi switches at my girlfriends house would be nice if they worked with HA as well, but priority would be for them to work without HA as well. So it is not a HA specific question but it is around the same area of knowledge. Hopping someone knows the code well enough (as obviously I don’t) and can tell me at least what protocol it uses so I can then start getting closer to my answer.

For my xmas present I got a handful of parts from Aliexpress and paid DHL to get them. Factoring in shipping, I got my ESP8266s for about $2.40, shield 1 ch relays for like $.70, etc. Seems most things I want to build would add up to under $5. Here in Mexico I can’t get anything already made for less than $15 plus shipping. I have little money but mucho time!

I am still working on getting tasmota set up on a chip and do some testing.

So I got Tasmoto working, I seem to like it a bit better than how I was flashing my ESP8266 before. Anyhow I can’t seem to figure out to do what I want to do, in fact I haven’t been able to find anything via google of someone else trying to do something like I want to do.

I can create my own poor mans Sonoff T1. In fact I already have one set up like that, with the touch sensor to turn on and off physically. The Sonoff T1s have relays.

I want to create a wifi switch that will control a relay it is not physically connected to, and I can’t believe no one else has done this before.

I gave you an example on my first post on how to do this using MQTT

Also read up on the KNX Features on the Tasmosta Wiki again there are examples.

I’m not sure why you said that. EVERYBODY is doing that. This pretty much is literally the definition of “home automation”.

You have a wifi enabled relay. You have a wifi enabled switch You have Tasmota flashed on both of them. You have HA installed and running. The only other thing you need to put it all together is to install an MQTT broker.

There are instructions on the HA site to tell you how to do that.

thank you both Wills and Finity.

Wills first time I looked into your post I didn’t think it applied to me since I thought they were grouping two relays. Since then I have done more reading and understand a bit better. I will spend today reading and playing with KNX. Quick reading it seems promising as it seems devices can talk to eachother without a “hub” which is what I am looking for.

Finity, it seems no one has coined a term for this type of device. All the “switches” and “button” examples I’ve found seem to have the relay attached, where once the switch was toggled the code ends up turning a pin on and off. I haven’t found any code that tells the ESP that when the switch is toggled it should turn on/off a pin on another device.

I do appreciate all the help

No no no. The switch should post an mqtt message. HA listens to mqtt and runs an automation. The automation posts an mqtt message to another topic. The second device listens to that mqtt topic and turns on, or off, or whatever.

Yes KNX looks very interesting. I am considering trying it out on some of my lights especially my 2 way switching lights.
Like you mention it does’t need a “Hub” to function. As long as your switches are on the same WiFi network as each other they will talk to each other, so not reliant on HA or a MQTT broker.
You can still control them with HA though so you can still use them with automations etc.

So I stand corrected! Seems what I would like to do is referred to as a 2 way switch or even a 3 way switch. Using 2 way switch as part of the keyword search did give me some good info. So far this video is the one that explains it the best! https://www.youtube.com/watch?v=jz6sX2f5jjQ I FOUND! my solution, since the way it is being done on the video the code runs on the actual ESP chips, so no HA or internet connection is required! Exactly what I was looking for! As usual the key was in having the right key words to google!

I do appreciate all of your input, and main kudos go to Wills! Reading up on KNX quickly got me to the one video I linked!