move fauxmo into place/add virtual switch

This commit is contained in:
Emil Lerch 2019-07-20 09:11:24 -07:00
parent 0e534d8d9d
commit b2f568565c
Signed by: lobo
GPG Key ID: CEC5F37C1BE5A481
2 changed files with 32 additions and 3 deletions

23
README.md Normal file
View File

@ -0,0 +1,23 @@
WeMo control
============
The plan:
---------
1. Use Fauxmo to create a virtual switch 'Movie Lights' recognized on the
NAS at port 20000
2. Fauxmo will run in a docker file and be able to talk to another container,
which runs our golang executable. Other container name is 'movielights'
3. Our golang executable will then talk to the actual wemo switches
TODO:
-----
Figure out how to discover the IP addresses. Options are:
* Do a discovery at startup
* ~~Do a discovery before an event~~ I don't like this one due to latency
* Do a discovery after an event
* Do a discovery on a time basis
Discovery is currently via a node module. Would prefer to use go here

12
fauxmo.py → fauxmo/fauxmo.py Normal file → Executable file
View File

@ -114,7 +114,7 @@ class upnp_device(object):
if not upnp_device.this_host_ip: if not upnp_device.this_host_ip:
temp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) temp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try: try:
temp_socket.connect(('8.8.8.8', 53)) temp_socket.connect(('1.1.1.1', 53))
upnp_device.this_host_ip = temp_socket.getsockname()[0] upnp_device.this_host_ip = temp_socket.getsockname()[0]
except: except:
upnp_device.this_host_ip = '127.0.0.1' upnp_device.this_host_ip = '127.0.0.1'
@ -381,8 +381,14 @@ class rest_api_handler(object):
# list will be used. # list will be used.
FAUXMOS = [ FAUXMOS = [
['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')], [
['kitchen lights', rest_api_handler('http://192.168.5.4/ha-api?cmd=on&a=kitchen', 'http://192.168.5.4/ha-api?cmd=off&a=kitchen')], 'Movie Lights',
rest_api_handler(
'http://movielights:8081/basement?moviemode=true',
'http://movielights:8081/basement?moviemode=false'
),
20000
],
] ]