def read(self, sensors):
        """Read a set of keys."""
        payload = {'destDev': [], 'keys': list(set([s.key for s in sensors]))}
        if self.sma_sid is None:
            yield from self.new_session()
            if self.sma_sid is None:
                return False
        body = yield from self._fetch_json(URL_VALUES, payload=payload)

        # On the first 401 error we close the session which will re-login
        if body.get('err') == 401:
            _LOGGER.warning("401 error detected, closing session to force "
                            "another login attempt")
            self.close_session()
            return False

        _LOGGER.debug(json.dumps(body))
        for sen in sensors:
            if sen.extract_value(body):
                _LOGGER.debug("%s\t= %s %s",
                              sen.name, sen.value, sen.unit)
        return True
def read ( self , sensors ) : payload = { 'destDev' : [ ] , 'keys' : list ( set ( [ s . key for s in sensors ] ) ) } if self . sma_sid is None : yield from self . new_session ( ) if self . sma_sid is None : return False body = yield from self . _fetch_json ( URL_VALUES , payload = payload ) if body . get ( 'err' ) == 401 : _LOGGER . warning ( "401 error detected, closing session to force " "another login attempt" ) self . close_session ( ) return False _LOGGER . debug ( json . dumps ( body ) ) for sen in sensors : if sen . extract_value ( body ) : _LOGGER . debug ( "%s\t= %s %s" , sen . name , sen . value , sen . unit ) return True
Read a set of keys.