mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 01:08:03 +01:00
Fix scheduler first execution (#798)
* Fix scheduler first execution not immediately * Also update sensor filters
This commit is contained in:
parent
59c5956f93
commit
d62ef35860
2 changed files with 3 additions and 3 deletions
|
@ -259,7 +259,7 @@ def setup_sensor_core_(var, config):
|
||||||
if CONF_ACCURACY_DECIMALS in config:
|
if CONF_ACCURACY_DECIMALS in config:
|
||||||
cg.add(var.set_accuracy_decimals(config[CONF_ACCURACY_DECIMALS]))
|
cg.add(var.set_accuracy_decimals(config[CONF_ACCURACY_DECIMALS]))
|
||||||
cg.add(var.set_force_update(config[CONF_FORCE_UPDATE]))
|
cg.add(var.set_force_update(config[CONF_FORCE_UPDATE]))
|
||||||
if CONF_FILTERS in config:
|
if config.get(CONF_FILTERS): # must exist and not be empty
|
||||||
filters = yield build_filters(config[CONF_FILTERS])
|
filters = yield build_filters(config[CONF_FILTERS])
|
||||||
cg.add(var.set_filters(filters))
|
cg.add(var.set_filters(filters))
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ void HOT Scheduler::set_interval(Component *component, const std::string &name,
|
||||||
item->name = name;
|
item->name = name;
|
||||||
item->type = SchedulerItem::INTERVAL;
|
item->type = SchedulerItem::INTERVAL;
|
||||||
item->interval = interval;
|
item->interval = interval;
|
||||||
item->last_execution = now - offset;
|
item->last_execution = now - offset - interval;
|
||||||
item->last_execution_major = this->millis_major_;
|
item->last_execution_major = this->millis_major_;
|
||||||
if (item->last_execution > now)
|
if (item->last_execution > now)
|
||||||
item->last_execution_major--;
|
item->last_execution_major--;
|
||||||
|
@ -106,7 +106,7 @@ void ICACHE_RAM_ATTR HOT Scheduler::call() {
|
||||||
// Not reached timeout yet, done for this call
|
// Not reached timeout yet, done for this call
|
||||||
break;
|
break;
|
||||||
uint8_t major = item->last_execution_major;
|
uint8_t major = item->last_execution_major;
|
||||||
if (item->last_execution + item->interval < item->last_execution)
|
if (item->last_execution > now)
|
||||||
major++;
|
major++;
|
||||||
if (major != this->millis_major_)
|
if (major != this->millis_major_)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue