Skip to content

Commit

Permalink
Version 1.0.5 --> New: Programm Smart Panels
Browse files Browse the repository at this point in the history
  • Loading branch information
Guido Diener committed Apr 8, 2018
1 parent a118617 commit 1544f33
Show file tree
Hide file tree
Showing 15 changed files with 408 additions and 153 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,7 @@ tox.ini
HowToUploadToPyPi.txt
MANIFEST.in
.pytest_cache/v/cache/lastfailed

# vscode
launch.json
settings.json
21 changes: 14 additions & 7 deletions example/playwith.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
"""This is the test to play around."""

import requests
import xml.etree.ElementTree as ET
import time

current_position = None


def get_state():
"""Get the state."""
full_url = "http://192.168.86.114/zrap/chscan/ch1"
device_info_response = requests.get(full_url)
root = ET.fromstring(device_info_response.text)
return str(root[0][0].text)


def count_time_till_stop():
"""Count the time till stop."""
start = time.time()
time.sleep(float(0.5))
while(get_state() != '0'):
time.sleep(float(0.2))
end = time.time()
print(end - start)


def go_to_position(postion):
"""Go to position."""
sleep_time = None
global current_position
if current_position is None:
if current_position is None:
payload = "cmd=close"
full_url = "http://192.168.86.114/zrap/chctrl/ch1"
requests.post(full_url, data=payload)
Expand All @@ -42,19 +50,19 @@ def go_to_position(postion):
full_url = "http://192.168.86.114/zrap/chctrl/ch1"
requests.post(full_url, data=payload)
sleep_time = float(55.3/100*(postion-current_position))

time.sleep(sleep_time)
payload = "cmd=stop"
full_url = "http://192.168.86.114/zrap/chctrl/ch1"
requests.post(full_url, data=payload)
current_position = postion


device_info_response = requests.get("http://192.168.86.114/zrap/chdes")

#payload = "cmd=open"
#full_url = "http://192.168.86.114/zrap/chctrl/ch1"
#device_info_response = requests.post(full_url, data=payload)
#print(device_info_response)
# payload = "cmd=open"
# full_url = "http://192.168.86.114/zrap/chctrl/ch1"
# device_info_response = requests.post(full_url, data=payload)
# print(device_info_response)

go_to_position(50)
time.sleep(float(2))
Expand All @@ -67,4 +75,3 @@ def go_to_position(postion):
go_to_position(10)
time.sleep(float(2))
go_to_position(0)

35 changes: 24 additions & 11 deletions example/sample.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
"""This is a Sample how to use the zeptrion Air Api."""

from zeptrionAirApi import ZeptrionAirHub

hub = ZeptrionAirHub(3) #Initialize the ZeptrionAIrHub and browse for 5sec
allZeptrionPanels = hub.get_all_panels() #returns all found panels
allZeptrionChannels = hub.get_all_channels() #returns all found channels
allLightChannels = hub.get_all_light_channels() #returns all found channels that are Light switches
allGroups = hub.get_all_group() #returns all groups, that have been defined on the zeptrion app
# Initialize the ZeptrionAIrHub and browse for 5sec
hub = ZeptrionAirHub(3)
# returns all found panels
allZeptrionPanels = hub.get_all_panels()
# returns all found channels
allZeptrionChannels = hub.get_all_channels()
# returns all found channels that are Light switches
allLightChannels = hub.get_all_light_channels()
# returns all groups, that have been defined on the zeptrion app
allGroups = hub.get_all_group()
for group in allGroups:
output_to_return = "Channels in Group: " + str(group)
hub.get_all_channels_by_group(group) #returns all channles that are defined for that group
# returns all channles that are defined for that group
hub.get_all_channels_by_group(group)

channels = hub.get_all_channels_by_cat(1) #returns all found channels that are Light switches --> Category 1
channel = channels[0] #pick the first light
channel.toggle_light() #toggle the light
channel.turn_on_light() #turn the light on
channel.turn_off_light() #turn the light off
# returns all found channels that are Light switches --> Category 1
channels = hub.get_all_channels_by_cat(1)
# pick the first light
channel = channels[0]
# toggle the light
channel.toggle_light()
# turn the light on
channel.turn_on_light()
# turn the light off
channel.turn_off_light()
28 changes: 28 additions & 0 deletions sample_smart_button.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""This is the test for Smart Button."""

from zeptrionAirApi import ZeptrionAirHub
import json

hub = ZeptrionAirHub(3) # Initialize the ZeptrionAIrHub and browse for 5sec
allZeptrionPanels = hub.get_all_panels() # returns all found panels
# smartBtns = hub.get_all_smart_buttons() # returns all found smart buttons
# hub.set_all_smart_buttons_to_program_mode()

prog_elements = {}
prog_elements['prog_req_type'] = 'POST'
prog_elements['prog_url'] = '192.168.86.167'
prog_elements['prog_path'] = '/test'
prog_elements['prog_typ'] = 'application/json'
prog_elements['prog_header_field'] = ''
prog_elements['prog_port'] = '1880'
body = {}
body['state'] = 20
body['attributes'] = {}
body['attributes']['unit_of_measurement'] = '°C'
body['attributes']['friendly_name'] = 'Bathroom Temperature'
prog_elements['prog_body'] = json.dumps(body)

# result = hub.programm_smart_btn(prog_elements)
# print(result)
result = hub.get_panels_with_smart_button()
print(result)
24 changes: 13 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""A setuptools based setup module.
"""
A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
Expand All @@ -17,23 +19,23 @@
long_description = f.read()

setup(
name = 'zeptrionAirApi',
name='zeptrionAirApi',
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
version = '1.0.4',
description = "This are the Classes to use the Zeptrion Air Lights etc.",
version='1.0.5',
description="This are the Classes to use the Zeptrion Air Lights etc.",
long_description=long_description,
author = "Swissglider",
author_email = "swissglider@mailschweiz.com",
url = "https://github.com/swissglider/zeptrionAirApi",
keywords = "zeptrion zeptrion-air Light-Switch Switch Blind-Switch",
author="Swissglider",
author_email="swissglider@mailschweiz.com",
url="https://github.com/swissglider/zeptrionAirApi",
keywords="zeptrion zeptrion-air Light-Switch Switch Blind-Switch",
install_requires=['requests', 'zeroconf', ],
classifiers = [
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
],
setup_requires=['pytest-runner'],
tests_require=['pytest'],
)
tests_require=['pytest', 'pytest-asyncio'],
)
10 changes: 6 additions & 4 deletions test_script.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ echo " ### pycodestyle --first test - "+$1
pycodestyle --first $1

echo " ### pylint 3.6 test - "+$1
/Users/diener/Library/Python/3.6/bin/pylint $1
/Users/diener/Library/Python/3.6/bin/pylint ./zeptrionAirApi

#echo " ### python3 setup.py test"
#python3 setup.py test
# echo " ### python3 setup.py test"
# python3 setup.py test

echo " ### pytest and coverage"
py.test --cov ./zeptrionAirApi
py.test --cov ./zeptrionAirApi

# py.test -s --cov-report html --cov ./zeptrionAirApi
8 changes: 5 additions & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""This is the __init_.py file."""

# __init__.py
#from zeptrionAirApi.zeptrion_air_hub import ZeptrionAirHub
#from zeptrionAirApi.zeptrion_air_panel import zeptrion_air_panel
#from zeptrionAirApi.zeptrion_air_channel import zeptrion_air_channel
# from zeptrionAirApi.zeptrion_air_hub import ZeptrionAirHub
# from zeptrionAirApi.zeptrion_air_panel import zeptrion_air_panel
# from zeptrionAirApi.zeptrion_air_channel import zeptrion_air_channel
Loading

0 comments on commit 1544f33

Please sign in to comment.