diff --git a/custom_components/xiaomi_miot/__init__.py b/custom_components/xiaomi_miot/__init__.py index 04e9b9b21..0e4379aef 100644 --- a/custom_components/xiaomi_miot/__init__.py +++ b/custom_components/xiaomi_miot/__init__.py @@ -2545,6 +2545,21 @@ def __init__(self, parent, miot_property: MiotProperty, option=None, **kwargs): 'property_description': miot_property.description or miot_property.name, }) + def update_with_properties(self): + pls = self.custom_config_list('with_properties', []) + for p in pls: + prop = self._miot_service.get_property(p) or self._miot_service.spec.get_property(p) + if not prop: + continue + val = prop.from_dict(self.parent_attributes) + self._extra_attrs[prop.name] = val + + def update(self, data=None): + super().update(data) + if not self._available: + return + self.update_with_properties() + def set_parent_property(self, val, prop=None): if prop is None: prop = self._miot_property diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index 9c59ae8d1..d20e8a577 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -44,9 +44,32 @@ 'sensor_properties': 'total_occupied', 'switch_properties': 'radar_switch,count_switch', 'select_properties': 'map_index,traction', - 'number_properties': 'radar_duration', 'button_actions': 'reboot', }, + 'ainice.sensor_occupy.3b:current_occupied': { + 'with_properties': 'has_someone_duration,no_one_duration,total_occupied', + 'device_class': 'occupancy', + }, + 'ainice.sensor_occupy.3b:a_occupied': { + 'with_properties': 'a_someone_duration,a_noone_duration', + 'device_class': 'occupancy', + }, + 'ainice.sensor_occupy.3b:b_occupied': { + 'with_properties': 'b_someone_duration,b_noone_duration', + 'device_class': 'occupancy', + }, + 'ainice.sensor_occupy.3b:c_occupied': { + 'with_properties': 'c_someone_duration,c_noone_duration', + 'device_class': 'occupancy', + }, + 'ainice.sensor_occupy.3b:d_occupied': { + 'with_properties': 'd_someone_duration,d_noone_duration', + 'device_class': 'occupancy', + }, + 'ainice.sensor_occupy.3b:e_occupied': { + 'with_properties': 'e_someone_duration,e_noone_duration', + 'device_class': 'occupancy', + }, 'ainice.sensor_occupy.pr': { 'main_miot_services': 'occupancy_sensor', 'state_property': 'occupancy_sensor.occupancy_status', diff --git a/custom_components/xiaomi_miot/sensor.py b/custom_components/xiaomi_miot/sensor.py index 79f8cea33..5a0609232 100644 --- a/custom_components/xiaomi_miot/sensor.py +++ b/custom_components/xiaomi_miot/sensor.py @@ -514,6 +514,7 @@ def update(self, data=None): super().update(data) if not self._available: return + self.update_with_properties() self._miot_property.description_to_dict(self._state_attrs) @property