Skip to content

Commit

Permalink
initialization of pyvlx with host/password
Browse files Browse the repository at this point in the history
  • Loading branch information
Julius2342 committed Jun 25, 2017
1 parent 4813da4 commit c5bbac3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ from pyvlx import PyVLX
import asyncio

async def main():
pyvlx = PyVLX("pyvlx.yaml")
pyvlx = PyVLX('pyvlx.yaml')
# Alternative: pyvlx = PyVLX(host='192.168.2.127',password='velux123')

await pyvlx.load_devices()
print(pyvlx.devices[1])
print(pyvlx.devices['Fenster 4'])
print(pyvlx.devices['Window 4'])

await pyvlx.load_scenes()
print(pyvlx.scenes[0])
print(pyvlx.scenes['alles auf'])
print(pyvlx.scenes['Open all windows'])

# opening/ closing windows by running scenes, yay!
await pyvlx.scenes[1].run()
Expand Down
7 changes: 6 additions & 1 deletion pyvlx/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

class Config:

def __init__(self, path):
def __init__(self, path=None, host=None, password=None):
if path is not None:
self.read_config(path)
if host is not None:
self.host = host
if password is not None:
self.password = password


def read_config(self, path):
print('Reading {0}'.format(path))
Expand Down
4 changes: 2 additions & 2 deletions pyvlx/pyvlx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

class PyVLX:

def __init__(self, path=None):
self.config = Config(path)
def __init__(self, path=None, host=None, password=None):
self.config = Config(path, host, password)
self.interface = Interface(self.config)
self.devices = Devices(self)
self.scenes = Scenes(self)
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import asyncio

async def main():
pyvlx = PyVLX('pyvlx.yaml')
pyvlx = PyVLX('pyvlx.yaml') # Alternative: pyvlx = PyVLX(host="192.168.2.127",password="velux123")

await pyvlx.load_devices()
print(pyvlx.devices[1])
Expand Down

0 comments on commit c5bbac3

Please sign in to comment.