Skip to content

Commit

Permalink
🚰 fix for smith.waterpuri.cxr800 (al-one#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed May 27, 2022
1 parent 116de46 commit f8d81a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions custom_components/xiaomi_miot/core/device_customizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,9 @@
'select_attributes': 'main_state,main_light,night_light,heat,vent,dry,natural_wind,delay_wind',
},
'smith.waterpuri.cxr800': {
'miot_type': 'urn:miot-spec-v2:device:water-purifier:0000A013:smith-cxr800:2',
'sensor_attributes': 'filter_life_level,rwaterconsumption,rsysstate',
'chunk_properties': 1,
'state_property': 'chanitex_wp_gs.rsysstate',
'sensor_properties': 'rwaterconsumption,rfilterwaterlifei,rfilterwaterlifeii,rfilterwaterlifeiii',
},
'shuii.humidifier.jsq002': {
'brightness_for_on': 3,
Expand Down
7 changes: 6 additions & 1 deletion custom_components/xiaomi_miot/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ def __init__(self, config, miot_service: MiotService):
async def async_added_to_hass(self):
await super().async_added_to_hass()
if prop := self.custom_config('state_property'):
self._prop_state = self._miot_service.get_property(prop) or self._prop_state
if '.' in prop:
srv, prop = f'{prop}'.split('.', 1)
if srv := self._miot_service.spec.get_service(srv):
self._prop_state = srv.get_property(prop) or self._prop_state
else:
self._prop_state = self._miot_service.get_property(prop) or self._prop_state
if self._prop_state:
self._attr_icon = self._prop_state.entity_icon
self._attr_device_class = self._prop_state.device_class
Expand Down

0 comments on commit f8d81a7

Please sign in to comment.