Tenda Beli pingable but unreachable

Im trying a rest switch for a basic plug. I gave it a static IP (the same as the one it always picks for itself - and also tried without this). It shows up online in the router page, I try pinging it from HA terminal and packets return ok, but ironically, the rest switch says it’s unreachable and so does ping from other places like cmd. Even tried nmap but that won’t reach it either. Tried Wireshark but I get lost in there. Tried to post with curl but still doesnt wanna. Tried reaching it in browser as well, timed out. Tried reaching it via Wireshark from the phone app which returns all packets when pinged on port 5000 (which is the same port that was recommended to me for use with a rest switch by someone who owns the plug and got it working but has since been unreachable)

Maybe someone can help me reach this darn thing? I’m noob with programming, don’t know syntax by heart but I do have experience with linux and some automation platforms. That just means I am a sleuth and can make stuff work from context so you can throw stuff at me, I will figure it out.

This is my rest config and the error from logs is No route to resource/endpoint: http://192.164.100.16:5000/
switch:

  - platform: rest
    name: TendaBeli
    resource: http://192.168.100.16:5000/setSta
    state_resource: http://192.168.100.16:5000/getSta
    is_on_template: '{{ value_json.data.status == 1 }}'
    body_on: '{"status":1}'
    body_off: '{"status":0}'
    headers:
      Content-Type: application/json

When the plug resets to factory settings it establishes an ssid with no password to which your phone connects and then you move it over to your own wifi. This is the command that can be used to do that and it seems to work physically but in cmd it returns a resp code 0 which I don’t know what it means.

curl -X POST http://PLUG-IP:5000/guideDone -d 
'{"account":"1","key":"YOUR-WLAN-KEY","server":"beli.intranet","ssid":"YOUR-WLAN-SSID"}'

Someone suggested client separation on the router (wired vs wifi) could be an issue but I don’t for the life of me know how to address that.
Can anyone think of anything putting all this together? It seems like a really simple thing even though I’ve been struggling with it for more than a week.

2 Likes

What’s the model of the plug?

What makes you think that it should be responding via port 5000?

Hi again, and thank you for the reply.
The model is Tenda Beli SP3, latest firmware, EU version.
I first tried to check which IPs were actively engaged, and this one was the only one that came back (apart from the ones I had already identified as being something else). I tried to ping its ip via the wireshark phone app on all ports and 5000 was the only one that returned anything. Also, 5000 is the port specified in a octoprint plugin that was set up to use the plug.

Also, someone over on the discord server had the same plugs and set up a rest integration for them, which is where I got the config from and just pasted in my local values (just the IP).

I finally managed to get it working, all I had to do was fiddle with the last setting that I hadn’t touched on my router: the beacon interval. As it turns out, it was set too low so the request would naturally time out before it had a chance to resolve. I tried to max it and after gradually reducing it til it no longer worked. Now everything good.

1 Like

Hey, thanks for this! I’ve been able to connect the SP9 plug to my Home Assistant thanks to this post. The SP9 also has power consumption measurement functionality. Does anyone know the REST api endpoint for reading that?

2 Likes

+1
Need the same API.

So I put your code in my configuration.yaml, replacing with my ip of course, and I get this error:

[state_resource] is an invalid option for [sensor.rest].
Can you help @chrisrosenkreuz23 ?

You need the IP of the device and the specific port it operates on.
Also, the error you’re getting seems to be related to templating, so might want to check the way templates are written for this particular context in the newer versions. Im running an older version of HA so I can’t help you there. RESTful Switch - Home Assistant
To my eye it looks like if you take out the state_resource line you’re good. Could be wrong though…

@rex_3 Sorry but I don’t know. If I were you I’d unpack the Tenda app and find the endpoint

I unpacked it some time ago. It didn’t change anything:

hello guys, I also have two Tenda Beli SP3 sockets, and I followed your guide which helped me a lot, only the sockets are easily connected to the home assistant, but the moment I press to turn them on, they immediately switch off, i.e. the The switch is like turning on and off at the same time, how could I fix this?

so you hear the click of the physical unit when you press it in HA and then another click shortly thereafter? if so, how far apart are the clicks?
to my ear it sounds like something to do with status polling

Yes exactly, I hear one physical click after another, almost instantly, maybe it all happens in a second.
What would Status Polling be?

I got most my stuff working with HA except Tenda Beli SP3. Read through this thread. I am confused. Does it mean you need first install OctoPrint and setup. the try connecting Tenda Beli SP3 to OctoPrint. Using HA octoPrint to control SP3 switch?

Where to put this kind of script in HA? Tried in configuration.yaml and checked it doesn’t recoganise “switch”.

I converted mine to ESPHome using Libretiny, has to be done via serial though.

no, the octoprint was an aside. This only has to do with the REST integration in ha.
what do you mean it doesn’t recognise it in configuration.yaml? I have mine exactly like that and it does. Newest ha ver.

See that the referenced device actually has that IP in your own network. Just look in the router page and set it a static one, then replace in yaml accordingly. You will probably need the mac address of the device, which is printed on its back

I’m sorry, I dunno how to address that. When I am at a loss and have no one to ask, I just ask AI. If that doesn’t help, I try the Discord channel of this forum.

I got them working now. detail steps see

I am glad to hear!