Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - platform: ultrasonic
- trigger_pin: GPIO5
- echo_pin: GPIO4
- update_interval: 100ms
- # name: "${friendly_name} Door Distance"
- id: distance
- timeout: 3m
- filters:
- - median:
- window_size: 5
- send_every: 5
- send_first_at: 3
- - sliding_window_moving_average:
- window_size: 5
- send_every: 2
- send_first_at: 1
- - delta: 0.05
- on_value:
- - lambda: 'id(internal_door_position).publish_state(x);'
- - platform: template
- id: internal_door_position
- update_interval: never
- filters:
- - calibrate_linear:
- # < 0.8m = 1.0 so the cover knows it is open
- - 0.8 -> 1.0
- # > 2.8m = 0.0 so the cover knows it is closed
- - 2.8 -> 0.0
- - lambda: 'return clamp(x, 0.0, 1.0);'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement