File: demo.py

package info (click to toggle)
python-airtouch4pyapi 1.0.8-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 136 kB
  • sloc: python: 933; makefile: 4; sh: 2
file content (93 lines) | stat: -rw-r--r-- 3,662 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import sys

import asyncio
import time

from airtouch4pyapi import AirTouch, AirTouchStatus, AirTouchVersion

def print_groups(groups):
    for group in groups:
        print(f"Group Name: {group.GroupName:15s} Group Number: {group.GroupNumber:3d} PowerState: {group.PowerState:3s} IsOn: {group.IsOn} OpenPercent: {group.OpenPercent:3d} Temperature: {group.Temperature:3.1f} Target: {group.TargetSetpoint:3.1f} BelongToAc: {group.BelongsToAc:2d} Spill: {group.Spill}")


def print_acs(acs):
    for ac in acs:
        print(f"AC Name: {ac.AcName:15s} AC Number: {ac.AcNumber:3d} IsOn: {ac.IsOn} PowerState: {ac.PowerState:3s} Target: {ac.AcTargetSetpoint:3.1f} Temp: {ac.Temperature:3.1f} Modes Supported: {ac.ModeSupported} Fans Supported: {ac.FanSpeedSupported} startGroup: {ac.StartGroupNumber: 2d} GroupCount: {ac.GroupCount:2d} Spill: {ac.Spill}")

async def updateInfoAndDisplay(ip) -> asyncio.coroutine:
    at = AirTouch(ip)
    await at.UpdateInfo()
    if(at.Status != AirTouchStatus.OK):
        print("Got an error updating info.  Exiting")
        return
    print("Updated Info on Groups (Zones) and ACs")
    print("AC INFO")
    print("----------")
    acs = at.GetAcs()
    print_acs(acs)
    print("----------\n\n")
    print("GROUP/ZONE INFO")
    print("----------")
    groups = at.GetGroups()
    print_groups(groups)
    val = input("Do you want to turn them all off, wait 10 seconds, turn them all back on? (y/n): ")
    if(val.lower() == "y"):
        for group in groups:
            await at.TurnGroupOffByName(group.GroupName)
        print("GROUP/ZONE INFO AFTER TURNING ALL OFF")
        print("----------")
        print_groups(groups)
        time.sleep(10)
        for group in groups:
            await at.TurnGroupOnByName(group.GroupName)
        await at.TurnAcOn(0)
        print("GROUP/ZONE INFO AFTER TURNING ALL ON")
        print("----------")
        print_groups(groups)
    val = input("Do you want to increment set points by 1 degree then back down by 1? (y/n): ")
    if(val.lower() == "y"):
        for group in groups:
            to_temp = int(group.TargetSetpoint) + 1
            await at.SetGroupToTemperatureByGroupName(group.GroupName, to_temp)
        print("GROUP/ZONE INFO AFTER SET TEMP + 1")
        print("----------")
        print_groups(groups)
        time.sleep(5)
        for group in groups:
            to_temp = int(group.TargetSetpoint) -1
            await at.SetGroupToTemperatureByGroupName(group.GroupName, to_temp)
        print("GROUP/ZONE INFO AFTER SET TEMP + 1")
        print("----------")
        print_groups(groups)
        
    val = input("Do you want to set group 0's mode to heat then back to cool? (y/n): ")
    if(val.lower() == "y"):
        await at.SetCoolingModeByGroup(0, 'Heat')
        print("AC INFO AFTER SETTING GROUP 0 to HEAT")
        print("----------")
        print_acs(acs)
        time.sleep(5)
        await at.SetCoolingModeByGroup(0, 'Cool')
        print("AC INFO AFTER SETTING GROUP 0 to COOL")
        print("----------")
        print_acs(acs)
#    await at.TurnGroupOff(0)
#    print("Turned off group 0, sleeping 4")
#    time.sleep(4);
#    await at.TurnGroupOn(0)
#    print("Turned on group 0")
    
#    await at.TurnAcOff(0)
#    print("Turned off ac 0, sleeping 4")
#    time.sleep(4);
#    await at.TurnAcOn(0)
#    print("Turned on ac 0")
#    print(at.GetSupportedFanSpeedsByGroup(0))
#    await at.SetGroupToPercentByGroupName("Zone 1", 5)

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print("nom nom nom give me an IP of an AirTouch system")
        sys.exit(1)
    asyncio.run(updateInfoAndDisplay(sys.argv[1]))