我现在能和小米温湿度计联动 控制开关空调和温度设置,没办法设置扫风,风速,用的 set_hvac_mode 接口,其他接口没弄明白,也没找到相关的资料。有大佬搞定了更复杂的设置么
# for hvac
def hvac_control(home_assistant_api, ACCESS_TOKEN, entity_id, action):
# Home Assistant 的 API URL
url = f'http://{home_assistant_api}:8123/api/services/climate/set_hvac_mode'
headers = {
'Authorization': f'Bearer {ACCESS_TOKEN}',
'Content-Type': 'application/json'
}
# 请求数据,指定要关闭的实体
data = {
'entity_id': entity_id, # shouldn't be a set
"hvac_mode": action # shouldn't be a string literal
}
# 发送 POST 请求关闭开关
response =
requests.post(url, headers=headers, json=data)
#返回响应结果
return(response.json())