python库提供与本地网络上的genius集线器的连接。
geniushub的Python项目详细描述
geniushub
python库提供与本地网络上的genius集线器的连接。
安装
克隆此重新定位并运行python setup.py install
,或者使用pip install genius
从pip安装。
API
这个库使用未记录的api与genius集线器通信。这个api可能会随着未来对genius集线器固件的更新而改变。
库支持以下功能:
getClimateList()
getSwitchList()
getTRVList()
getSensorList()
getSwitchList()
getZone(zoneId)
getDevice(zoneId, addr)
GET_CLIMATE(zone)
GET_SWITCH(zone)
getSensor(cv)
getTRV(cv)
GET_MODE(zone)
putjson(device_id, data)
用法
通过传入本地IP地址、用户名和密码初始化到集线器的链接。用户名和密码与登录Genius应用程序时使用的相同。成功登录后,模块将定期轮询集线器,以便在本地缓存从集线器获取的值。
从getter中读取的内容是不言而喻的。putjson将数据发布到genius集线器。json的格式可以通过探索genius应用程序和查看发布到hub的请求来发现。
import asyncio
from geniushub import GeniusHub
IP_ADDRESS = 'Your local ip address'
USERNAME = 'Your user name'
PASSWORD = 'Your password'
INTERVAL = 60
async def main():
genius_hub = GeniusHub(IP_ADDRESS, USERNAME, PASSWORD, INTERVAL)
await genius_hub.getjson('/zones')
# Get the zones with a temperature
climate_list = genius_hub.getClimateList()
print("Climate -------------------------------------------------------------")
for zone in climate_list:
print(zone)
trvs = genius_hub.getTRVList()
print("TRV -----------------------------------------------------------------")
for trv in trvs:
print(trv)
switches = genius_hub.getSwitchList()
print("Switches ------------------------------------------------------------")
for switch in switches:
print(switch)
sensors = genius_hub.getSensorList()
print("Sensors -------------------------------------------------------------")
for sensor in sensors:
print(sensor)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()