def receive_message(self, message, data):  # noqa: E501 pylint: disable=too-many-return-statements
        """ Called when a multizone message is received. """
        if data[MESSAGE_TYPE] == TYPE_DEVICE_ADDED:
            uuid = data['device']['deviceId']
            name = data['device']['name']
            self._add_member(uuid, name)
            return True

        if data[MESSAGE_TYPE] == TYPE_DEVICE_REMOVED:
            uuid = data['deviceId']
            self._remove_member(uuid)
            return True

        if data[MESSAGE_TYPE] == TYPE_DEVICE_UPDATED:
            uuid = data['device']['deviceId']
            name = data['device']['name']
            self._add_member(uuid, name)
            return True

        if data[MESSAGE_TYPE] == TYPE_MULTIZONE_STATUS:
            members = data['status']['devices']
            members = \
                {member['deviceId']: member['name'] for member in members}
            removed_members = \
                list(set(self._members.keys())-set(members.keys()))
            added_members = list(set(members.keys())-set(self._members.keys()))
            _LOGGER.debug("(%s) Added members %s, Removed members: %s",
                          self._uuid, added_members, removed_members)

            for uuid in removed_members:
                self._remove_member(uuid)
            for uuid in added_members:
                self._add_member(uuid, members[uuid])

            for listener in list(self._status_listeners):
                listener.multizone_status_received()

            return True

        if data[MESSAGE_TYPE] == TYPE_SESSION_UPDATED:
            # A temporary group has been formed
            return True

        if data[MESSAGE_TYPE] == TYPE_CASTING_GROUPS:
            # Answer to GET_CASTING_GROUPS
            return True

        return False
def receive_message ( self , message , data ) : if data [ MESSAGE_TYPE ] == TYPE_DEVICE_ADDED : uuid = data [ 'device' ] [ 'deviceId' ] name = data [ 'device' ] [ 'name' ] self . _add_member ( uuid , name ) return True if data [ MESSAGE_TYPE ] == TYPE_DEVICE_REMOVED : uuid = data [ 'deviceId' ] self . _remove_member ( uuid ) return True if data [ MESSAGE_TYPE ] == TYPE_DEVICE_UPDATED : uuid = data [ 'device' ] [ 'deviceId' ] name = data [ 'device' ] [ 'name' ] self . _add_member ( uuid , name ) return True if data [ MESSAGE_TYPE ] == TYPE_MULTIZONE_STATUS : members = data [ 'status' ] [ 'devices' ] members = { member [ 'deviceId' ] : member [ 'name' ] for member in members } removed_members = list ( set ( self . _members . keys ( ) ) - set ( members . keys ( ) ) ) added_members = list ( set ( members . keys ( ) ) - set ( self . _members . keys ( ) ) ) _LOGGER . debug ( "(%s) Added members %s, Removed members: %s" , self . _uuid , added_members , removed_members ) for uuid in removed_members : self . _remove_member ( uuid ) for uuid in added_members : self . _add_member ( uuid , members [ uuid ] ) for listener in list ( self . _status_listeners ) : listener . multizone_status_received ( ) return True if data [ MESSAGE_TYPE ] == TYPE_SESSION_UPDATED : return True if data [ MESSAGE_TYPE ] == TYPE_CASTING_GROUPS : return True return False
Called when a multizone message is received.