Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into v1
Browse files Browse the repository at this point in the history
# Conflicts:
#	custom_components/xiaomi_miot/core/device_customizes.py
#	custom_components/xiaomi_miot/manifest.json
#	custom_components/xiaomi_miot/sensor.py
  • Loading branch information
al-one committed Dec 2, 2024
2 parents 0553cea + f5e743e commit 079e01b
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 51 deletions.
2 changes: 1 addition & 1 deletion custom_components/xiaomi_miot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ def update_with_properties(self):
if not prop:
continue
val = prop.from_dict(self.parent_attributes)
if prop.value_range and not (prop.range_min() <= val <= prop.range_max()):
if not prop.range_valid(val):
val = None
self._extra_attrs[prop.name] = val

Expand Down
1 change: 1 addition & 0 deletions custom_components/xiaomi_miot/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
MiotSpec,
MiotService,
)
from .core.const import AlarmControlPanelState

_LOGGER = logging.getLogger(__name__)
DATA_KEY = f'{ENTITY_DOMAIN}.{DOMAIN}'
Expand Down
1 change: 0 additions & 1 deletion custom_components/xiaomi_miot/core/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class CameraState(StrEnum):
except (ModuleNotFoundError, ImportError):
class AlarmControlPanelState(StrEnum):
"""Alarm control panel entity states."""

DISARMED = "disarmed"
ARMED_HOME = "armed_home"
ARMED_AWAY = "armed_away"
Expand Down
64 changes: 27 additions & 37 deletions custom_components/xiaomi_miot/core/device_customizes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from .converters import *

CHUNK_1 = {
'chunk_properties': 1,
}

ENERGY_KWH = {
'state_class': 'total_increasing',
'device_class': 'energy',
Expand All @@ -16,6 +20,8 @@
'number_properties': 'curtain-2.mode-10,default_close_position',
},
'090615.curtain.*': {
'auto_cloud': True,
'chunk_properties': 1,
'exclude_miot_properties': 'motor_control',
},
'090615.plug.plus01': {
Expand Down Expand Up @@ -114,27 +120,15 @@
'select_properties': 'mode',
},

'babai.curtain.190812': {
'chunk_properties': 1,
},
'babai.curtain.at5810': {
'chunk_properties': 1,
},
'babai.curtain.bb82mj': {
'chunk_properties': 1,
},
'babai.curtain.lsxf83': {
'chunk_properties': 1,
},
'babai.curtain.m515e': {
'chunk_properties': 1,
},
'babai.curtain.mtx850': {
'chunk_properties': 1,
},
'babai.curtain.yilc3': {
'chunk_properties': 1,
},
'babai.curtain.190812': CHUNK_1,
'babai.curtain.at5810': CHUNK_1,
'babai.curtain.bb82cb': CHUNK_1,
'babai.curtain.bb82mj': CHUNK_1,
'babai.curtain.cmb5': CHUNK_1,
'babai.curtain.lsxf83': CHUNK_1,
'babai.curtain.m515e': CHUNK_1,
'babai.curtain.mtx850': CHUNK_1,
'babai.curtain.yilc3': CHUNK_1,
'bkrobo.chair.*': {
'sensor_properties': 'sit_state,power_state,recharge',
'switch_properties': 'on,setcheck',
Expand Down Expand Up @@ -603,12 +597,8 @@
'sensor_properties': 'status',
'switch_properties': 'mode,motor_reverse',
},
'dooya.curtain.m7': {
'chunk_properties': 1,
},
'dooya.curtain.m7li': {
'chunk_properties': 1,
},
'dooya.curtain.m7': CHUNK_1,
'dooya.curtain.m7li': CHUNK_1,
'dooya.curtain.*': {
'auto_cloud': True,
'exclude_miot_properties': 'fault',
Expand Down Expand Up @@ -671,8 +661,9 @@
'select_properties': 'speed_control',
},
'giot.bhf_light.v1ibhw': {
'sensor_properties': 'custom.status',
'switch_properties': 'heating,blow,ventilation,dryer,uv,horizontal_swing,night_light_switch',
'exclude_miot_properties': 'custom.status,setting,msga,msgb',
'exclude_miot_properties': 'setting,msga,msgb',
},

'hfjh.fishbowl.v1': {
Expand Down Expand Up @@ -808,9 +799,7 @@
'switch_properties': 'on,time_watermark,motion_detection',
'number_properties': 'image_rollover,alarm_interval',
},
'isleep.blanket.hs2205': {
'chunk_properties': 1,
},
'isleep.blanket.hs2205': CHUNK_1,
'isleep.blanket.*': {
'sensor_properties': 'fault,temperature,water_level',
'select_properties': 'mode,sleep_level',
Expand Down Expand Up @@ -1214,6 +1203,7 @@
'miot_type': 'urn:miot-spec-v2:device:air-conditioner:0000A004:qdhkl-b23:2',
},
'qjiang.acpartner.wb20': {
'chunk_properties': 1,
'sensor_properties': 'switch.temperature',
'exclude_miot_services': 'air_condition_outlet_matching,matching_action',
'exclude_miot_properties': 'fault',
Expand Down Expand Up @@ -1277,9 +1267,7 @@
'qmi.plug.*': {
'sensor_properties': 'power_consumption',
},
'qushui.bed.001': {
'chunk_properties': 1,
},
'qushui.bed.001': CHUNK_1,
'qushui.bed.*': {
'chunk_properties': 1,
'switch_properties': 'ai_on',
Expand Down Expand Up @@ -1333,9 +1321,7 @@
'select_attributes': 'main_state,main_light,night_light,heat,vent,dry,natural_wind,delay_wind',
},

'smartj.curtain.sjdt82': {
'chunk_properties': 1,
},
'smartj.curtain.sjdt82': CHUNK_1,
'smith.blanket.cxma1': {
'sensor_properties': 'fault,temperature',
'select_properties': 'water_level,quilt_dry',
Expand Down Expand Up @@ -1814,12 +1800,16 @@
'motor_strong,motor_high,motor_med,motor_med_l,motor_low,motor_silent,'
'motor_favorite,motor_set_speed',
},
'zhimi.airpurifier.ma2:filter_life_level': {
'state_class': 'measurement',
},
'zhimi.airpurifier.mb4': {
'sensor_properties': 'moto_speed_rpm',
'switch_properties': 'alarm',
'number_properties': 'favorite_speed,aqi_updata_heartbeat,brightness',
},
'zhimi.airpurifier.vb2:temperature': {
'state_class': 'measurement',
'unit_of_measurement': '°C',
},
'zhimi.airpurifier.za1': {
Expand Down
29 changes: 20 additions & 9 deletions custom_components/xiaomi_miot/core/miot_local_devices.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
MIOT_LOCAL_MODELS = [
# '090615.curtain.jldj03',
# '090615.curtain.kcz82d', # -4004
# '090615.curtain.ptx82', # -4004
# '090615.curtain.sidt82', # -4004
# '090615.curtain.ws9856',
# '090615.curtain.wsdml1', # -4004
# '090615.curtain.ykgc82', # -4004
# '090615.curtain.zsdj35', # -4004
# '090615.curtain.zsdj82', # -4004
'090615.curtain.jldj03',
'090615.curtain.kcz82d',
'090615.curtain.ptx82',
'090615.curtain.sidt82',
'090615.curtain.ws9856',
'090615.curtain.wsdml1',
'090615.curtain.ykgc82',
'090615.curtain.zsdj35',
'090615.curtain.zsdj82',
'090615.gateway.ac10',
'090615.gateway.ktvrf',
'090615.plug.plus01',
Expand Down Expand Up @@ -264,6 +264,7 @@
'dreame.vacuum.r2247',
'dreame.vacuum.r2254',
'dreame.vacuum.r2257o',
'dreame.vacuum.r2312',
'e11035.airer.t10l',
'e11035.airer.t10xfh',
'era.diffuser.ws01',
Expand All @@ -288,6 +289,7 @@
'gerwin.curtain.gm24tf',
'gerwin.curtain.gm25xm',
'gerwin.curtain.gm35xm',
'giot.bhf_light.v1ibhw',
'giot.light.aise01',
'giot.tow_w.v1itrw',
'gtop.light.c02',
Expand Down Expand Up @@ -451,6 +453,7 @@
'mibx5.washer.v11',
'mibx5.washer.v6',
'midjd.fridge.501b',
'midjd.fridge.516',
'midjd6.fridge.430',
'midjd6.fridge.4301',
'midjd6.fridge.430b',
Expand Down Expand Up @@ -654,6 +657,7 @@
'viomi.fridge.u46',
'viomi.fridge.u47',
'viomi.fridge.u54',
'viomi.fryer.v3',
'viomi.heater.v10',
'viomi.heater.v4',
'viomi.heater.v5',
Expand Down Expand Up @@ -715,6 +719,7 @@
'wzt.desk.h101',
'xiaomi.airc.h09h00',
'xiaomi.airc.r24r00',
'xiaomi.airc.r33r00',
'xiaomi.airc.r34r00',
'xiaomi.airc.rr2r00',
'xiaomi.aircondition.c10',
Expand Down Expand Up @@ -778,6 +783,7 @@
'xiaomi.airp.va2b',
'xiaomi.airp.va3',
'xiaomi.airp.va4',
'xiaomi.bhf_light.s1',
'xiaomi.bhf_light.v1',
'xiaomi.blanket.mj1',
'xiaomi.blanket.mj2',
Expand All @@ -787,6 +793,7 @@
'xiaomi.dishwasher.s2',
'xiaomi.dishwasher.v02',
'xiaomi.fan.p43',
'xiaomi.fan.p45',
'xiaomi.fan.p51',
'xiaomi.feeder.iv2001',
'xiaomi.feeder.pi2001',
Expand All @@ -797,10 +804,12 @@
'xiaomi.heater.ma8',
'xiaomi.hood.jyjss2',
'xiaomi.hood.ymv5',
'xiaomi.humidifier.3lite',
'xiaomi.humidifier.airmx',
'xiaomi.humidifier.p1200',
'xiaomi.humidifier.p3',
'xiaomi.kettle.mek01',
'xiaomi.kettle.v21',
'xiaomi.light.ceil04',
'xiaomi.light.cfan',
'xiaomi.light.lamp30',
Expand Down Expand Up @@ -843,6 +852,7 @@
'xiaomi.vacuum.d102ev',
'xiaomi.vacuum.d103cn',
'xiaomi.vacuum.d106gl',
'xiaomi.vacuum.d110ch',
'xiaomi.waterheater.ym02',
'xiaomi.waterheater.ym05',
'xiaomi.waterheater.yms2',
Expand All @@ -863,6 +873,7 @@
'yeelink.bhf_light.v15',
'yeelink.bhf_light.v17',
'yeelink.bhf_light.v18',
'yeelink.bhf_light.v20',
'yeelink.bhf_light.v6',
'yeelink.bhf_light.v8',
'yeelink.controller.v2',
Expand Down
11 changes: 11 additions & 0 deletions custom_components/xiaomi_miot/core/miot_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,17 @@ def range_step(self):
return self.value_range[2]
return None

def range_valid(self, val):
if not self.value_range:
return True
range_min = self.range_min()
range_max = self.range_max()
if None in [range_min, range_max]:
return True
if val == None:
return False
return range_min <= val <= range_max

@property
def is_bool(self):
return self.format == 'bool'
Expand Down
5 changes: 2 additions & 3 deletions custom_components/xiaomi_miot/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,8 @@ def native_value(self):
if key in self._state_attrs:
return f'{self._state_attrs[key]}'.lower()
val = prop.from_dict(self._state_attrs)
if prop.value_range:
if not prop.range_min() <= val <= prop.range_max():
val = None
if not prop.range_valid(val):
val = None
return val

def before_select_modes(self, prop, option, **kwargs):
Expand Down

0 comments on commit 079e01b

Please sign in to comment.