Skip to content

Commit

Permalink
add option configuration_entities
Browse files Browse the repository at this point in the history
add option `diagnostic_entities`
  • Loading branch information
al-one committed Nov 6, 2024
1 parent 80e51e9 commit d160ff2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions custom_components/xiaomi_miot/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ async def async_step_customizing(self, user_input=None):
'fan_services': cv.string,
'exclude_miot_services': cv.string,
'exclude_miot_properties': cv.string,
'configuration_entities': cv.string,
'diagnostic_entities': cv.string,
'cloud_delay_update': cv.string,
}
options = {
Expand Down
7 changes: 7 additions & 0 deletions custom_components/xiaomi_miot/core/device_customizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,13 @@
'reset_mop_life,reset_brush_life,reset_filter_life,reset_detergent_management_level,'
'reset_dust_bag_life',
'select_actions': 'remote_control',
'configuration_entities': 'ai_cleaning,ai_managed_cleaning,use_detergent,defecation_detection,cut_hair_config,'
'solid_dirt_detection,floor_material_detection,room_detection,liquid_dirt_detection,'
'mop_auto_lift,carpet_boost,carpet_avoidance,carpet_cleaning_method,object_detection,'
'dirt_detection,sweep_ai_detection,hot_water_mop_wash,physical_control_locked,volume,'
'auto_water_change,auto_mop_dry,auto_dust_arrest,dust_arrest_frequency,'
'vacuum.detergent_self_delivery,detergent_self_delivery_level',
'diagnostic_entities': 'voltage,water_check_status',
},
'xiaomi.watch.*': {
'sensor_properties': 'current_step_count,current_distance',
Expand Down
15 changes: 15 additions & 0 deletions custom_components/xiaomi_miot/core/hass_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,22 @@ def __init__(self, device: 'Device', conv: 'BaseConv'):

cate = self.custom_config('entity_category') or conv.option.get('entity_category')
if isinstance(cate, str):
cate = EntityCategory(cate) if cate in EntityCategory else None
if cate:
self._attr_entity_category = EntityCategory(cate) if cate in EntityCategory else None
elif not cate:
cats = {
'configuration_entities': EntityCategory.CONFIG,
'diagnostic_entities': EntityCategory.DIAGNOSTIC,
}
for k, v in cats.items():
names = self.custom_config_list(k) or []
if self._miot_property and self._miot_property.in_list(names):
self._attr_entity_category = v
break
if self._miot_action and self._miot_action.in_list(names):
self._attr_entity_category = v
break

self.on_init()
self.device.add_listener(self.on_device_update)
Expand Down
2 changes: 2 additions & 0 deletions custom_components/xiaomi_miot/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@
"close_texts": "close_texts",
"closed_position": "closed_position",
"cloud_delay_update": "cloud_delay_update",
"configuration_entities": "configuration_entities",
"coord_type": "coord_type",
"current_temp_property": "current_temp_property",
"descriptions_for_on": "descriptions_for_on",
"descriptions_for_off": "descriptions_for_off",
"deviated_position": "deviated_position",
"device_class": "device_class",
"diagnostic_entities": "diagnostic_entities",
"disable_location_name": "disable_location_name",
"disable_preset_modes": "disable_preset_modes",
"entity_category": "entity_category",
Expand Down

0 comments on commit d160ff2

Please sign in to comment.