Skip to content

Commit

Permalink
Initial code
Browse files Browse the repository at this point in the history
  • Loading branch information
sweco-secfha committed Dec 7, 2019
1 parent a8ff5a3 commit 40170da
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
48 changes: 48 additions & 0 deletions 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()
6 changes: 6 additions & 0 deletions example.py
@@ -0,0 +1,6 @@
import aquael

light = aquael.Light('192.168.15.230')
light.poweron('200200112')
time.sleep(5)
light.poweroff()
22 changes: 22 additions & 0 deletions 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",
],
)

0 comments on commit 40170da

Please sign in to comment.