Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix get homeinfo error #80

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions custom_components/xiaomi_home/miot/miot_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ def get_homeinfos(self) -> dict:
'dids': room.get('dids', [])
}
for room in home.get('roomlist', [])
if 'id' in room
},
'group_id': calc_group_id(
uid=home['uid'], home_id=home['id']),
Expand All @@ -493,7 +494,10 @@ def get_homeinfos(self) -> dict:
home_infos['homelist'][home_id]['dids'].extend(info['dids'])
for room_id, info in info['room_info'].items():
home_infos['homelist'][home_id]['room_info'].setdefault(
room_id, {'dids': []})
room_id, {
'room_id': room_id,
'room_name': '',
'dids': []})
home_infos['homelist'][home_id]['room_info'][
room_id]['dids'].extend(info['dids'])

Expand Down Expand Up @@ -605,30 +609,33 @@ async def get_devices_async(
device_type, None) or {}).items():
if isinstance(home_ids, list) and home_id not in home_ids:
continue
home_name: str = home_info['home_name']
group_id: str = home_info['group_id']
homes[device_type].setdefault(
home_id, {
'home_name': home_info['home_name'],
'home_name': home_name,
'uid': home_info['uid'],
'group_id': home_info['group_id'],
'group_id': group_id,
'room_info': {}
})
devices.update({did: {
'home_id': home_id,
'home_name': home_info['home_name'],
'home_name': home_name,
'room_id': home_id,
'room_name': home_info['home_name'],
'group_id': home_info['group_id']
'room_name': home_name,
'group_id': group_id
} for did in home_info.get('dids', [])})
for room_id, room_info in home_info.get('room_info').items():
room_name: str = room_info.get('room_name', '')
homes[device_type][home_id]['room_info'][
room_id] = room_info['room_name']
room_id] = room_name
devices.update({
did: {
'home_id': home_id,
'home_name': home_info['home_name'],
'home_name': home_name,
'room_id': room_id,
'room_name': room_info['room_name'],
'group_id': home_info['group_id']
'room_name': room_name,
'group_id': group_id
} for did in room_info.get('dids', [])})
dids = sorted(list(devices.keys()))
results: dict[str, dict] = await self.get_devices_with_dids_async(
Expand Down
Loading