'Update the sensor\'s state, if needed.'

def _update_callback(self):

    self.update()
    if (self._timer is not None):
        self._timer()
        self._timer = None
    if ((self._delay > 0) and (not self.is_on)):
        def _delay_update(now):
            'Timer    callback    for    sensor    update.'
            _LOGGER.debug('%s    Called    delayed    (%s    sec)    update.', self._name, self._delay)
            self.schedule_update_ha_state()
            self._timer = None
        self._timer = track_point_in_utc_time(self.hass, _delay_update, (utcnow() + timedelta(seconds=self._delay)))
    else:
        self.schedule_update_ha_state()
