|

楼主 |
发表于 2024-11-21 01:07:25
|
显示全部楼层
谢谢,如果我想让这个函数通过HA关闭小米的aqara开关。怎么设置呢?
def control_homeassistant(entity_id, action):
url = 'http://10.0.0.222:8123/api/services/light/{}'.format(action)
headers = {
'Authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiMGM4YTI4YTNhYTQ0Njk4YjMwODkwOTQ4YTMwM2E3YSIs',
'Content-Type': 'application/json'
}
data = {
'entity_id': entity_id
}
response = requests.post(url, headers=headers, json=data)
print(response.text) |
|