Venstar Colortouch恒温器接口库API V5
venstarcolortouch的Python项目详细描述
Python3 API用于Venstar Colortouch恒温器
Venstar ColorTouch thermostat是带有rest api的wifi恒温器。这是一个简单的python3 api。必须读取API documents。
限制
api没有实现venstar发现协议。假设您知道恒温器的ip地址或fqdn。
测试
$ python venstarcolortouch 192.168.1.252 Testing with IP: 192.168.1.252 Login successful. API: 5 Type: residential Was able to get info:{u'spacetemp': 67.0, u'schedulepart': 255, u'dehum_setpoint': 0, u'away': 0, u'cooltempmax': 99.0, u'cooltemp': 78.0, u'tempunits': 0, u'state': 1, u'schedule': 0, u'hum': 0, u'heattemp': 75.0, u'hum_setpoint': 36, u'fan': 0, u'hum_active': 99, u'heattempmax': 99.0, u'cooltempmin': 35.0, u'name': u'DebtRidge', u'mode': 1, u'heattempmin': 35.0, u'availablemodes': 0, u'fanstate': 1, u'setpointdelta': 2.0} Name is MyHouse Fan is 0 Heat setpoint is 75.0 Cool setpoint is 78.0 Was able to get sensors:{u'sensors': [{u'hum': 36, u'name': u'Thermostat', u'temp': 67.0}, {u'name': u'Outdoor', u'temp': 0.0}]} Indoor temp is 67.0 and humidity is 36 Runtimes: {u'cool1': 0, u'cool2': 0, u'ts': 1429574400, u'fc': 0, u'heat2': 0, u'heat1': 0, u'aux2': 0, u'aux1': 0} Path is: /control set_control Success! Heat setpoint is 60.0 Cool setpoint is 90.0 Path is: /control set_control Success! Heat setpoint is 75.0 Cool setpoint is 78.0
用法
classVenstarColorTouch:def__init__(self,addr,timeout):
类实例化需要具有可选超时的IP地址或主机名。
ct=venstarcolortouch.VenstarColorTouch(a,timeout=5)ifct.login()isTrue:print("Login successful. API: {0} Type: {1}".format(ct._api_ver,ct._type))
log in()函数没有真正登录,但它确实确认了通信,并且api版本足够新。
API
api调用使用以下常量:
MODE_OFFMODE_HEATMODE_COOLMODE_AUTOSTATE_IDLESTATE_HEATINGSTATE_COOLINGSTATE_LOCKOUTSTATE_ERRORFAN_AUTOFAN_ONFANSTATE_OFFFANSTATE_ONTEMPUNITS_FTEMPUNITS_CSCHED_FSCHED_CSCHEDPART_MORNINGSCHEDPART_DAYSCHEDPART_EVENINGSCHEDPART_NIGHTSCHEDPART_INACTIVEAWAY_HOMEAWAY_AWAY
功能
有update_*
函数可以更新各种数据的本地副本。然后是用于检索数据的get_*
函数,最后是用于更改可写设置的set_*
函数。
update_sensors()
-更新室内和室外温度传感器的状态。get_runtimes()
-收集运行时数据。get_info()
-返回一条信息指令。{u'spacetemp', u'schedulepart', u'dehum_setpoint', u'away', u'cooltempmax', u'cooltemp', u'tempunits', u'state', u'schedule', u'hum', u'heattemp', u'hum_setpoint', u'fan', u'hum_active', u'heattempmax', u'cooltempmin', u'name', u'mode', u'heattempmin', u'availablemodes', u'fanstate', u'setpointdelta'}
get_info("heattemp")
get_thermostat_sensor(attr)
获取特定恒温器传感器的值。get_thermostat_sensor("temp")
get_outdoor_sensor(attr)
获取室外传感器的值。get_outdoor_sensor("temp")```
get_alerts()
获取任何已注册的警报。set_setpoints(heattemp, cooltemp)
设置加热温度/冷却温度。set_mode(mode)
设置恒温器模式。- 关闭模式
- 加热模式
- 模式“酷”
- 自动模式
set_fan(fan)
设置风扇模式。- 风扇自动
- 风扇打开
set_tempunits(tempunits)
将摄氏度或华氏度设置为- 温度单位
- 温度单位
set_away(away)
设置主客场时间表。- 客场
- 客场
set_schedule(schedule)
打开或关闭计划。- 0-关
- 1-开
set_hum_setpoint(hum_setpoint)
设置加湿器设定值set_dehum_setpoint(dehum_setpoint)
设置除湿器设定值