英語 | 簡體中文
MIoT-Spec:小米IoT設備的協定規範,是小米IoT平台根據硬體產品的組網方式、產品功能特點、用戶使用場景特點,設計的描述硬體產品功能定義的標準以及用戶對硬體產品使用體驗的要求規範。
該組件使用miot協定自動將小米設備整合到HomeAssistant中,目前支援大部分小米IoT設備。並且支援HA Web UI,無需配置yaml即可輕鬆將小米設備整合到HA中。
HACS > 整合 > ➕ 探索與下載儲存庫 >
Xiaomi Miot Auto
> 下載此儲存庫
HACS > 整合 >
Xiaomi Miot Auto
> 更新/重新下載
下載並複製
custom_components/xiaomi_miot
資料夾到 HomeAssistant 設定資料夾中的custom_components
資料夾
wget -O - https://get.hacs.vip | DOMAIN=xiaomi_miot bash -
# Or
wget -O - https://raw.githubusercontent.com/al-one/hass-xiaomi-miot/master/install.sh | ARCHIVE_TAG=latest bash -
configuration.yaml
shell_command :
update_xiaomi_miot : |-
wget -O - https://get.hacs.vip | DOMAIN=xiaomi_miot bash -
service: shell_command.update_xiaomi_miot
配置 > 設備和服務 > ?整合 > ➕ 新增整合 > ?搜尋
Xiaomi Miot Auto
或點擊:
從v0.4.4版本開始,元件增加了按帳戶整合時選擇連接設備模式的支援:
適用於區域網路內支援miot-spec協定的設備
為host/token整合的裝置設定小米雲
# configuration.yaml
xiaomi_miot :
username : xiaomi_username
password : xiaomi_password
# server_country: cn # Location of xiaomi cloud: cn(default), de, i2, ru, sg, tw, us
# http_timeout: 15 # Timeout (seconds) for requesting the xiaomi apis
配置 > 設備和服務 > ?整合 > 小米 Miot Auto > 選項 > ☑️ 啟用 miot 雲
期待您的貢獻。
# configuration.yaml
xiaomi_miot :
language : zh # Using the built-in dictionary, currently only `zh` is supported
# https://github.com/al-one/hass-xiaomi-miot/blob/master/custom_components/xiaomi_miot/core/translation_languages.py
translations :
# Global dictionary
idle : '空闲'
busy : '工作中'
# Dictionary for specifying fan modes
fan.mode :
straight wind : '直吹模式'
natural wind : '自然风'
# Dictionary for specifying the drying modes of the washer
washer.drying_level :
moist : '微湿'
extra : '特干'
# configuration.yaml
homeassistant :
customize : !include customize.yaml
# Customize via device model
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 via parent entity
# customize.yaml
domain.your_entity_id :
miot_local : true # Force to read and write data in LAN (integrate by account)
miot_cloud : true # Enable miot cloud for entity (read, write, action)
miot_cloud_write : true # Enable miot cloud (only write)
miot_cloud_action : true # Enable miot cloud (only action)
check_lan : true # Check LAN connection in cloud mode
miio_properties : power,battery # Get miio properties to state attributes
miio_cloud_props : prop.power,event.dev_online
# Custom sub entities
domain.parent_entity_id :
sensor_properties : temperature,humidity,illumination # Miot properties
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 # Reverse color temperature (Requires reload config entry)
yeelight_smooth_on : 2000 # milliseconds (Only for Yeelights in local mode)
yeelight_smooth_off : 3000 # milliseconds (Only for Yeelights in local mode)
climate.your_entity_id :
bind_sensor : sensor.temperature_entity,sensor.humidity_entity # Sensor entities
camera.your_entity_id :
video_attribute : 1 # https://github.com/al-one/hass-xiaomi-miot/issues/11#issuecomment-773054167
keep_streaming : true # Continuously update stream address
cover.your_entity_id :
closed_position : 5 # Change cover state to closed when position <= 5%
deviated_position : 2 # Current position deviation 2% -> 0%, 98% -> 100%
motor_reverse : true # Reverse motor state (Requires reload config entry)
position_reverse : true # Reverse motor position (Requires reload config entry)
open_texts : Open,Up
close_texts : Close,Down
media_player.mitv_entity_id :
bind_xiaoai : media_player.xiaoai_entity_id # Bind xiaoai speaker for turn on TV
domain.your_entity_id_xxxx :
interval_seconds : 30 # Seconds between each update state (Requires reload config entry)
chunk_properties : 10 # Chunk miot properties on update state (LAN)
reverse_state : true # Reverse the On/Off state of a binary sensor
太多的實體屬性將使您的 HA 資料庫變得非常大。如果某些實體屬性對您來說無用,您可以配置
exclude_state_attributes
來忽略它們。
# configuration.yaml
xiaomi_miot :
exclude_state_attributes :
- miot_type
- stream_address
- motion_video_latest
此元件新增了對組態重新載入的支援(以避免在 YAML 設定變更後必須重新啟動 HomeAssistant 實例):
?開發者工具 > YAML 設定 > YAML 設定重新載入 > ?尋找
Xiaomi Miot Auto
(幾乎位於清單底部)
此元件使用輪詢方式取得裝置狀態,因此無法即時監聽部分裝置的事件。
由於HA支援服務回應已經有一段時間了,從v0.7.18開始,該元件不再觸發事件。
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 :
- siid : 2
piid : 1
- siid : 3
piid : 2
update_entity : true # Update to entity state attributes
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
xiaomi_miot.send_command
service : xiaomi_miot.send_command
data :
entity_id : switch.your_entity_id
method : set_power
params :
- on
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
xiaomi_miot.renew_devices
service : xiaomi_miot.renew_devices
data :
username : 80001234 # Xiaomi Account ID / Email / Phone
xiaomi_miot.request_xiaomi_api
service : xiaomi_miot.request_xiaomi_api
data :
entity_id : sensor.your_entity_id
api : /v2/plugin/fetch_plugin
data :
latest_req :
api_version : 10070
plugins :
- model : brand.device.model
更多服務
?開發者工具 > 狀態 > ?過濾實體
# configuration.yaml
logger :
default : warning
logs :
custom_components.xiaomi_miot : debug
配置 > 系統 > ✍️ 日誌
xiaomi_miot.get_token
,輸入裝置名稱關鍵字Write custom log files
和Enable app's debug mode
vevs/logs/misc/devices.txt
中尋找令牌CXVbfhHuSRsi
)