Merge pull request #7 from LaneaLucy/main
update Illuminance at least every 60 seconds, even if value not changed
This commit is contained in:
commit
9a237b7355
|
|
@ -60,6 +60,10 @@ globals:
|
|||
type: float
|
||||
restore_value: no
|
||||
initial_value: "-1"
|
||||
- id: last_illuminance_timestamp
|
||||
type: int
|
||||
restore_value: no
|
||||
initial_value: "-1"
|
||||
|
||||
improv_serial:
|
||||
|
||||
|
|
@ -684,19 +688,28 @@ sensor:
|
|||
accuracy_decimals: 1
|
||||
id: bh1750_light
|
||||
update_interval: 1s
|
||||
force_update: true
|
||||
filters:
|
||||
- lambda: !lambda |-
|
||||
auto time = id(time_now).utcnow().timestamp;
|
||||
if (id(last_illuminance) == x){
|
||||
if (time >= (id(last_illuminance_timestamp) + 60)){
|
||||
id(last_illuminance_timestamp) = time;
|
||||
return x;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
if (id(bh1750_fast_update).state){
|
||||
id(last_illuminance) = x;
|
||||
// ESP_LOGD("custom", "Fast Update BH1850");
|
||||
id(last_illuminance_timestamp) = time;
|
||||
return x;
|
||||
}
|
||||
if (abs(id(last_illuminance) - x) > 1){
|
||||
|
||||
id(last_illuminance) = x;
|
||||
id(last_illuminance_timestamp) = time;
|
||||
return x;
|
||||
}
|
||||
return {};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user