makermusings / fauxmo

Emulated Belkin WeMo devices that work with the Amazon Echo
MIT License
525 stars 176 forks source link

echo dot can't find devices python 3 / Kind of working code end of 2022 #40

Open justvam opened 1 year ago

justvam commented 1 year ago

Alexa doesn't seem to find fauxmo, I tried changing model number to 1.0 in xml. I tried replacing urn:Belkin:device:** in if data.find(b'M-SEARCH') == 0 and data.find(b'urn:Belkin:device:**') != -1: with upnp:rootdevice instead of urn:Belkin:device:** because when I use urn:Belkin:device:** fauxmo doesn't responses at all.

Entering main loop                                         

Responding to search for office lights
Responding to search for kitchen lights
Responding to setup.xml for office lights
Responding to setup.xml for kitchen lights
Responding to search for office lights
Responding to search for kitchen lights
Responding to search for office lights
Responding to search for kitchen lights
Responding to search for office lights
Responding to search for kitchen lights

and then alexa says that she can't find anything.

maybe it's because of

message = bytes(message, 'utf-8')
socket.send(message)

and

message = bytes(message, 'utf-8')
temp_socket.sendto(message, destination)

but if I send it directly without bytes() than it gives me error a bytes-like object is required, not 'str'

same for data.find('stuff') If I don't make it data.find(b'stuff') then I get argument should be integer or bytes-like object, not 'str'

code:

fauxmo.zip

justvam commented 1 year ago

I was figuring this out from 8 am, now it's 3pm.

I finally fixed the code and connection works.

now I need to fix the turning on and off;

Here's the code:

fauxmo.zip

justvam commented 1 year ago

I fixed everything now, Here's the fully working code, (At least for me it works perfectly) I would create pull request if I wasn't lazy (And also I don't know how to do it properly), so I will just keep this issue opened.

fauxmo.zip

strunker commented 1 year ago

I fixed everything now, Here's the fully working code, (At least for me it works perfectly) I would create pull request if I wasn't lazy (And also I don't know how to do it properly), so I will just keep this issue opened.

fauxmo.zip

So weird because I was literally JUST trying to update this to work with Py 3+ and I ran into this exact same error. And while I am no longer receiving the error, using your code, the devices are still not getting discovered for me sadly.

image

justvam commented 1 year ago

@strunker try replugging echo dot (it actually helped me) and try at least 2 times to discover devices without restarting the script. Sometimes alexa just sends different requests. I've left in the code something like #dbg("Responding with: " + str(message) + "\n") and #dbg("Receiving " + str(data) + "\n")

basicly uncomment every dbg()

Alexa should send something like this:

image image

strunker commented 1 year ago

@Vamaka12 so I actually do see replies but the switches dont ever seem to get discovered by Alexa. You can see on the right side. Am I doing something wrong there? All I should have to do is simply scan for them after starting up fauxmo right? image

justvam commented 1 year ago

@Vamaka12 so I actually do see replies but the switches dont ever seem to get discovered by Alexa. You can see on the right side. Am I doing something wrong there? All I should have to do is simply scan for them after starting up fauxmo right? image

Yup you just have to simply scan for them after starting up fauxmo and it looks like you didn't uncommented all dbg(), can you uncomment all of them please?

After echo dot get's setup.xml it should respond with this image

I was stuck at the same problem you have now. Here's last things that I did after which it started working:

After I replugged I waited untill the blue light turned off and tried searching for 2 times (on second time it worked).

first time I searched through app, and second time I tried asking "Alexa, find devices"

so, check that you can open setup.xml in your browser, add wemo skill to alexa app and replug echo dot.

strunker commented 1 year ago

@Vamaka12 so I actually do see replies but the switches dont ever seem to get discovered by Alexa. You can see on the right side. Am I doing something wrong there? All I should have to do is simply scan for them after starting up fauxmo right? image

Yup you just have to simply scan for them after starting up fauxmo and it looks like you didn't uncommented all dbg(), can you uncomment all of them please?

After echo dot get's setup.xml it should respond with this image

I was stuck at the same problem you have now. Here's last things that I did after which it started working:

  • I checked that http://192.168.0.143:54001/setup.xml and http://192.168.0.143:54002/setup.xml (for you it's http://10.1.1.238:54001/setup.xml and http://10.1.1.238:54002/setup.xml) was opening in browser while script is running
  • I was changing SETUP_XML multiple of times (I spend 1-2 hour on it didn't helped, last xml which I am using is already in code)
  • I added "Wemo" skill to alexa app (you need to create wemo account and link it)
  • And then I replugged echo dot

After I replugged I waited untill the blue light turned off and tried searching for 2 times (on second time it worked).

first time I searched through app, and second time I tried asking "Alexa, find devices"

so, check that you can open setup.xml in your browser, add wemo skill to alexa app and replug echo dot.

So I uncommented the last of the dbg() My responses look differe than yours, I never see any posts? I also can reach in browser. I downloaded the mobile app setup a new account, unlinked relinked the alexa skill as well, still nothing for me.

There must be something else going on for me though becaus ethere is a new maintained python 3 version of this, you can find it below. And that doesnt work for me either. You may find it of interest though so linking it here. The xml that generates is entirely different from the one this project generates. In either case neither are working for me sadly.

https://pypi.org/project/fauxmo/

image image

justvam commented 1 year ago

@strunker I don't have any ideas other than that I send you the wrong code (Could be a possibility, sorry if that's the case)

I don't think that it will change something but still try this one: fauxmo.zip

for me it looks like that with the exact code that I posted above: image

Just in case I use python 3.10.4

Also I've tried https://pypi.org/project/fauxmo/ but I just couldn't get it to run

strunker commented 1 year ago

@strunker I don't have any ideas other than that I send you the wrong code (Could be a possibility, sorry if that's the case)

I don't think that it will change something but still try this one: fauxmo.zip

for me it looks like that with the exact code that I posted above: image

Just in case I use python 3.10.4

Also I've tried https://pypi.org/project/fauxmo/ but I just couldn't get it to run

Thanks for trying to help, and yeah it seems to be the problem for me that I never get anything back from the echo device. I have my firewall turned compeltely off on this machine, and turned off my sec product so cant imagine the incoming port is being blocked. I can also browse the .../setup.xml file from a different computer, not just locally to this machine, which indicates there isnt a port issue. Just odd, I never get the Post back, which I asume comes from the echo? As some type of acknowledgement that the switch was added? What do the switches look like in your Alexa app?

justvam commented 1 year ago

@strunker

You're welcome, The first Post you recieve after setup.xml is to get current status of the switch/plug and I guess it also works as a confirmation. image

Sure: image image

If you will find any solution you can write it here, will be interesting to read how you fixed it.

strunker commented 1 year ago

@strunker

You're welcome, The first Post you recieve after setup.xml is to get current status of the switch/plug and I guess it also works as a confirmation. image

Sure: image image

If you will find any solution you can write it here, will be interesting to read how you fixed it.

Interesting so they show up as smart plugs then not switches. TY again.

c240amg commented 9 months ago

I've forked this repo and have added your code @Vamaka12 so that we can see the differences in a PR.

I've had issues with my belkins, as they only seem to work with a 1st Gen echo device. My 2nd/3rd/4th gen devices don't recognise them at all...

justvam commented 9 months ago

Sure, feel free to do anything with the code. I git cloned your fork and it works, out of the box.

Never had belkins, and I only have a single gen 4 echo, so can't really help you with that.