本帖最后由 是拖油瓶吖 于 2021-2-18 18:36 编辑
小米拖扫一体机器人用miio_raw接入ha需要安装miio_raw扩展 https://github.com/syssi/xiaomi_raw
设备型号:viomi.vacuum.v7
sensor:
- platform: xiaomi_miio_raw
name: viomi_vacuum_v7_status
host: 192.168.x.x
token: XXXXXXXXXX #填你的机器人的token
sensor_property: "run_state"
default_properties_getter: "get_prop"
default_properties:
- run_state #运行状态 5充电 4回冲 3清扫
- mode #模式 0正常 5遥控
- err_state #错误状态
- battary_life #电量
- box_type #尘盒类型 1 单尘盒
- mop_type #抹布类型 0 没有抹布
- s_time #清扫时间
- s_area #清扫面积
- suction_grade #吸力等级 0安静 1标准 2中档 3强力
- water_grade #水量 11 12 13 水量
- remember_map #是否记忆地图 1记忆
- has_map #是否有地图 1 有
- is_mop #清扫模式 0 1 2 //模式 扫地 拖扫 单拖#
- has_newmap #新地图 未知定义
- mop_route #未知定义
- map_num #地图序号
- map_id #地图id
- platform: template
sensors:
vacuum_status:
friendly_name: '状态'
value_template: "{{ state_attr('sensor.viomi_vacuum_v7_status','run_state') }}"
vacuum_battary:
friendly_name: '电池'
value_template: >
{% if state_attr('sensor.viomi_vacuum_v7_status','battary_life') == 100 %} 已充满
{% else %} {{state_attr('sensor.viomi_vacuum_v7_status','battary_life')}} %
{% endif %}
vacuum_mop:
friendly_name: '模式'
value_template: "{{ state_attr('sensor.viomi_vacuum_v7_status','is_mop') }}"
value_template: >
{% if state_attr('sensor.viomi_vacuum_v7_status','is_mop') == 0 %} 单扫
{% elif state_attr('sensor.viomi_vacuum_v7_status','is_mop') == 1 %} 拖扫
{% elif state_attr('sensor.viomi_vacuum_v7_status','is_mop') == 2 %} 单拖
{% endif %}
vacuum_time:
friendly_name: '清扫时间'
value_template: "{{ state_attr('sensor.viomi_vacuum_v7_status','s_time') }} ′"
vacuum_area:
friendly_name: '清扫面积'
value_template: "{{ state_attr('sensor.viomi_vacuum_v7_status','s_area') }} m²"
vacuum_status_name:
friendly_name: '状态'
value_template: >
{% if state_attr('sensor.viomi_vacuum_v7_status','run_state') == 0 %} 休眠中
{% elif state_attr('sensor.viomi_vacuum_v7_status','run_state') == 1 %} 需要救援
{% elif state_attr('sensor.viomi_vacuum_v7_status','run_state') == 2 %} 暂停
{% elif state_attr('sensor.viomi_vacuum_v7_status','run_state') == 3 %} 清扫中
{% elif state_attr('sensor.viomi_vacuum_v7_status','run_state') == 4 %} 回冲中
{% elif state_attr('sensor.viomi_vacuum_v7_status','run_state') == 5 %} 充电中
{% endif %}
vacuum_water:
friendly_name: '水量'
value_template: >
{% if state_attr('sensor.viomi_vacuum_v7_status','water_grade') == 11 %} 1档
{% elif state_attr('sensor.viomi_vacuum_v7_status','water_grade') == 12 %} 2档
{% elif state_attr('sensor.viomi_vacuum_v7_status','water_grade') == 13 %} 3档
{% endif %}
vacuum_suction:
friendly_name: '吸力'
value_template: >
{% if state_attr('sensor.viomi_vacuum_v7_status','suction_grade') == 0 %} 安静
{% elif state_attr('sensor.viomi_vacuum_v7_status','suction_grade') == 1 %} 标准
{% elif state_attr('sensor.viomi_vacuum_v7_status','suction_grade') == 2 %} 中档
{% elif state_attr('sensor.viomi_vacuum_v7_status','suction_grade') == 3 %} 强力
{% endif %}
vacuum_box_type:
friendly_name: '尘盒'
value_template: >
{% if state_attr('sensor.viomi_vacuum_v7_status','box_type') == 0 %} 未安装
{% elif state_attr('sensor.viomi_vacuum_v7_status','box_type') == 1 %} 单尘盒
{% elif state_attr('sensor.viomi_vacuum_v7_status','box_type') == 2 %} 550ML水箱
{% elif state_attr('sensor.viomi_vacuum_v7_status','box_type') == 3 %} 2合1水箱
{% endif %}
vacuum_mop_type:
friendly_name: '抹布'
value_template: >
{% if state_attr('sensor.viomi_vacuum_v7_status','mop_type') == 0 %} 未安装
{% elif state_attr('sensor.viomi_vacuum_v7_status','mop_type') == 1 %} 已安装
{% endif %}
script:
viomi_vacuum_v7_start:
alias: 开始扫地
sequence:
- service: xiaomi_miio_raw.sensor_raw_command
data_template:
entity_id: sensor.viomi_vacuum_v7_status
method: "set_mode_withroom"
params: [0,1,0]
viomi_vacuum_v7_stop:
alias: 返回充电
sequence:
- service: xiaomi_miio_raw.sensor_raw_command
data_template:
entity_id: sensor.viomi_vacuum_v7_status
如果有大佬愿意花功夫写成插件,可以联系我测试更多状态,
以上状态代表的意思部分是猜的,如果实际使用有不符的请回帖
帖子发代码 缩进全乱了...有问题的话自行调整吧
|