Skip to content

Commit

Permalink
remove hangouts.users state, simplifies hangouts.conversations (home-…
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbypunk90 authored and Jacob Mansfield committed Sep 4, 2018
1 parent 4e500b6 commit 6e710ba
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions homeassistant/components/hangouts/hangouts_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,23 +195,15 @@ async def _async_list_conversations(self):
import hangups
self._user_list, self._conversation_list = \
(await hangups.build_user_conversation_list(self._client))
users = {}
conversations = {}
for user in self._user_list.get_all():
users[str(user.id_.chat_id)] = {'full_name': user.full_name,
'is_self': user.is_self}

for conv in self._conversation_list.get_all():
users_in_conversation = {}
for i, conv in enumerate(self._conversation_list.get_all()):
users_in_conversation = []
for user in conv.users:
users_in_conversation[str(user.id_.chat_id)] = \
{'full_name': user.full_name, 'is_self': user.is_self}
conversations[str(conv.id_)] = \
{'name': conv.name, 'users': users_in_conversation}

self.hass.states.async_set("{}.users".format(DOMAIN),
len(self._user_list.get_all()),
attributes=users)
users_in_conversation.append(user.full_name)
conversations[str(i)] = {'id': str(conv.id_),
'name': conv.name,
'users': users_in_conversation}

self.hass.states.async_set("{}.conversations".format(DOMAIN),
len(self._conversation_list.get_all()),
attributes=conversations)
Expand Down

0 comments on commit 6e710ba

Please sign in to comment.