同步操作将从 Alone/hass-xiaomi-miot 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
English | 简体中文
MIoT-Spec 是小米IoT平台根据硬件产品的联网方式、产品功能的特点、用户使用场景的特征和用户对硬件产品使用体验的要求,设计的描述硬件产品功能定义的标准规范。
本插件利用了miot协议的规范,可将小米设备自动接入HomeAssistant,目前已支持大部分小米米家智能设备。且该插件支持HA后台界面集成,无需配置yaml即可轻松将小米设备接入HA。
下载并复制
custom_components/xiaomi_miot
文件夹到HA根目录下的custom_components
文件夹
# 执行下面的命令可以自动安装
wget -q -O - https://cdn.jsdelivr.net/gh/al-one/hass-xiaomi-miot/install.sh | bash -
# 如果遇到下载缓慢或下载失败可以执行下面的命令
wget -q -O - https://cdn.jsdelivr.net/gh/al-one/hass-xiaomi-miot/install.sh | HUB_DOMAIN=hub.fastgit.org bash -
或者通过HACS搜索
Xiaomi Miot Auto
安装
自v0.4.4版本开始,插件新增支持账号集成时选择连接设备的模式:
通过host/token接入设备,适用于在局域网环境下支持miot协议的设备
为通过token集成的设备开启云端模式
# configuration.yaml
xiaomi_miot:
username: xiaomi_username
password: xiaomi_password
# server_country: cn # 小米云服务器位置: cn(默认), de, i2, ru, sg, tw, us
# http_timeout: 15 # 请求小米接口的超时时间(秒)
可以通过配置文件将大部分miot属性的选项描述(如:模式、风速等)翻译成你想要的语言,当然也欢迎你贡献你的词典给其他人👏🏻。
# configuration.yaml
xiaomi_miot:
language: zh # 使用内置词典,目前仅支持`zh`
# https://github.com/al-one/hass-xiaomi-miot/blob/master/custom_components/xiaomi_miot/core/translation_languages.py
translations:
# 全局词典,对所有实体生效
idle: '空闲'
busy: '工作中'
# 指定风扇模式的词典
fan.mode:
straight wind: '直吹模式'
natural wind: '自然风'
# 指定洗衣机烘干模式的词典
washer.drying_level:
moist: '微湿'
extra: '特干'
# configuration.yaml
homeassistant:
customize: !include customize.yaml
# 通过设备型号自定义
xiaomi_miot:
# https://github.com/al-one/hass-xiaomi-miot/blob/master/custom_components/xiaomi_miot/core/device_customizes.py
device_customizes:
chuangmi.plug.212a01:
miot_local: true
chunk_properties: 7
# 通过父实体自定义
# customize.yaml
domain.your_entity_id:
miot_local: true # 使用本地模式 (通过账号接入的设备)
miot_cloud: true # 为该实体开启云端模式 (read, write, action)
miot_cloud_write: true # 仅写属性使用云端模式
miot_cloud_action: true # 仅action使用云端模式
check_lan: true # 云端模式下检查设备在局域网是否可用
miio_properties: power,battery # 获取miio属性到实体的属性中
miio_cloud_props: prop.power,event.dev_online
# 自定义子实体
domain.parent_entity_id:
sensor_properties: temperature,humidity,illumination # Miot属性
binary_sensor_properties: is_volume_muted,any_boolen_property
switch_properties: on,power
number_properties: volume
select_properties: mode
fan_properties: mode,fan_level
cover_properties: motor_control
light.your_entity_id:
color_temp_reverse: false # 反转色温(需重载集成配置)
yeelight_smooth_on: 2000 # 毫秒 (仅支持本地接入的易来灯)
yeelight_smooth_off: 3000 # 毫秒 (仅支持本地接入的易来灯)
climate.your_entity_id:
bind_sensor: sensor.temperature_entity,sensor.humidity_entity # 绑定传感器实体
camera.your_entity_id:
video_attribute: 1 # https://github.com/al-one/hass-xiaomi-miot/issues/11#issuecomment-773054167
keep_streaming: true # 持续更新流地址
cover.your_entity_id:
closed_position: 5 # 当实体位置值小于等于此值时为关闭状态
deviated_position: 2 # 位置偏差值 2% -> 0%, 98% -> 100%
motor_reverse: true # 反转电机状态(需重载集成配置)
position_reverse: true # 反转电机进程(需重载集成配置)
open_texts: 打开,升
close_texts: 关闭,降
media_player.mitv_entity_id:
bind_xiaoai: media_player.xiaoai_entity_id # 绑定小爱音箱以打开电视
domain.your_entity_id_xxxx:
interval_seconds: 30 # 每次更新状态间隔秒数(需重载集成配置)
chunk_properties: 10 # 单次查询设备属性的最大个数(LAN)
reverse_state: true # 反转开关状态(仅作用于Binary Sensor)
过多的实体属性会导致你的HA数据库变得很庞大,如果某些实体属性对你没有用处,你可以配置
exclude_state_attributes
来忽略它们
# configuration.yaml
xiaomi_miot:
exclude_state_attributes:
- miot_type
- stream_address
- motion_video_latest
自v0.4.16版本开始,本插件支持配置重载(修改YAML配置后无需重启HomeAssistant):
xiaomi_miot.set_property
service: xiaomi_miot.set_property
data:
entity_id: camera.isa_hlc7_xxxx
field: camera_control.on
value: true
xiaomi_miot.set_miot_property
service: xiaomi_miot.set_miot_property
data:
entity_id: camera.isa_hlc7_xxxx
siid: 2
piid: 1
value: true
xiaomi_miot.get_properties
service: xiaomi_miot.get_properties
data:
entity_id: camera.isa_hlc7_1ab7
mapping:
power:
siid: 2
piid: 1
night:
siid: 2
piid: 3
throw: true # throw result to HA notifications
xiaomi_miot.call_action
service: xiaomi_miot.call_action
data:
entity_id: vacuum.dreame_p2259_entity_id
siid: 4 # vacuum-extend
aiid: 1 # start-clean
params:
- 18 # piid: 1 - work-mode
- '{"selects":[[7,1,0,2,1]]}' # piid: 10 - clean-extend-data
throw: true # throw result to HA notifications
xiaomi_miot.send_command
service: xiaomi_miot.send_command
data:
entity_id: switch.your_entity_id
method: set_power
params:
- on
throw: true # throw result to HA notifications
xiaomi_miot.get_token
service: xiaomi_miot.get_token
data:
name: Light # Keyword of device name in Mihome / IP / Model.
xiaomi_miot.intelligent_speaker
service: xiaomi_miot.intelligent_speaker
data:
entity_id: media_player.xiaoai_lx04_xxxx
text: Turn on the light
execute: true # Execute text directive.
silent: true # Silent execution.
xiaomi_miot.xiaoai_wakeup
service: xiaomi_miot.xiaoai_wakeup
data:
entity_id: media_player.xiaoai_lx04_xxxx
查看更多服务
# 使用HA服务 (无需重启)
service: logger.set_level
data:
custom_components.xiaomi_miot: debug
# 或者修改 configuration.yaml (需重启)
logger:
default: warning
logs:
custom_components.xiaomi_miot: debug
QQ群:198841186
微信群:
使用HomeAssistant服务
xiaomi_miot.get_token
,输入设备名称关键词使用@vevsvevs修改版的米家
Write custom log files
和Enable app's debug mode
vevs/logs/misc/devices.txt
文件中找到token此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。