Skip to content

Commit

Permalink
sytle: change logic to suit conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
DoraTiger committed Dec 26, 2024
1 parent 2b2a670 commit 07716ec
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions custom_components/xiaomi_home/miot/miot_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,15 +517,12 @@ def parse_miot_property_entity(
'device_class']
result = {'platform': platform, 'device_class': device_class}
# optional:
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 = optional.get('unit_of_measurement')
if prop_optional_unit and not prop.unit:
result['unit_of_measurement'] = prop_optional_unit
if 'optional' in SPEC_PROP_TRANS_MAP['properties'][prop_name]:
optional = SPEC_PROP_TRANS_MAP['properties'][prop_name]['optional']
if 'state_class' in optional:
result['state_class'] = optional['state_class']
if not prop.unit and 'unit_of_measurement' in optional:
result['unit_of_measurement'] = optional['unit_of_measurement']
return result

def spec_transform(self) -> None:
Expand Down

0 comments on commit 07716ec

Please sign in to comment.