Get States of Devices.
161551
def get_states(self, devices):
        """"""
        header = BASE_HEADERS.copy()
        header['Cookie'] = self.__cookie

        json_data = self._create_get_state_request(devices)

        request = requests.post(
            BASE_URL + 'getStates',
            headers=header,
            data=json_data,
            timeout=10)

        if request.status_code != 200:
            self.__logged_in = False
            self.login()
            self.get_states(devices)
            return

        try:
            result = request.json()
        except ValueError as error:
            raise Exception(
                "Not a valid result for" +
                "getStates, protocol error:" + error)

        self._get_states(result)
654350
def get_device_elements(self):
        """"""
        plain = self._aha_request('getdevicelistinfos')
        dom = xml.dom.minidom.parseString(plain)
        _LOGGER.debug(dom)
        return dom.getElementsByTagName("device")
495336
def _get_state(inspect_results):
    '''
    
    '''
    if inspect_results.get('State', {}).get('Paused', False):
        return 'paused'
    elif inspect_results.get('State', {}).get('Running', False):
        return 'running'
    else:
        return 'stopped'
1224285
def get_device_status(self, t):
        ''''''
        data = {}
        for name, (func, _, _) in self.addons.iteritems():
            data[name] = func(t)
        return data
460382
def get_devices(self):
        
        url = self.base_url + '/net/home_auto_query.lua'
        response = self.session.get(url, params={
            'sid': self.sid,
            'command': 'AllOutletStates',
            'xhr': 0,
        }, timeout=15)
        response.raise_for_status()
        data = response.json()
        count = int(data["Outlet_count"])
        devices = []
        for i in range(1, count + 1):
            device = Device(
                int(data["DeviceID_{0}".format(i)]),
                int(data["DeviceConnectState_{0}".format(i)]),
                int(data["DeviceSwitchState_{0}".format(i)])
            )
            devices.append(device)
        return devices
959060
def devices(self):
        """"""
        log_msg = True
        while True:
            if log_msg:
                self.logger.info("Scanning for devices")

            try:
                device = self.find_device()
                if device:
                    yield device
                    log_msg = True
                else:
                    log_msg = False
            except BackendError as err:
                self.logger.error("Error while scanning for devices: {0}",
                                  err)
                return
            except DeviceError as err:
                self.logger.error("Unable to connect to detected device: {0}",
                                  err)
362528
def get_state(self):
        
        return {
            REG_X: self.index_x.value,
            REG_Y: self.index_y.value,

            REG_U: self.user_stack_pointer.value,
            REG_S: self.system_stack_pointer.value,

            REG_PC: self.program_counter.value,

            REG_A: self.accu_a.value,
            REG_B: self.accu_b.value,

            REG_DP: self.direct_page.value,
            REG_CC: self.get_cc_value(),

            "cycles": self.cycles,
            "RAM": tuple(self.memory._mem) # copy of array.array() values,
        }
1293201
def get(self, deviceId):
        
        measurementsByName = self.measurements.get(deviceId)
        if measurementsByName is None:
            return []
        else:
            return list(measurementsByName.values())
1186040
def desc(self):
        """"""
        return '{0} (ID: {1}) - {2} - {3}'.format(
            self.name, self.device_id, self.type, self.status)
1129368
def devices(self):
        ''''''
        out = self.raw_cmd("devices").communicate()[0].decode("utf-8")
        match = "List of devices attached"
        index = out.find(match)
        if index < 0:
            raise EnvironmentError("adb is not working.")
        return dict([s.split("\t") for s in out[index + len(match):].strip().splitlines() if s.strip()])
945142
def status(self, additional=[]):
        
        self.manager.refresh_client()
        fields = ['batteryLevel', 'deviceDisplayName', 'deviceStatus', 'name']
        fields += additional
        properties = {}
        for field in fields:
            properties[field] = self.content.get(field)
        return properties
180278
def match(self, device):
        """"""
        return all(match_value(getattr(device, k), v)
                   for k, v in self._match.items())
1082715
def devices_in_group(self):
        """"""
        try:
            devices = self.get_parameter('devices')
        except AttributeError:
            return []

        ctor = DeviceFactory
        return [ctor(int(x), lib=self.lib) for x in devices.split(',') if x]
265709
def state(self):
        """"""
        response =  self.SOAPAction('GetSocketSettings', 'OPStatus', self.moduleParameters("1"))
        if response is None:
            return 'unknown'
        elif response.lower() == 'true':
            return ON
        elif response.lower() == 'false':
            return OFF
        else:
            _LOGGER.warning("Unknown state %s returned" % str(response.lower()))
            return 'unknown'
914807
def get_device_state(self):
        
        log.debug("getting device state...")
        cmd, url = DEVICE_URLS["get_device_state"]
        return self._exec(cmd, url)
49318
def devices(self):
        
        eax = self.attributes.get('devices')
        if eax is None:
            eax = self._all_devices
        if not isinstance(eax, list):
            eax = [eax]
        return [str(dev) for dev in eax]
522991
def get_relay_state(self):
        """"""
        self.get_status()
        try:
            self.state = self.data['relay']
        except TypeError:
            self.state = False

        return bool(self.state)