Skip to content

Commit

Permalink
deprecated some sub entities
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Oct 31, 2024
1 parent 75da37b commit ca2c312
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 103 deletions.
42 changes: 0 additions & 42 deletions custom_components/xiaomi_miot/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ async def async_added_to_hass(self):
if rev is not None:
self._vars['reverse_state'] = rev

async def async_update_for_main_entity(self):
await super().async_update_for_main_entity()
self._update_sub_entities(['illumination', 'no_motion_duration'], domain='sensor')

@property
def is_on(self):
ret = self._state
Expand Down Expand Up @@ -221,7 +217,6 @@ async def async_update_for_main_entity(self):
if self.custom_config_bool('use_ble_object', True):
await self.async_update_ble_data()
await super().async_update_for_main_entity()
self._update_sub_entities(['illumination', 'no_motion_duration'], domain='sensor')

async def async_update_ble_data(self):
did = self.miot_did
Expand Down Expand Up @@ -312,43 +307,6 @@ def __init__(self, config, miot_service: MiotService):
self._prop_state.name if self._prop_state else 'status',
)

async def async_update(self):
await super().async_update()
if not self._available:
return
from .fan import MiotModesSubEntity
add_fans = self._add_entities.get('fan')
pls = self._miot_service.get_properties(
'mode', 'washing_strength', 'nozzle_position', 'heat_level',
)
seat = self._miot_service.spec.get_service('seat')
if seat:
prop = seat.get_property('heat_level')
if prop:
pls.append(prop)
else:
self._update_sub_entities(
['heating', 'deodorization'],
[seat],
domain='switch',
)
for p in pls:
if not p.value_list and not p.value_range:
continue
if p.name in self._subs:
self._subs[p.name].update()
elif add_fans:
opt = None
if p.name in ['heat_level']:
opt = {
'power_property': p.service.bool_property('heating'),
}
self._subs[p.name] = MiotModesSubEntity(self, p, opt)
add_fans([self._subs[p.name]], update_before_add=True)

if self._prop_power:
self._update_sub_entities(self._prop_power, None, 'switch')

@property
def icon(self):
return 'mdi:toilet'
Expand Down
3 changes: 0 additions & 3 deletions custom_components/xiaomi_miot/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ async def async_update(self):
continue
self._update_sub_entities(p, None, 'switch')

if self._miot_service.name in ['ptc_bath_heater']:
self._update_sub_entities(None, ['light', 'light_bath_heater'], domain='light')

if self._miot_service.get_action('start_wash'):
pnm = 'action_wash'
prop = self._miot_service.get_property('status')
Expand Down
2 changes: 1 addition & 1 deletion custom_components/xiaomi_miot/core/device_customizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2217,7 +2217,7 @@
},
{
'class': MiotLightConv,
'services': ['night_light', 'ambient_light', 'plant_light'],
'services': ['night_light', 'ambient_light', 'plant_light', 'light_bath_heater'],
},
{
'class': MiotLightConv,
Expand Down
5 changes: 0 additions & 5 deletions custom_components/xiaomi_miot/humidifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ async def async_update(self):
num = round(num * fac)
self._attr_target_humidity = num

if self._prop_water_level and self._prop_water_level.writeable:
self._update_sub_entities(
[self._prop_water_level.name],
domain='number_select',
)
add_fans = self._add_entities.get('fan')
for p in self._mode_props:
pnm = p.full_name
Expand Down
34 changes: 0 additions & 34 deletions custom_components/xiaomi_miot/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,6 @@ async def async_update(self):
})
self._prop_state.description_to_dict(self._state_attrs)

async def async_update_for_main_entity(self):
await super().async_update_for_main_entity()

self._update_sub_entities(
['motor_control', 'backrest_angle', 'leg_rest_angle'],
['bed', 'backrest_control', 'leg_rest_control'],
domain='cover',
)

@property
def device_class(self):
"""Return the class of this entity."""
Expand Down Expand Up @@ -266,31 +257,6 @@ def __init__(self, config, miot_service: MiotService):
'Idle', 'Completed', 'Shutdown', 'CookFinish', 'Pause', 'Paused', 'Fault', 'Error', 'Stop', 'Off',
)

async def async_update(self):
await super().async_update()
if not self._available:
return
if self._prop_state:
self._update_sub_entities(
['target_temperature'],
domain='number',
)
add_selects = self._add_entities.get('select')
pls = self._miot_service.get_properties(
'mode', 'cook_mode', 'heat_level', 'target_time', 'target_temperature',
)
for p in pls:
if p.name in self._subs:
self._subs[p.name].update_from_parent()
elif not (p.value_list or p.value_range):
continue
elif add_selects:
from .select import MiotSelectSubEntity
if p.writeable:
self._subs[p.name] = MiotSelectSubEntity(self, p)
if p.name in self._subs:
add_selects([self._subs[p.name]], update_before_add=True)

@property
def is_on(self):
val = self._prop_state.from_dict(self._state_attrs)
Expand Down
18 changes: 0 additions & 18 deletions custom_components/xiaomi_miot/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,6 @@ async def async_added_to_hass(self):
self._subs[fnm] = MiotSwitchActionSubEntity(self, prop, act)
add_switches([self._subs[fnm]], update_before_add=True)

async def async_update(self):
await super().async_update()
if not self._available:
return
self._update_sub_entities(
['heat_level'],
['massager'],
domain='fan',
option={
'power_property': self._miot_service.get_property('heating'),
},
)
self._update_sub_entities(
['mode', 'massage_strength', 'massage_part', 'massage_manipulation'],
['massager'],
domain='number_select' if self.entry_config_version >= 0.3 else 'fan',
)


class SwitchSubEntity(ToggleSubEntity, BaseEntity):
def __init__(self, parent, attr='switch', option=None, **kwargs):
Expand Down

0 comments on commit ca2c312

Please sign in to comment.