针对小米插座自动化的脚本
My laptop battery is swollen because of long-time charging.
After I bought a new battery, I decided to find out how to auto-charge using the Xiaomi Smart Socket 3.
My target is as follows:
1. When the battery percentage is below 50%, it starts charging.
2. When the battery percentage exceeds 90%, it stops charging.
3. When the laptop is shut down, it stops charging.
尝试失败
以下两种方式都获取失败, 原因是遇到账号需要短信二次验证..
-
miiocli cloud python-miio
-
token_extractor.py Home Assistant
转机
commands
siid, 可以理解为方法id
piid, 可以理解为参数id
# 查询固件版本等信息
miiocli device --ip IP --token abcde info
# 开
miiocli -d device --ip IP --token abcde raw_command set_properties "[{'did': 'MYDID', 'siid': 2, 'piid': 1, 'value':True}]"
# 关
miiocli -d device --ip IP --token abcde raw_command set_properties "[{'did': 'MYDID', 'siid': 2, 'piid': 1, 'value':False}]"
# 获取开关状态
miiocli -d device --ip IP --token abcde raw_command get_properties "[{'did': 'MYDID', 'siid': 2, 'piid': 1}]"
Comments