Skip to content

Commit

Permalink
style: fix pylint format
Browse files Browse the repository at this point in the history
  • Loading branch information
DoraTiger committed Dec 17, 2024
1 parent 679af9d commit fc0dedb
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions custom_components/xiaomi_home/miot/miot_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,20 +515,17 @@ def parse_miot_property_entity(
prop.icon = self.icon_convert(prop.unit)
device_class = SPEC_PROP_TRANS_MAP['properties'][prop_name][
'device_class']

result = {'platform': platform, 'device_class': device_class}

# optional:
prop_optional = SPEC_PROP_TRANS_MAP['properties'][prop_name].get('optional')
if prop_optional:
prop_optional_state_class = prop_optional.get('state_class')
optional = SPEC_PROP_TRANS_MAP['properties'][prop_name].get('optional')
if optional:
prop_optional_state_class = optional.get('state_class')
if prop_optional_state_class:
result['state_class'] = prop_optional_state_class

prop_optional_unit = prop_optional.get('unit_of_measurement')
prop_optional_unit = optional.get('unit_of_measurement')
if prop_optional_unit and not prop.unit:
result['unit_of_measurement'] = prop_optional_unit

result['unit_of_measurement'] = prop_optional_unit
return result

def spec_transform(self) -> None:
Expand Down Expand Up @@ -559,9 +556,10 @@ def spec_transform(self) -> None:
if 'state_class' in prop_entity:
prop.state_class = prop_entity['state_class']
if 'unit_of_measurement' in prop_entity:
prop.external_unit = self.unit_convert(prop_entity['unit_of_measurement'])
prop.icon = self.icon_convert(prop_entity['unit_of_measurement'])

prop.external_unit = self.unit_convert(
prop_entity['unit_of_measurement'])
prop.icon = self.icon_convert(
prop_entity['unit_of_measurement'])
# general conversion
if not prop.platform:
if prop.writable:
Expand Down

0 comments on commit fc0dedb

Please sign in to comment.