Tell anyone who wants to know that a sensor was updated.
337443
def alert(self, msg):
        """"""
        if self.event_callback is not None:
            try:
                self.event_callback(msg)
            except Exception as exception:  # pylint: disable=broad-except
                _LOGGER.exception(exception)

        if self.persistence:
            self.persistence.need_save = True
1156419
protected final void notifyChanged() {
        for (int i = mObservers.size() - 1; i >= 0; i--) {
            mObservers.get(i).onChanged();
        }
    }
532454
def notify(self, value):
        """"""

        with self.lock:
            #TODO: this could slow down slow-rate incoming updates
            # since the number of ticks depends on the actual time
            # passed since the latest notification. Consider using
            # a real timer to tick the EWMA.

            self.tick()

            for avg in (self.m1, self.m5, self.m15, self.day):
                avg.update(value)
            self.count += value
553324
def _on_state_changed(self):
        """"""
        raw_state, generation = self.state.raw_state_and_generation
        if generation != self._last_generation:
            self._last_generation = generation
            self._send_update(raw_state, generation)
1133576
def _updated_cb(self, downtotal, downdone, uptotal, updone):
        
        self.emit('updated', downtotal, downdone, uptotal, updone)
1326034
def notify(self, *args, **kwargs):
        ''''''
        for handler in tuple(self.handlers):
            handler(*args, **kwargs)
433750
function Sensor(sensorInfo, options) {
  var props = this.properties = this.constructor.properties;
  var id = sensorInfo.id;

  if (id) {
    this.id = id;
  } else {
    if (props && props.id) {
      this.id = template(props.id, options);
    }
  }
  this.info = sensorInfo;
  this.options =  _.defaults(options || {}, sensorInfo.options);
  this.model = sensorInfo.model;
  this.device = sensorInfo.device;

  EventEmitter.call(this);
}
1084367
def update(self):
        """"""
        self._controller.update(self._id, wake_if_asleep=False)
        data = self._controller.get_charging_params(self._id)
        if data and (time.time() - self.__manual_update_time > 60):
            if data['charging_state'] != "Charging":
                self.__charger_state = False
            else:
                self.__charger_state = True
402360
async def _on_status_change(self, update):
        """"""

        info = update['payload']
        new_number = info['new_status']
        name = update['service']

        if name not in self.services:
            return

        with self._state_lock:
            is_changed = self.services[name].state != new_number
            self.services[name].state = new_number

        # Notify about this service state change if anyone is listening
        if self._on_change_callback and is_changed:
            self._on_change_callback(name, self.services[name].id, new_number, False, False)
385138
def update(self):
        """"""
        if batinfo_tag:
            # Use the batinfo lib to grab the stats
            # Compatible with multiple batteries
            self.bat.update()
            self.bat_list = [{
                'label': 'Battery',
                'value': self.battery_percent,
                'unit': '%'}]
        elif psutil_tag and hasattr(self.bat.sensors_battery(), 'percent'):
            # Use psutil to grab the stats
            # Give directly the battery percent
            self.bat_list = [{
                'label': 'Battery',
                'value': int(self.bat.sensors_battery().percent),
                'unit': '%'}]
        else:
            # No stats...
            self.bat_list = []
462125
def _do_update_callback(self, msg):
        """"""
        for callback, sensor in self._updateCallbacks:
            if sensor == msg:
                _LOGGING.debug('Update callback %s for sensor %s',
                               callback, sensor)
                callback(msg)
385574
def updated_on(self):
    """"""
    s = self._info.get('updated', None)
    return dateutil.parser.parse(s) if s else None
621418
def update_record(self, now, rec):
        """"""
        for listener in self.listeners:
            listener.update_record(self, now, rec)
        self.notify_all()
757068
def update(self):
        """"""
        self._controller.update(self._id, wake_if_asleep=False)
        data = self._controller.get_state_params(self._id)
        if data:
            self.__odometer = data['odometer']
        data = self._controller.get_gui_params(self._id)
        if data:
            if data['gui_distance_units'] == "mi/hr":
                self.measurement = 'LENGTH_MILES'
            else:
                self.measurement = 'LENGTH_KILOMETERS'
            self.__rated = (data['gui_range_display'] == "Rated")
272882
def inform(self, reading):
        """"""
        try:
            self._inform_callback(self._sensor, reading)
        except Exception:
            log.exception('Unhandled exception trying to send {!r} '
                          'for sensor {!r} of type {!r}'
                          .format(reading, self._sensor.name, self._sensor.type))
145022
def refresh(self):
        """"""
        # new_device = {}
        if self.type in CONST.BINARY_SENSOR_TYPES:
            response = self._lupusec.get_sensors()
            for device in response:
                if device['device_id'] == self._device_id:
                    self.update(device)

            return device

        elif self.type == CONST.ALARM_TYPE:
            response = self._lupusec.get_panel()
            self.update(response)
            return response
        
        elif self.type == CONST.TYPE_POWER_SWITCH:
            response = self._lupusec.get_power_switches()
            for pss in response:
                if pss['device_id'] == self._device_id:
                    self.update(pss)
            return pss
971612
def is_sensor(self, sensorid, child_id=None):
        """"""
        ret = sensorid in self.sensors
        if not ret:
            _LOGGER.warning('Node %s is unknown', sensorid)
        if ret and child_id is not None:
            ret = child_id in self.sensors[sensorid].children
            if not ret:
                _LOGGER.warning('Child %s is unknown', child_id)
        if not ret and parse_ver(self.protocol_version) >= parse_ver('2.0'):
            _LOGGER.info('Requesting new presentation for node %s',
                         sensorid)
            msg = Message(gateway=self).modify(
                node_id=sensorid, child_id=SYSTEM_CHILD_ID,
                type=self.const.MessageType.internal,
                sub_type=self.const.Internal.I_PRESENTATION)
            if self._route_message(msg):
                self.add_job(msg.encode)
        return ret