Giter Site home page Giter Site logo

fauxmo's Introduction

fauxmo

Emulated Belkin WeMo devices that work with the Amazon Echo

Visit this Maker Musings article to learn more about using this code to integrate the Amazon Echo with your own home automation.

Summary

The Amazon Echo will allow you to control a limited number of home automation devices by voice. If you want to control device types that it doesn't know about, or perform more sophisticated actions, the Echo doesn't provide any native options. This code emulates the Belkin WeMo devices in software, allowing you to have it appear that any number of them are on your network and to link their on and off actions to any code you want.

Instructions

All of the code to make it work is contained in the single file, fauxmo.py. It requires Python 2.7 and standard libraries. The example handler class that reacts to on and off commands uses the python-requests library, but could be replaced with code that does the same thing in many different ways.

Copy the fauxmo.py file to your server and edit the FAUXMOS list for the device names you want and the URLs to invoke for on and off commands for each one. You can execute it simply as ./fauxmo.py. If you want debug output, execute ./fauxmo.py -d. If you want it to run for an extended period, you could do something like nohup ./fauxmo.py & or take extra steps to make it run at startup, etc.

Note: unless you specify port numbers in the creation of your fauxmo objetcs, your virtual switch devices will use a different port every time you run fauxmo.py, which will make it hard for the Echo to find them. So you should plan to either leave the script running for long periods or choose fixed port numbers.

Once fauxmo.py is running, simply tell your Echo to "Find connected devices". You can also do this from the Echo App web page.

Related

fauxmo's People

Contributors

jgstew avatar makermusings avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fauxmo's Issues

fauxmo does not handle GetBinaryState

Recently Alexa started sending GetBinaryState soap actions both before and after SetBinaryState actions to confirm the result of SetBinaryState. Without it she claims the target is not responding.
Adding the code to handle the request is really easy. I have already done it, but I don't have permission to push changes to this repo (and honestly I don't know how to do it properly. I use SVN for my projects) I'm attaching the new fauxmo.py.

fauxmo.zip

16 device limit?

Thanks for putting this on GitHub and the blogs about it. Do you know if the 16 device limit is still the max amount of WeMo the echo can detect or has that been expanded?

device description

Is it possible to change the device description? I was able to change the main device name, but in the description (in the devices list of alexa) there is still "WeMo Switch".

Failed to initialize UPnP sockets

I also posted this issue on n8henrie's branch but thought I would try here as well in case anyone has encountered the problem with this version.

When I run fauxmo, I get the error shown below and then Echo does not discover any connected devices. On the other version, it shows a little more info; i.e., the error is errno 48 Address already in use. I've tried rebooting and netstat does not show my server listening on port 1900 (assuming that is the port with the problem). Any thoughts? Thanks.

--Dave

./fauxmo.py -d
Failed to initialize UPnP sockets:
got local address of 192.168.0.xxx
UPnP broadcast listener: new device registered
FauxMo device 'family room light' ready on 192.168.0.104:50509
UPnP broadcast listener: new device registered
FauxMo device 'hall light' ready on 192.168.0.104:50510
Entering main loop

fauxmo devices go offline after first request

fauxmo set up with different WeMo switchdummies.
Alexa App finds them all.
Once i ask Alexa to interact with the devices they go offline and Alexa says that the switch is not responding.
fauxmo log:
pi@raspberrypi:~/fauxmo $ ./fauxmo.py -d
Listening for UPnP broadcasts
got local address of 192.168.0.129
UPnP broadcast listener: new device registered
FauxMo device 'Schlafzimmer' ready on 192.168.0.129:45433
UPnP broadcast listener: new device registered
FauxMo device 'Wohnzimmer' ready on 192.168.0.129:38589
UPnP broadcast listener: new device registered
FauxMo device 'Gang' ready on 192.168.0.129:50235
UPnP broadcast listener: new device registered
FauxMo device 'Bad' ready on 192.168.0.129:39361
Entering main loop

Responding to search for Schlafzimmer
Responding to search for Wohnzimmer
Responding to search for Gang
Responding to search for Bad
Responding to search for Schlafzimmer
Responding to search for Wohnzimmer
Responding to search for Gang
Responding to search for Bad
Responding to setup.xml for Bad
Responding to setup.xml for Schlafzimmer
Responding to setup.xml for Wohnzimmer
Responding to setup.xml for Gang
Responding to setup.xml for Schlafzimmer
Responding to setup.xml for Wohnzimmer
Responding to setup.xml for Gang
Responding to setup.xml for Bad
Responding to ON for Bad

Somehow the first command still comes through.

Respond to Alexa

Hi,

I have setted everything up, so that i can controll the pin, and it words perfectly fine.
The issue i have is: everytime i tell alexa to turn a GPIO on or off, she does it fine, but after that she tells me every time, that the device is not online. Do alexa need a response from the pi to stop saying this? What do i have to do to send this response? what else can i do?

sry for bad englisch

fauxmo with alexa-avs on Raspberry Pi

Hi,
I have setup alexa on Raspberry Pi using the steps mentioned in https://github.com/alexa/alexa-avs-sample-app/wiki/Setting-up-the-Raspberry-Pi and able to execute basic alexa skills like "what is the weather".

Now I am trying to add basic home skills to Raspberry-Pi like "turn on kitchen light".
I have tried to run fauxmo.py in same Raspberry-Pi. But the dummy devices are not listed while searching devices through "Discover device" option (tried with both web interface & alexa Android app).
Is it possible to use "fauxmo.py" on same Pi3 device to setup dummy devices?

issue with echo show

I replaced my echo dot with an echo show, and i am having a weird issue with fauxmo. Fauxmo Device control only works when the old echo dot is on and in range. If it’s not, I get a “I don’t know what went wrong” reply from Alexa. I tried forgetting one of the fauxmo devices, turning off the old echo dot, and discovering it on the echo show, but the device did not show up. I also tried hard-coding the ports. Once I powered up the Echo Dot, the forgotten device was discovered without any issue. Any ideas?

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

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

Cant find devices after alexa update

Hai Sir .. After alexa's new update alexa can't find devices, But raspberry pi is responding to alexa device search.. did they change the xml file .. ? Help me out Please..

Google home uses different port

I set this uses a different port to run and the Google home runs port 80. Is there a way to get fauxmo taking to the Google home?

Specifying port numbers?

The readme encourages specifying fixed port numbers, but gives no indication of how to do that.

This section:
for one_faux in FAUXMOS:
if len(one_faux) == 2:
# a fixed port wasn't specified, use a dynamic one
one_faux.append(0)
seems to suggest adding a field like this:
['nameHere', rest_api_handler('http://addressHere', 'http://addressHere'), 'portHere'],
but this just throws errors and doesn't run.

Can someone help me out here (and perhaps update the readme for others)?

Working with Wemo App + Motion Sensor Possibilities?

Not really an issue, more of a question,

but would the fauxmo code work with the wemo app in that I could set up a wemo motion sensor to turn on one of the virtual lights? I want to be able to use my wemo motion sensors to trigger other automation activities

Thanks

Returned ip adress not correct

Hello together!

There is a function "def act(self, client_address, state, name):" which gives the ip adress, state and name back, when there was a command from Alexa!

My idea is to create for example just one device called "light"
I will have two Alexa's (Echo dot) in two different rooms.
So if i am in the first room and i say "Alexa switch on the light", then the light should switch on in this room. Same in the second room with the second Alexa and the second lamp.

My idea was to handle this over the IP adress. I know which IP adress is in which room and so i can filter the commands and can switch on different outputs!

I found out, that the ip adress which i get back from the function "act" is always just one of the both alexas, but doesn't matter in which room i send the voice command. It is always the same IP adress.

Do you have any idea why?
Can you help me with this problem?

Thank you a lot
kevstone122

Wemo Emulators seem to be dead now

I have been working for a few days now, trying all of the different libraries out there. None of them seem to work anymore since the Alexa is now forcing that you add a skill for the wemo. So unless I am wrong, and I hope I am, none of these emulators will work anymore. Someone please tell me I am wrong.

Additional information about rest api handlers

Could you provide a description on what options are available for the triggers that take place when the Echo tries to run actions against the virtual switches? Can these events handle more than just on and off?

What I'm doing:
I'm building a series of light boxes to be placed in several rooms of my house. These boxes each contain a Raspberry Pi 2, a number of sensors and a relay board connected to several LED light strips. In all, I'm looking to configure up to 8 virtual switches per box. The 16 device limit doesn't bother me, although I've read that in recent weeks, Amazon has increased the device limit in the Echo to control up to 100. I will have up to 7 of these light boxes in my house.

With the example below, I changed the IP address to be that of the Raspberry Pi I'm using for testing, 192.168.0.101. I've also added a port of 49101 so that if I stop and relaunch the python script, it persists. The Echo detects the device and puts it in it's list as "office lights", but when I ask Alexa to turn offlice lights on or off, it thinks for several seconds, then tells me that the device is not responding. I'm not a python guy and I'm not sure what options are available for triggers. Is "http://192.168.5.4/ha-api?cmd=on&a=office" simply looking for a file located in a standard document_root directory for httpd or is this something that is also presented within the python script for fauxmo? If this address is local to the server where the python script is running, could I replace this trigger with the location of a bash or php script? If so, what would that look like? Can this handler handle more than just on and off? I'd love to be able to say something like "Alexa, light box set position one" but I don't completely understand how the Echo determines a command. "Alexa, office lights on" makes sense, but can I use multi-word commands?

['office lights', rest_api_handler('http://192.168.5.4/ha-api?cmd=on&a=office', 'http://192.168.5.4/ha-api?cmd=off&a=office')]

echo dot 2 having trouble finding device

I had the echo connected to the unit until I tried to reboot several times. After that I could not get the unit to connect to the echo.

debug output shows the python script responding to the search attempts, but the echo will not fully pair.

What can I do to solve this? I tried to set a default port, but couldnt figure out how to set a static ip or port.

this is the output: (my local network is 192.168.1.x and the python script is running on a raspberry pi on 192.168.1.77

Listening for UPnP broadcasts
got local address of 192.168.4.2
UPnP broadcast listener: new device registered
FauxMo device 'living room lights' ready on 192.168.4.2:39675
Entering main loop

Responding to search for living room lights
Responding to search for living room lights

Please help!

run script instead of URI ?

Is there an easy way to modify the code so that instead of making an API call to a URL, it can instead execute a bash script? Calling a method in the main fauxmo.py file could be ok too.

I have very little experience with python, so I don't instantly see how to accomplish this, but if there's a quick way it would be better for me than the alternative of setting up a web server on the Raspberry Pi and writing a handler to receive the call and then execute the script/code; seems nicer to do it directly.

What I am trying to achieve is to integrate this with a 433MHz library to send pulses over GPIO to a transmitter installed on the Pi, so Alexa can control regular (cheap) 433 power sockets.

"That command doesn't work on that device"

So, just experimenting.

I run up out-of-the-box fauxmo on my workstation, do a scan on the Echo, it correctly finds 2 devices. Great!

The debug output looks right:

duncan@z640:~/src/fauxmo$ python ./fauxmo.py -d
Listening for UPnP broadcasts
got local address of 10.0.0.9
UPnP broadcast listener: new device registered
FauxMo device 'office lights' ready on 10.0.0.9:49726
UPnP broadcast listener: new device registered
FauxMo device 'kitchen lights' ready on 10.0.0.9:49131
Entering main loop

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 setup.xml for kitchen lights
Responding to setup.xml for office 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 setup.xml for office lights
Responding to setup.xml for kitchen lights
Responding to setup.xml for office lights
Responding to setup.xml for kitchen lights

I then say 'Alexa, turn on the office lights'. The debug looks good:

Responding to ON for office lights

But a short time after, Alexa responds with 'That command is not support by that device'. It then gives the same answer for kitchen lights, without and output from fauxmo. Some time later, the debug output printed is:

('Connection aborted.', error(110, 'Connection timed out'))

Any help greatfully appreciated. I'll try to do some debug of my own in the meantime.

Can the emulated switches be detected using the ouimeaux wemo api?

I am interested in using the emulated switches in conjunction with ouimeaux wemo api. But when I use 'wemo -d list'(ouimeaux wemo api) command in one terminal and i run fauxmo script in another command, I am getting following output:

wemo -d list window:

DEBUG:ouimeaux.discovery:Binding datagram server to 'IP : Port'
INFO:ouimeaux.environment:Discovering devices
DEBUG:ouimeaux.discovery:Broadcasting M-SEARCH to 239.255.255.250:1900
DEBUG:ouimeaux.discovery:Broadcasting M-SEARCH to 239.255.255.250:1900
DEBUG:ouimeaux.discovery:Broadcasting M-SEARCH to 239.255.255.250:1900
DEBUG:ouimeaux.discovery:Broadcasting M-SEARCH to 239.255.255.250:1900
DEBUG:ouimeaux.discovery:Broadcasting M-SEARCH to 239.255.255.250:1900

fauxmo script window:
Listening for UPnP broadcasts
got local address of 'IP'
UPnP broadcast listener: new device registered
FauxMo device 'office lights' ready on IP:53729
UPnP broadcast listener: new device registered
FauxMo device 'kitchen lights' ready on IP:53730
Entering main loop

Ouimeaux API wasn't able to detect the emulated switches. Is there a way to make it work?

Can Not Dectect FauxMo Devices

I tried running Fauxmo yesterday with no success. There were to execution errors with Fauxmo.py but I was not able to detect my devices.

Running debug, execution sits around line 400.

with the -d option it looks like this:

pi@raspberrypi:~/Downloads/fauxmo-master $ python fauxmo.py -d
Listening for UPnP broadcasts
got local address of 192.168.0.24
UPnP broadcast listener: new device registered
FauxMo device 'red led' ready on 192.168.0.24:47898
UPnP broadcast listener: new device registered
FauxMo device 'blue' ready on 192.168.0.24:40721
Entering main loop

Has the Alexa /Wemo universe changed to 'lock-out' this sort of device?

How to delete emulated device from Alexa app?

I added few devices using Fauxmo that got discovered in Alexa, and then later renamed the devices, now Alexa shows all the devices old and new. My issue is how to delete old devices from Alexa.

Fauxmo can not find by Echo dot 3rd gen

After flashing Fauxmo to ESP8266 ESP12, it says on the serial monitor that ESP8266 is connected. But I could not ping it. Looking at the router, the MAC address is there, but the device name and IP Address is "unknown". So Echo Dot 3rd gen could not find the device.
The heap printf in serial is constant and have lots of space, so the chip is working, except that the Wifi is not functioning.

I flashed with normal AsynchTCP simple_server program. It worked fine. I can see the device name and IP address in my router.

Python 3 support?

Can this be updated with a library such as maybe six to support python3 natively as well?

Echo finds FAUXMO devices but later they all go offline.

I have been using FAUXMO on a Rasp Pi for over a year. When I tell it to discover devices, it finds all of my FAUXMO devices, but within 24 hours all the devices are listed as offline in the Alexa app, so I have to do another discover.

This appears to be caused by a change in the Echo firmware.
Has anyone also experienced this problem?

16 switch limit

Hi,

I wasn't sure where to post this question so correct me if this is the wrong place.

The 16 switch limit. Is that per pi or is that in total for alexa.

E.g. can i have 16 switch on one raspberry pi and then another 16 on another or is it a total of 16 switches in the household?

(Sorry for a repetition, i know similar issues are submitted occasionally, but i just needed a bit of clarification)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.