Skip to content

Commit

Permalink
add in temperature setting
Browse files Browse the repository at this point in the history
  • Loading branch information
rossdargan committed Nov 25, 2020
1 parent 6a67c39 commit 1556adc
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
Empty file modified .devcontainer/Dockerfile
100644 → 100755
Empty file.
Empty file modified .devcontainer/devcontainer.json
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions layz_spa/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def __init__(self, auth, base_url=API_URI + "/v" + API_VERSION + "/gizwits/"):
self.auth = auth
self.base_url = base_url

async def send_command(self, command):
async def send_command(self, command, query_string={}):
async with aiohttp.ClientSession() as session:
async with session.post(self.base_url+command, data=self.auth) as r:
async with session.post(self.base_url+command, data=self.auth,params=query_string) as r:

if r.status == 200:
return await r.json()
Expand Down
12 changes: 6 additions & 6 deletions layz_spa/spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ async def set_power(self, power):
await self.api.send_command("turn_on")
else:
await self.api.send_command("turn_off")
await self.update_status()


async def set_filter_power(self, power):
"""
Expand All @@ -77,8 +75,6 @@ async def set_filter_power(self, power):
await self.api.send_command("turn_filter_on")
else:
await self.api.send_command("turn_filter_off")
await self.update_status()


async def set_heat_power(self, power):
"""
Expand All @@ -91,7 +87,6 @@ async def set_heat_power(self, power):
await self.api.send_command("turn_heat_on")
else:
await self.api.send_command("turn_heat_off")
await self.update_status()

async def set_wave_power(self, power):
"""
Expand All @@ -101,4 +96,9 @@ async def set_wave_power(self, power):
await self.api.send_command("turn_wave_on")
else:
await self.api.send_command("turn_wave_off")
await self.update_status()

async def set_target_temperature(self, temperature):
"""
Set the target temperature for the spa
"""
await self.api.send_command("temp_set", {"temperature": temperature})
4 changes: 3 additions & 1 deletion sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def main():

print(await spa.is_online())
await spa.update_status()
print("current power", spa.power)
print("current power", spa.temp_set)

await spa.set_power(True)
print("current power 1", spa.power)
Expand All @@ -36,6 +36,8 @@ async def main():
# await spa.set_power(True)
print("current power 2", spa.power)

await spa.set_target_temperature(22)

if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ def readme():
setup(
name = 'layz_spa',
packages = ['layz_spa'],
version = '0.2',
version = '0.3',
license='MIT',
description = 'An API to control wifi based lay-z spas',
long_description=readme(),
long_description_content_type='text/markdown',
author = 'Ross Dargan',
author_email = '[email protected]',
url = 'https://github.com/rossdargan/',
download_url = 'https://github.com/rossdargan/lazy-spa-api/archive/0.2.tar.gz',
download_url = 'https://github.com/rossdargan/layz-spa-api/archive/0.3.tar.gz',
keywords = ['Lazy Spa', 'Layz Spa', 'Lay-z spa'],
install_requires=[
'aiohttp'
Expand Down

0 comments on commit 1556adc

Please sign in to comment.