Do a separate query to get device status. This can tell if device
        is on/off, lighting level, etc.
329186
def get_device_status(self, device_id, return_led=0, level=None):
        """"""
        # status['responseCmd2'] is lighting level
        # responseCmd1 contains All-Link Database delta
        # if returnLED = 0. returns light level in responseCmd2
        # if returnLED = 1, returns LED Bit Flags in responseCmd1

        self.logger.info("\nget_device_status for device %s", device_id)
        device_id = device_id.upper()
        status = False

        if not level:
            if return_led == 1:
                level = '01'
            else:
                level = '00'

        if os.path.exists(device_id + CACHE_FILE):
            status = self.get_command_response_from_cache(device_id, '19', level)

        if not status:
            self.logger.info("no cached status for device %s", device_id)
            self.direct_command(device_id, '19', level)

            attempts = 1
            sleep(1)

            status = self.get_buffer_status(device_id)
            while 'success' not in status and attempts < 9:
                status = self.get_command_response_from_cache(device_id, '19', level)
                if not status:
                    if attempts % 3 == 0:
                        self.direct_command(device_id, '19', level)
                    else:
                        sleep(1)
                    status = self.get_buffer_status(device_id)
                attempts += 1
        else:
            self.logger.info("got cached status for device %s", device_id)

        return status
597486
def pause(self, device):
        
        resp = self.post('pause', params={'device': device},
                         return_response=True)
        error = resp.text
        if not error:
            error = None
        return {'success': resp.status_code == requests.codes.ok,
                'error': error}
1116421
def available(self):
        """"""
        if not self.adb_server_ip:
            # python-adb
            return bool(self._adb)

        # pure-python-adb
        try:
            # make sure the server is available
            adb_devices = self._adb_client.devices()

            # make sure the device is available
            try:
                # case 1: the device is currently available
                if any([self.host in dev.get_serial_no() for dev in adb_devices]):
                    if not self._available:
                        self._available = True
                    return True

                # case 2: the device is not currently available
                if self._available:
                    logging.error('ADB server is not connected to the device.')
                    self._available = False
                return False

            except RuntimeError:
                if self._available:
                    logging.error('ADB device is unavailable; encountered an error when searching for device.')
                    self._available = False
                return False

        except RuntimeError:
            if self._available:
                logging.error('ADB server is unavailable.')
                self._available = False
            return False
495908
def value(self):
        
        return (
            -self.enable_device.value
            if self.phase_device.is_active else
            self.enable_device.value
        )
1225606
def get_night_light_state(self):
        """"""
        if not self.camera_extended_properties:
            return None

        night_light = self.camera_extended_properties.get('nightLight')
        if not night_light:
            return None

        if night_light.get('enabled'):
            return 'on'

        return 'off'
426214
def state(self):
        
        # Check if device is disconnected.
        if not self.available:
            return STATE_UNKNOWN
        # Check if device is off.
        if not self.screen_on:
            return STATE_OFF
        # Check if screen saver is on.
        if not self.awake:
            return STATE_IDLE
        # Check if the launcher is active.
        if self.launcher or self.settings:
            return STATE_STANDBY
        # Check for a wake lock (device is playing).
        if self.wake_lock:
            return STATE_PLAYING
        # Otherwise, device is paused.
        return STATE_PAUSED
884401
def _check_device_failover_status(self, device, status):
        '''
        '''

        sync_status = device.tm.cm.sync_status
        sync_status.refresh()
        current_status = (sync_status.entries[self.sync_status_entry]
                          ['nestedStats']['entries']['status']
                          ['description'])
        if status == current_status:
            return True
        return False
754785
def probe_check(name, status, device_type):
    """"""
    status_string = PROBE_STATE.get(int(status), "unknown")

    if status_string == "ok":
        return ok, "{} '{}': {}".format(device_type, name, status_string)

    if status_string == "unknown":
        return unknown, "{} '{}': {}".format(device_type, name, status_string)

    return critical, "{} '{}': {}".format(device_type, name, status_string)
188884
def _check_all_devices_in_sync(self):
        '''
        '''

        if len(self._get_devices_by_failover_status('In Sync')) != \
                len(self.devices):
            msg = "Expected all devices in group to have 'In Sync' status."
            raise UnexpectedDeviceGroupState(msg)
880620
def turn_on(self):
        """"""
        if self.device_status != 'on':
            body = helpers.req_body(self.manager, 'devicestatus')
            body['uuid'] = self.uuid
            body['status'] = 'on'
            head = helpers.req_headers(self.manager)

            r, _ = helpers.call_api('/131airPurifier/v1/device/deviceStatus',
                                    'put', json=body, headers=head)

            if r is not None and helpers.check_response(r, 'airpur_status'):
                self.device_status = 'on'
                return True
            else:
                return False
107316
def get_device_status(host, services=None, zconf=None):
    

    try:
        status = _get_status(
            host, services, zconf, "/setup/eureka_info?options=detail")

        friendly_name = status.get('name', "Unknown Chromecast")
        model_name = "Unknown model name"
        manufacturer = "Unknown manufacturer"
        if 'detail' in status:
            model_name = status['detail'].get('model_name', model_name)
            manufacturer = status['detail'].get('manufacturer', manufacturer)

        udn = status.get('ssdp_udn', None)

        cast_type = CAST_TYPES.get(model_name.lower(),
                                   CAST_TYPE_CHROMECAST)

        uuid = None
        if udn:
            uuid = UUID(udn.replace('-', ''))

        return DeviceStatus(friendly_name, model_name, manufacturer,
                            uuid, cast_type)

    except (requests.exceptions.RequestException, OSError, ValueError):
        return None
737763
def check_status(self, **kwargs):
        
        for work in self:
            work.check_status()

        if kwargs.pop("show", False):
            self.show_status(**kwargs)
1312893
async def get_devices(self):
        """"""
        data = await self.api("devices")
        if self.connected and self.authenticated:
            self._devices = data
        else:
            self._devices = self._devices
        _LOGGER.debug(self._devices)
49161
def __check_state(self):
        """"""
        state = self.__read_device()
        if not state:
            raise UnpluggedError(
                "Gamepad %d is not connected" % self.__device_number)
        if state.packet_number != self.__last_state.packet_number:
            # state has changed, handle the change
            self.__handle_changed_state(state)
            self.__last_state = state
897723
def is_boot_completed(self):
        """"""
        completed = self.adb.getprop('sys.boot_completed')
        if completed == '1':
            self.log.debug('Device boot completed.')
            return True
        return False
177553
def status(self, message, *args, **kwargs):
    """"""
    if self.isEnabledFor(GNUPG_STATUS_LEVEL):
        self._log(GNUPG_STATUS_LEVEL, message, args, **kwargs)
815532
def is_on(self):
        
        if self._type == 'Occupancy':
            return self.status not in CONST.STATUS_ONLINE
        return self.status not in (CONST.STATUS_OFF, CONST.STATUS_OFFLINE,
                                   CONST.STATUS_CLOSED)