<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def available(self) -> bool: """Return if device is online or not."""

        # Both ability to retrieve state from MyQ cloud AND device itself has
        # to be online.
        is_available = self.api.online and \
            next(
                attr['Value'] for attr in
                self._device_json.get('Attributes', [])
                if attr.get('AttributeDisplayName') == 'online') == "True"

        return is_available