Skip to content

Commit

Permalink
Try since switch for expanded range
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenpapierski committed Oct 26, 2024
1 parent dd0a540 commit 7c6f70d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 8 additions & 0 deletions bed-presence-mk1/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,11 @@ button:
name: Restart
id: btn_restart
entity_category: "diagnostic"

switch:
- platform: template
name: Expand Range
id: expand_range
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: "configuration"
9 changes: 1 addition & 8 deletions bed-presence-mk1/sensor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ sensor:
window_size: ${averaging_window_samples}
send_every: 1
- lambda: |- # clamp to a min_value of 0 unless expand_range is True
if (x >= 0 || id(expand_${sensor_id}_range).state) {
if (x >= 0 || id(expand_range).state) {
return x;
} else {
return 0;
Expand Down Expand Up @@ -167,13 +167,6 @@ button:
# round to 2 decimal places
value: !lambda return round(id(bed_sensor_${sensor_id}).state * 100)/100.0;

switch:
- platform: template
name: Expand ${sensor_name} Range
id: expand_${sensor_id}_range
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF

script:
- id: update_trigger_${sensor_id}
mode: queued
Expand Down

0 comments on commit 7c6f70d

Please sign in to comment.