diff --git a/aquael.py b/aquael.py new file mode 100755 index 0000000..e9a7f4a --- /dev/null +++ b/aquael.py @@ -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() \ No newline at end of file diff --git a/example.py b/example.py new file mode 100644 index 0000000..dda21ad --- /dev/null +++ b/example.py @@ -0,0 +1,6 @@ +import aquael + +light = aquael.Light('192.168.15.230') +light.poweron('200200112') +time.sleep(5) +light.poweroff() \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..45bd1ce --- /dev/null +++ b/setup.py @@ -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", + ], + ) \ No newline at end of file