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.69k stars 661 forks source link

绿米空调伴侣 P3 接入后无法追踪电量消耗 #234

Closed MapleEve closed 3 years ago

MapleEve commented 3 years ago

问题场景:

HAAS 在最近的版本中可以单独通过传感器的功率来计量设备耗电,但是 miot auto 中接入的设备,甚至是 raw 接入的设备都无法在计量中被选中,只有接入网关的设备才可以被选中,且P3空调网关的状态显示错误

具体可以在下面问题描述中查看

问题 Model:

lumi.acpartner.mcn02 lumi.aircondition.acn05

问题描述:

lumi.aircondition.acn05

code_format: null
changed_by: null
code_arm_required: false
model: lumi.aircondition.acn05
lan_ip: 192.168.0.41
mac_address: 54:XX:XX:XX:A7:7B
firmware_version: 3.1.4_0050
hardware_version: ''
entity_class: MiotAlarmEntity
miot_type: urn:miot-spec-v2:device:air-conditioner:0000A004:lumi-acn05:1
arming.arming_mode.error: '-704083036 Device operation timeout'
arming.arming_change.error: '-704030013 Property is not readable'
arming.customize_mode_one.error: '-704083036 Device operation timeout'
arming.customize_mode_two.error: '-704083036 Device operation timeout'
arming.customize_mode_three.error: '-704083036 Device operation timeout'
arming.customize_mode_four.error: '-704083036 Device operation timeout'
arming.customize_mode_five.error: '-704083036 Device operation timeout'
arming.customize_mode_six.error: '-704083036 Device operation timeout'
arming.delay_time_basic.error: '-704083036 Device operation timeout'
arming.alarm_duration_basic.error: '-704083036 Device operation timeout'
arming.alarm_vlume_basic.error: '-704083036 Device operation timeout'
arming.delay_time_home.error: '-704083036 Device operation timeout'
arming.alarm_duration_home.error: '-704083036 Device operation timeout'
arming.alarm_volume_home.error: '-704083036 Device operation timeout'
arming.delay_time_away.error: '-704083036 Device operation timeout'
arming.alarm_duration_away.error: '-704083036 Device operation timeout'
arming.alarm_volume_away.error: '-704083036 Device operation timeout'
arming.delay_time_sleep.error: '-704083036 Device operation timeout'
arming.alarm_duration_sleep.error: '-704083036 Device operation timeout'
arming.alarm_volume_sleep.error: '-704083036 Device operation timeout'
arming.target_arming_mode.error: '-704083036 Device operation timeout'
arming.alarm.error: '-704083036 Device operation timeout'
arming.sound_name_basic.error: '-704083036 Device operation timeout'
arming.sound_name_home.error: '-704083036 Device operation timeout'
arming.sound_name_away.error: '-704083036 Device operation timeout'
arming.sound_name_sleep.error: '-704083036 Device operation timeout'
arming.stop_preview.error: '-704083036 Device operation timeout'
weather_bind-16-1: '{"did":"lumi.158d000578fc40","model":"lumi.weather.v1"}'
switch_control.error: '-704030013 Property is not readable'
temperature_alarm-13-1.error: '-704083036 Device operation timeout'
device_protect.power_alarm.error: '-704083036 Device operation timeout'
power_consumption: 0.74
electric_power-12-2: 9
ac_function.ac_ctrl_range: >-
  {"match":0,"models":[{"mode":0,"speeds":[0,1,2,3],"temps":[16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],"directs":[1],"type":2,"light":[0,1],"disD":0,"disL":1},{"mode":1,"speeds":[0,1,2,3],"temps":[16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],"directs":[1],"type":2,"light":[0,1],"disD":0,"disL":1},{"mode":2,"speeds":[0,1,2,3],"temps":[],"directs":[1],"type":2,"light":[0,1],"disD":0,"disL":1},{"mode":3,"speeds":[1,2,3],"temps":[],"directs":[1],"type":2,"light":[0,1],"disD":0,"disL":1},{"mode":4,"speeds":[0],"temps":[],"directs":[1],"type":2,"light":[0,1],"disD":0,"disL":1}]}
ac_function.match_status: 1
ac_function.set_ele_info.error: '-704030013 Property is not readable'
ac_function.ac_type: 2
ac_function.ac_mode: 1
ac_function.brand_id: 137
ac_function.remote_id: 11842
ac_function.ac_state: P1_M0_T21_S3_D0
ac_function.quick_cool_time: 10
ac_function.quick_cool: 0
ac_function.sleep_cfg: '[0]'
ac_function.eco_mode: 0
ac_function.eco_mode_time: 30
ac_function.match_pro.error: '-704030013 Property is not readable'
ac_function.ir_learn.error: '-704030013 Property is not readable'
ac_function.ir_learn_del.error: '-704030013 Property is not readable'
ac_function.report_ir_learn.error: '-704083036 Device operation timeout'
ac_function.report_ir_learn_key: ''
ac_function.send_learn_cmd.error: '-704030013 Property is not readable'
ac_function.sleep_status: 0
match_download_retry-11-24.error: '-704030013 Property is not readable'
play_spec_audio.error: '-704083036 Device operation timeout'
play_spec_audio_time-9-2.error: '-704030013 Property is not readable'
play_spec_audio.play_cycle.error: '-704083036 Device operation timeout'
play_spec_audio.stop_play.error: '-704030013 Property is not readable'
play_spec_audio.audio_list.error: '-704083036 Device operation timeout'
play_spec_audio.language_list.error: '-704083036 Device operation timeout'
accidental_deletion.on_off: 0
indicator_light.error: '-704083036 Device operation timeout'
indicator_light.effective_time.error: '-704083036 Device operation timeout'
fan_control.fan_level: 3
fan_control.vertical_swing: true
switch.on: true
air_conditioner.on: false
air_conditioner.mode: 2
air_conditioner.fault.error: '-704083036 Device operation timeout'
target_temperature-10-4: 21
illumination-8-1.error: '-704083036 Device operation timeout'
alarm.error: '-704083036 Device operation timeout'
alarm.volume.error: '-704083036 Device operation timeout'
state_updater: cloud
sub_entities:
  - power_consumption-12.power_consumption-1
  - power_consumption-12.electric_power-2
friendly_name: 书房空调网关
supported_features: 0

相关传感器

entity_class: MiotSensorSubEntity
parent_entity_id: alarm_control_panel.lumi_acn05_a77b_arming
service_description: power-consumption
property_description: electric-power
electric_power-12-2: 9
friendly_name: 书房空调功率
supported_features: 0
device_class: power

lumi.acpartner.mcn02

image

hvac_modes:
  - auto
  - cool
  - heat
  - dry
  - fan_only
  - 'off'
min_temp: 16
max_temp: 30
target_temp_step: 1
fan_modes:
  - Auto
  - Low
  - Medium
  - High
swing_modes:
  - 'Off'
  - Vertical
current_temperature: null
temperature: 16
fan_mode: Auto
swing_mode: Vertical
model: lumi.acpartner.mcn02
lan_ip: 192.168.0.33
mac_address: XX:XX:XX:XX:0A:XX
firmware_version: 2.1.8_0009
hardware_version: ''
entity_class: MiotClimateEntity
miot_type: urn:miot-spec-v2:device:air-conditioner:0000A004:lumi-mcn02:1
air_conditioner.on: true
air_conditioner.mode: 3
target_temperature-2-3: 16
fan_control.fan_level: 0
fan_control.vertical_swing: true
state_updater: cloud
electric_power: 862.89
power_cost_today: 0
power_cost_month: 13.36
friendly_name: 副卧空调
supported_features: 41

相关传感器

state_class: measurement
entity_class: BaseSensorSubEntity
parent_entity_id: climate.lumi_mcn02_0a98_air_conditioner
electric_power: 94.22
unit_of_measurement: W
friendly_name: 副卧空调功率
supported_features: 0
device_class: power

正常可以统计到的插座: image

无主体数据,可能我不知道需要什么命令调出,如果有什么需要补充的可以留言,必回,感谢。

截图:

image

MapleEve commented 3 years ago

可能传感器我选择错了,应该是 _energy 后缀的,但是不管是 auto 还是 raw 都把用电量写在 consumption 里面。

网关用的是 energy 后缀

MapleEve commented 3 years ago

另外空调伴侣 P3 的耗电量应该是 kWh 目前我看到里面显示的是 Wh,计量单位错误了

al-one commented 3 years ago

HA可计量传感器实体(功率、用电量)的统计异常已经在v0.4.9版本中修复了,请升级后再观察。关于用电量数据,请将设备共享给米家账号143050915

MapleEve commented 3 years ago

出现以上问题已经升级0.4.9版本并重启了 HA,是否需要删除设备重新添加? 以上两个 model 已经共享给 Alone2

HA可计量传感器实体(功率、用电量)的统计异常已经在v0.4.9版本中修复了,请升级后再观察。关于用电量数据,请将设备共享给米家账号143050915

al-one commented 3 years ago

不需要重新添加。

MapleEve commented 3 years ago

不需要重新添加。

重启后 lumi.acpartner.mcn02 的耗电数据已经好了

但是 state_class: total_increasing 这个我看过官方文档写的是总耗电用这个,如果是周期重置的需要用到别的

https://developers.home-assistant.io/docs/core/entity/sensor/#how-to-choose-state_class-and-last_reset

他的传感器有两个,一个是日耗电一个是月耗电,没有像插座一样的「总」耗电 (这个不确定

al-one commented 3 years ago

The sensor's value may reset to 0, and its value can only increase: state class total_increasing. Examples: energy consumption aligned with a billing cycle, e.g. monthly, an energy meter resetting to 0 every time it's disconnected

日耗电和月耗电均为周期性总值,会重置为0,因此state_class应为total_increasing

al-one commented 3 years ago

无网关状态,无法修改网关状态「是否在家、是否关闭、是否离家」

lumi.aircondition.acn05网关功能因小米云端接口无法正确返回数据,因此无法支持。(该设备可能支持本地miot协议,请尝试通过token集成它。)


空调插座功率可以在传感器中显示,但是无法通过 HAAS 的 Energy 功能进行追踪 功率无单位,在 raw 中可以自定义 mapping 来加入单位,但是也无法通过 Energy 进行追踪

已在 https://github.com/al-one/hass-xiaomi-miot/commit/2ef57cd8fe3560c412223d0e622b4688d78febd4 中修复,请更新到master分支后查看。

MapleEve commented 3 years ago

无网关状态,无法修改网关状态「是否在家、是否关闭、是否离家」

lumi.aircondition.acn05网关功能因小米云端接口无法正确返回数据,因此无法支持。(该设备可能支持本地miot协议,请尝试通过token集成它。)

空调插座功率可以在传感器中显示,但是无法通过 HAAS 的 Energy 功能进行追踪 功率无单位,在 raw 中可以自定义 mapping 来加入单位,但是也无法通过 Energy 进行追踪

已在 2ef57cd 中修复,请更新到master分支后查看。

同时报错的还有

custom_components.xiaomi_miot.climate custom_components.xiaomi_miot.alarm_control_panel

image

意味着 Local 模式接入不可用

al-one commented 3 years ago

我在抓包过程成发现米家APP是使用miot协议和lumi.aircondition.acn05交互的,不知道有没有可能是一次性查询的属性数量过多或者太频繁造成的。你可以尝试在本地模式下为该设备添加自定义属性

# customize.yaml
climate.lumi_acn05_entity_id:
  chunk_properties: 8 # 减少每次查询属性的个数
  exclude_miot_services: arming,play_spec_audio # 排除一些不可用的服务以减少设备负担
al-one commented 3 years ago

如果上述方法仍然在不可用,那只能用云端模式了。