Closed nathanhaigh closed 2 years ago
Hi @nathanhaigh
a list of some of the functions available is here: https://github.com/LonePurpleWolf/airtouch4pyapi#usage
The main/only usage of this is as a home assistant library, this file has some examples of what calls look like (eg. see highlighted line): https://github.com/home-assistant/core/blob/dev/homeassistant/components/airtouch4/climate.py#L168
In general, after your line its:
await airTouch.UpdateInfo() #get all the info from the at system about groups, temps etc.
airTouch.GetGroups() #interrogate for group number
airTouch.TurnGroupOn(groupNumber)
Thanks for the help. I think I am misunderstanding something entirely!
I get:
SyntaxError: 'await' outside function
Any chance you could provide a minimal reproducible example? Something along the lines of:
from airtouch4pyapi.airtouch import AirTouch
import asyncio
airTouch = AirTouch("192.168.0.14")
async def zoneOn(groupNumber):
await airTouch.UpdateInfo()
airTouch.GetGroups()
airTouch.TurnGroupOn(groupNumber)
asyncio.run(zoneOn(2))
However, it just seems to hang.
Hi @nathanhaigh
It's tough to be able to give better advice on how to debug beyond the basics - if the behaviour you're getting is hanging, the first thing id be doing is working out what line thats happening on by using print statements, etc. When I run your code, I get an asyncio based issue because the last function isnt awaited - changing it to:
from airtouch4pyapi.airtouch import AirTouch
import asyncio
airTouch = AirTouch("192.168.0.14")
async def zoneOn(groupNumber):
await airTouch.UpdateInfo()
airTouch.GetGroups()
await airTouch.TurnGroupOn(groupNumber)
asyncio.run(zoneOn(2))
closes fine and works on my setup (turns the expected group on) - after the UpdateInfo function you can print(airTouch.Status) to see if the airtouch module was able to be contacted as another diagnostic step.
Have you done much with asyncio before? If not and you're interested, can definitely recommend this video as a starter: https://developers.home-assistant.io/docs/asyncio_101/ - might help with some of the confusing bits!
I'm trying to play around with using this code to communicate with my airtouch4. Could you provide an example of how to use
airtouch4pyapi
to issue commands and retrieve info from my airtouch4?I was hoping to do something quite basic along the lines of:
Can you provide some guidance here?