al-one / hass-xiaomi-miot

Automatic integrate all Xiaomi devices to HomeAssistant via miot-spec, support Wi-Fi, BLE, ZigBee devices. 小米米家智能家居设备接入Hass集成
https://miot-spec.com
Apache License 2.0
4.68k stars 664 forks source link

小米空气净化器4 屏幕控制不正常 #1775

Open SodaWithoutSparkles opened 4 months ago

SodaWithoutSparkles commented 4 months ago

Device model / 设备型号

xiaomi.airp.mp4

Component version / 插件版本

0.7.19

HA core version / HA版本

2024.7.2

Integrated mode / 集成方式

Local (本地模式)

The problem / 问题详情

小米空气净化器4 无法打开屏幕或者设置亮度,只能关闭

Entity attributes / 实体属性

preset_modes:
  - Auto
  - Sleep
  - Favorite
  - None
percentage: 66
percentage_step: 33
preset_mode: None
model: xiaomi.airp.mp4
lan_ip: redacted
mac_address: redacted
entity_class: MiotFanEntity
home_room: redacted
exclude_miot_services:
  - custom_service
miot_type: urn:miot-spec-v2:device:air-purifier:0000A007:xiaomi-mp4:1
air_purifier.on: true
air_purifier.fault: 0
air_purifier.mode: 6
air_purifier.fan_level: 1
air_purifier.anion: true
rfid.rfid_tag: redacted
rfid.rfid_factory_id: redacted
rfid.rfid_product_id: "16"
rfid.rfid_time: redacted
rfid.rfid_serial_num: redacted
air_purifier_favorite.fan_level: 10
screen.brightness: 2
physical_controls_locked: false
alarm: true
filter.filter_life_level: 41
filter.filter_used_time: 2089
filter.filter_left_time: 1411
environment.relative_humidity: 71
environment.temperature: 27
environment.air_quality: 0
environment.pm2_5_density: 1
state_updater: lan
sub_entities:
  - environment-3.relative_humidity-1
  - environment-3.temperature-2
  - environment-3.pm2_5_density-4
  - filter-4.filter_life_level-1
  - air_purifier-2.anion-6
  - alarm-6.alarm-1
  - screen-13
  - environment-3.air_quality-3
  - filter-4.filter_used_time-2
  - filter-4.filter_left_time-3
  - physical_controls_locked-8.physical_controls_locked-1
icon: mdi:air-purifier
friendly_name: Xiaomi Smart Air Purifier 4 Air Purifier
supported_features: 9

Home Assistant Logs / 系统日志

N/A

SodaWithoutSparkles commented 4 months ago

实测以下service 可以控制亮度:

service: xiaomi_miot.set_miot_property
data:
  entity_id: fan.xiaomi_mp4_air_purifier
  siid: 13
  piid: 1
  value: 2

可能的 value:

reference: https://home.miot-spec.com/spec?type=urn:miot-spec-v2:device:air-purifier:0000A007:xiaomi-mp4:1

建议把这三个亮度设置为100%, 50% 和0%。就是一个brightness step 为50%的灯实体。或者更好的方式是设置一个下拉式选单 (dropdown)以设置亮度。

SodaWithoutSparkles commented 4 months ago

估计是因为代码里面直接把0, 1, 2 三种模式map 到亮度0%, 1%, 2%。

关掉屏幕亮度理应是0%,但是回传数据是模式2 (屏幕关闭),map 到了亮度 = 2%。不过一个关掉的灯不应该有2%亮度,导致HA 认为灯还在开。

可行的解决方法可能是类似这样:

brightness = [1, 0.5, 0][miot_brightness_mode]

#通过 list index 的方式返回适合的数值