Skip to content

Commit

Permalink
Merge pull request #228 from blakadder/patch-4
Browse files Browse the repository at this point in the history
Add battery level icon to vacuum entity
  • Loading branch information
ha0y authored Aug 28, 2021
2 parents 674ca88 + 64c7e51 commit ca173f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion custom_components/xiaomi_miot_raw/deps/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"sensor": {
"air_fryer",
"air_monitor",
"battery",
"chair",
"chair_customize",
"cooker",
Expand Down Expand Up @@ -227,4 +228,4 @@
"ppm" : CONCENTRATION_PARTS_PER_MILLION , # ppm浓度
"lux" : LIGHT_LUX , # 勒克斯(照度)
"mg/m3" : CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER , # 毫克每立方米
}
}
8 changes: 7 additions & 1 deletion custom_components/xiaomi_miot_raw/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def supported_features(self):
s |= SUPPORT_STOP
if self._did_prefix + 'mode' in self._mapping:
s |= SUPPORT_FAN_SPEED
if 'battery_battery_level' in self._mapping:
if self._did_prefix + 'battery_level' in self._mapping or \
'battery_battery_level' in self._mapping:
s |= SUPPORT_BATTERY
if 'a_l_battery_start_charge' in self._mapping:
s |= SUPPORT_RETURN_HOME
Expand Down Expand Up @@ -230,6 +231,11 @@ def _handle_platform_specific_attrs(self):
self._state = k
except:
pass
try:
self._battery_level = self._state_attrs.get(self._did_prefix + 'battery_level') or \
self._state_attrs.get('battery_battery_level')
except:
pass
try:
self._fan_speed = self.get_key_by_value(self._ctrl_params['mode'],self._state_attrs.get(self._did_prefix + 'mode'))
except KeyError:
Expand Down

0 comments on commit ca173f4

Please sign in to comment.