Control Belkin brand Wemo smart plugs synchronously or asynchronously.
Install from pypi.org
pip install pyblinky
Parameter | Default | Description |
---|---|---|
ip | Required | Network location of plug1 |
timeout | 3 | Seconds to wait for response |
name_cache_age | 0 | Seconds to store plug name before re-querying it |
Action | Parameters | Description |
---|---|---|
on | None | Turn plug on |
off | None | Turn plug off |
toggle | None | Change plug status |
burst | seconds | Turn on plug, wait num seconds, then turn off |
status | None | Get status of plug as (bool) |
identify | None | Get name of plug (str) |
rename | name | Rename plug |
A more thorough list of available actions on the plug is documented here and some may be implemented here in the future.
from pyblinky import Wemo
plug = Wemo('192.168.1.87')
print(plug.status())
print(plug.identify())
plug.on()
import asyncio
from pyblinky import AsyncWemo
plugs = [
AsyncWemo('192.168.1.87'),
AsyncWemo('192.168.1.88'),
AsyncWemo('192.168.1.89')
]
async def main():
result = await asyncio.gather(
*(
[
x.status()
for x in plugs
] +
[
y.identify()
for y in plugs
]
)
)
print(result)
if __name__ == '__main__':
asyncio.run(main())