Get lates data from the sensor and update own state.

        Returns:
            dict: Latest state
965200
def update(self):
        

        (data_format, data) = RuuviTagSensor.get_data(self._mac, self._bt_device)

        if data == self._data:
            return self._state

        self._data = data

        if self._data is None:
            self._state = {}
        else:
            self._state = get_decoder(data_format).decode_data(self._data)

        return self._state
669791
def _get_state(self) -> None:
        
        # Don't need to go any further if we don't have a message
        if self.last_message is None:
            return

        # get the latest message UUID
        uuid = self.last_message.uuid
        # Check it against the stored UUID
        if uuid != self._last_bot_uuid:
            self.logger.info(' UUID message mismatch')
            self.logger.debug(' Old UUID: %s | New UUID: %s',
                              self._last_bot_uuid,
                              uuid)

            self.send_identity()
            # Store the latest message UUID now that we've sent an IDENT
            self._last_bot_uuid = uuid
1002200
def updated(self):
        ''
        return dateutil.parser.parse(str(self.f.latestRevision.updated))
1125232
def get_last_update_of_model(self, model, **kwargs):
        
        qs = self.get_for_model(model)
        if kwargs:
            qs = qs.filter(**kwargs)
        try:
            return qs.order_by('-timestamp')[0].timestamp
        except IndexError:
            return datetime.datetime.fromtimestamp(0)
273146
def extract_now_state(self):
        '''
        
        '''
        x, y = self.__agent_pos
        state_arr = np.zeros(self.__map_arr.shape)
        state_arr[x, y] = 1
        return np.expand_dims(state_arr, axis=0)
931377
def dump_state(self):
        

        superstate = super(ReferenceController, self).dump_state()

        superstate.update({
            'state_name': self.STATE_NAME,
            'state_version': self.STATE_VERSION,
            'app_info': self.app_info,
            'os_info': self.os_info,

            # Dump all of the subsystems
            'remote_bridge': self.remote_bridge.dump(),
            'tile_manager': self.tile_manager.dump(),
            'config_database': self.config_database.dump(),
            'sensor_log': self.sensor_log.dump()
        })

        return superstate
1357559
def updated(self):
        ''
        return dateutil.parser.parse(str(self.f.currentRevision.updated))
297541
def sync(self, *sids):
        
        if sids == ():
            sids = [sid for (sid,) in self.dbcur.execute(SQL_SENSOR_ALL)]
        for sid in sids:
            self.dbcur.execute(SQL_TMPO_LAST, (sid,))
            last = self.dbcur.fetchone()
            if last:
                rid, lvl, bid, ext = last
                self._clean(sid, rid, lvl, bid)
                # prevent needless polling
                if time.time() < bid + 256:
                    return
            else:
                rid, lvl, bid = 0, 0, 0
            self._req_sync(sid, rid, lvl, bid)
1009199
def latency(self):
        
        return {
            'input': {
                'min': self.data['defaultLowInputLatency'],
                'max': self.data['defaultHighInputLatency'],
            },
            'output': {
                'min': self.data['defaultLowOutputLatency'],
                'max': self.data['defaultHighOutputLatency'],
            }
        }
30924
def reset_state(self):
        
        self.active_message = None
        self.measurement = None
        if self.is_waiting_to_shutdown:
            self.shutdown_connections()
        elif self.is_processing:
            self.set_state(self.STATE_IDLE)
        elif self.is_idle or self.is_connecting or self.is_shutting_down:
            pass
        else:
            LOGGER.critical('Unexepected state: %s', self.state_description)
        LOGGER.debug('State reset to %s (%s in pending)',
                     self.state_description, len(self.pending))
673429
def data(self):
        

        if self.is_obsolete():
            data = self.get_data()
            for datum in data:
                if 'published_parsed' in datum:
                    datum['published_parsed'] = \
                        self.parse_time(datum['published_parsed'])

            try:
                dumped_data = json.dumps(data)
            except:
                self.update_cache(data)
            else:
                self.update_cache(dumped_data)
                return data

        try:
            return json.loads(self.cache_data)
        except:
            return self.cache_data

        return self.get_data()
1311208
def get_state(self):
        
        try:
            raise self._error
        except TypeError:
            pass
        except Exception as e:
            _logger.warning("%r", e)
            raise
        return self._state
1251334
def get_target_state():
    
    sdp_state = SDPState()
    errval, errdict = _check_status(sdp_state)
    if errval == "error":
        LOG.debug(errdict['reason'])
        return dict(
            current_target_state="unknown",
            last_updated="unknown",
            reason=errdict['reason']
        )
    LOG.debug('Getting target state')
    target_state = sdp_state.target_state
    LOG.debug('Target state = %s', target_state)
    return dict(
        current_target_state=target_state,
        allowed_target_states=sdp_state.allowed_target_states[
            sdp_state.current_state],
        last_updated=sdp_state.target_timestamp.isoformat())
747835
def _prior_running_states(jid):
    '''
    
    '''

    ret = []
    active = __salt__['saltutil.is_running']('state.*')
    for data in active:
        try:
            data_jid = int(data['jid'])
        except ValueError:
            continue
        if data_jid < int(jid):
            ret.append(data)
    return ret
800032
def get_update_status_brok(self):
        
        data = {'uuid': self.uuid}
        self.fill_data_brok_from(data, 'full_status')
        return Brok({'type': 'update_' + self.my_type + '_status', 'data': data})
1060516
def update_state_from_api(self):
        
        if self.last_api_call is not None:
            difference = (datetime.datetime.now() - self.last_api_call).seconds
        else:
            # This is the first run, so we need to get the lastest state.
            difference = 301
        if difference >= 300:
            url = BASE_URL + "/rest/item"
            payload = {'usertoken': self.token}
            arequest = requests.get(url, params=payload)
            status = str(arequest.status_code)
            if status == '401':
                _LOGGER.info("Token expired? Trying to get a new one.")
                self.authenticate(True)
                arequest = requests.get(url, params=payload)
                status = arequest.status_code
            elif status == '404':
                _LOGGER.error("No devices associated with this account.")
            elif status != '200':
                _LOGGER.error("API error not updating state. " + status)
            else:
                self.state = arequest.json()
            self.last_api_call = datetime.datetime.now()
            _LOGGER.info("Pulled latest state from API.")
518661
def get_status(self):
    
    self.__update_state()
    if self._state.active:
      return self.RUNNING
    else:
      return self._state.result_status