Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8ff5a3
commit 40170da
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python | ||
'''Usage: | ||
aquael poweron IPADDRESS RBW | ||
aquael poweroff IPADDRESS | ||
aquael (-h | --help) | ||
aquael --version | ||
''' | ||
from docopt import docopt | ||
import socket | ||
|
||
OFF_COLOR = '000000000' | ||
|
||
class Light(): | ||
def __init__(self, ip): | ||
self._ip = ip | ||
|
||
def poweron(self, rbw): | ||
set_color(self._ip, rbw) | ||
|
||
def poweroff(self): | ||
set_color(self._ip, OFF_COLOR) | ||
|
||
def set_color(ip, rbw): | ||
UDP_IP = ip | ||
UDP_PORT = 2390 | ||
MESSAGE = 'PWM_SET:' + rbw | ||
|
||
print('UDP target IP:', UDP_IP) | ||
print('UDP target port:', UDP_PORT) | ||
print('message:', MESSAGE) | ||
|
||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||
sock.bind(('0.0.0.0', 2390)) | ||
sock.sendto(MESSAGE.encode(), (UDP_IP, UDP_PORT)) | ||
|
||
def __main(): | ||
arguments = docopt(__doc__, version='0.0.2') | ||
ip = arguments['IPADDRESS'] | ||
rbw = arguments['RBW'] | ||
light = Light(ip) | ||
|
||
if arguments['poweron'] is True: | ||
light.poweron(rbw) | ||
elif arguments['poweroff'] is True: | ||
light.poweroff(ip) | ||
|
||
if __name__ == '__main__': | ||
__main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import aquael | ||
|
||
light = aquael.Light('192.168.15.230') | ||
light.poweron('200200112') | ||
time.sleep(5) | ||
light.poweroff() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import setuptools | ||
|
||
with open("README.md", "r") as fh: | ||
long_description = fh.read() | ||
|
||
|
||
setuptools.setup( | ||
name='py-aquael', | ||
version='0.0.2', | ||
scripts=['aquael.py'], | ||
author="Christopher Haglund", | ||
description="A python library for the Aquael Leddy link unofficial API", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/choffah/py-aquael", | ||
packages=setuptools.find_packages(), | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: BSD License", | ||
"Operating System :: OS Independent", | ||
], | ||
) |