I would like to configure a smart plug so that it can be turned on and off from a remote website or app, similar to how most retail plugs, like Kasa, work, but managed from a custom website or app. I will not be able to alter the router, open up ports, or set up a VPN. It should be plug and play, directly from the smart plug. Ideally, someone would create an account on some website, plug in their smart plug and connect it to their wifi, add the unique ID for the smart plug to their account, and then be able to control it. I understand that what I described would not be secure, but I would add security in different ways.
The solutions I’ve seen in other discussions all seem to be focused on pulling data from the smart plug using MQTT or Telegram, rather than pushing requests to the smart plug. Here are a few of the discussions I’ve seen:
Thank you, but I should clarify that I am not looking to control my own smart plugs. I want to provide smart plugs to other people and they should be able to connect that to a centralized website which would then have the ability to turn them on and off. So for something like that, a separate paid service may not work.
Not really sure at what level the question is.
Are you looking from COTS smart plugs that can be flashed with ESPHome, so that you could create the firmware doing what you describe?
Or are you a step further, having the plug, and asking for the code?
What is the use case, btw?
Are you creating a business trying to mimic Tuya but even more locked ?
Are you looking from COTS smart plugs that can be flashed with ESPHome, so that you could create the firmware doing what you describe?
I’m still researching and haven’t built or purchased anything yet, so the next step is creating a proof of concept. If ESPHome is able to do what I need (i.e. be controlled remotely and track energy usage) I was planning on buying a smart plug with pre-flashed ESPHome.
Or are you a step further, having the plug, and asking for the code?
I am asking for the code or a suggestion for a platform that I could build on top of, that I could use to remotely control a network of smart plugs from a custom app or website. I am currently looking into Nabu Casa webhooks (as @nickrout mentioned), but not yet sure if one centralized Nabu Casa account can be used to manage many smart plugs.
What is the use case, btw?
This is just the research stage, so it could still go in lots of directions, but one idea is to build a network of electric vehicle charging stations powered by outdoor outlets in homes and businesses. EV owners could then see a map of available charging stations and unlock the chargers from an app. If anyone is interested in talking about it, send me a message.
Thank you for the suggestion. I think that would work if I wanted to manage my own smart plugs remotely, but in my case, I will be providing the smart plugs to other people that will then connect to my network, so asking them to set up a port-forward would not work.
If you flash a smart plug for this purpose you could use the HTTP request to have their device call your API server regularly, this eliminates the need for them to open ports. I don’t know all the ins-and-outs of your project, or if you are going to be hosting a server or not, but if so then this would be one way to do things. It also depends on how rapidly you need to toggle their device for them.
If you flash a smart plug for this purpose you could use the HTTP request to have their device call your API server regularly, this eliminates the need for them to open ports.
Thank you, that’s a clever solution
I don’t know all the ins-and-outs of your project, or if you are going to be hosting a server or not, but if so then this would be one way to do things.
Yes, I would be hosting a server that the smart plug could ping.
It also depends on how rapidly you need to toggle their device for them.
This could be an issue as well as the scalability of the HTTP requests as the network grows, but this could be a good interim solution (and probably safer than the network directly connecting to the plug)
As a developer, and a lot of that is web technologies, having the end device poll your server is pretty standard so you aren’t opening ports. You could have it hit your server every second if you wanted but you’ll need a beefy ESP device so that doesn’t impact their own ability to use it. As for the server, this kind of request is so tiny it would take many thousands of simultaneous requests to really have a significant impact on your server.
It could be as simple as you set a value in the database and the API request just reads if it needs to go on or off. If it’s checking every 5-10 seconds then that’s your delay.