mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Now using PyWemo instead of Ouimeaux to control WeMo
This commit is contained in:
parent
85f401f209
commit
f4c77c85bd
@ -31,7 +31,7 @@ The system is built modular so support for other devices or actions can be imple
|
||||
|
||||
Installation instructions
|
||||
-------------------------
|
||||
* The core depends on [PyEphem](http://rhodesmill.org/pyephem/) and [Requests](http://python-requests.org). Depending on the components you would like to use you will need [PHue](https://github.com/studioimaginaire/phue) for Philips Hue support, [PyChromecast](https://github.com/balloob/pychromecast) for Chromecast support and [ouimeaux](https://github.com/iancmcc/ouimeaux) for WeMo support. Install these using `pip install pyephem requests phue ouimeaux pychromecast`.
|
||||
* The core depends on [PyEphem](http://rhodesmill.org/pyephem/) and [Requests](http://python-requests.org). Depending on the components you would like to use you will need [PHue](https://github.com/studioimaginaire/phue) for Philips Hue support and [PyChromecast](https://github.com/balloob/pychromecast) for Chromecast support. Install these using `pip install pyephem requests phue pychromecast`.
|
||||
* Clone the repository and pull in the submodules `git clone --recursive https://github.com/balloob/home-assistant.git`
|
||||
* Copy home-assistant.conf.default to home-assistant.conf and adjust the config values to match your setup.
|
||||
* For Tomato you will have to not only setup your host, username and password but also a http_id. The http_id can be retrieved by going to the admin console of your router, view the source of any of the pages and search for `http_id`.
|
||||
|
@ -54,28 +54,20 @@ def setup(bus, statemachine):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
import ouimeaux.environment as wemo_env
|
||||
import ouimeaux.device.switch as wemo_switch
|
||||
import ouimeaux.device.insight as wemo_insight
|
||||
import homeassistant.external.pywemo.pywemo as pywemo
|
||||
except ImportError:
|
||||
logger.exception(("Failed to import ouimeaux. "
|
||||
"Did you maybe not install the 'ouimeaux' "
|
||||
"dependency?"))
|
||||
pass
|
||||
|
||||
return False
|
||||
|
||||
env = wemo_env.Environment()
|
||||
logger.info("Scanning for WeMo devices")
|
||||
devices = pywemo.discover_devices()
|
||||
|
||||
try:
|
||||
env.start()
|
||||
except socket.error:
|
||||
# If the socket is already in use
|
||||
logger.exception("Error starting WeMo environment")
|
||||
return False
|
||||
is_switch = lambda switch: isinstance(switch, pywemo.Switch)
|
||||
|
||||
env.discover(5)
|
||||
switches = [device for device in devices if is_switch(device)]
|
||||
|
||||
if len(env.list_switches()) == 0:
|
||||
if len(switches) == 0:
|
||||
logger.error("No WeMo switches found")
|
||||
return False
|
||||
|
||||
@ -88,7 +80,7 @@ def setup(bus, statemachine):
|
||||
""" Update the state of specified WeMo device. """
|
||||
|
||||
# We currently only support switches
|
||||
if not isinstance(device, wemo_switch.Switch):
|
||||
if not is_switch(device):
|
||||
return
|
||||
|
||||
try:
|
||||
@ -107,7 +99,7 @@ def setup(bus, statemachine):
|
||||
|
||||
state_attr = {ATTR_FRIENDLY_NAME: device.name}
|
||||
|
||||
if isinstance(device, wemo_insight.Insight):
|
||||
if isinstance(device, pywemo.Insight):
|
||||
pass
|
||||
# Should work but doesn't..
|
||||
#state_attr[ATTR_TODAY_KWH] = device.today_kwh
|
||||
@ -129,7 +121,7 @@ def setup(bus, statemachine):
|
||||
logger.info("Updating WeMo status")
|
||||
_update_wemos_state.last_updated = datetime.now()
|
||||
|
||||
for device in env:
|
||||
for device in switches:
|
||||
_update_wemo_state(device)
|
||||
|
||||
_update_wemos_state(None, True)
|
||||
|
1
homeassistant/external/pywemo
vendored
Submodule
1
homeassistant/external/pywemo
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 0e87fe7d724aca851acfb5e756b751e072b03ca5
|
Loading…
x
Reference in New Issue
Block a user