I have a cover that I need to control to different positions using ESPHome.
From the docs, the component is configured thus:
cover:
- platform: endstop
name: "Endstop Cover"
open_action:
- switch.turn_on: open_cover_switch
open_duration: 2.1min
open_endstop: open_endstop_binary_sensor
close_action:
- switch.turn_on: close_cover_switch
close_duration: 2min
close_endstop: close_endstop_binary_sensor
stop_action:
- switch.turn_off: open_cover_switch
- switch.turn_off: close_cover_switch
I have a linear potentiometer sensor that reports the cover position:
sensor:
### Linear potentiometer inputs
- id: back_height
platform: adc
pin: 33
name: "Back height"
update_interval: 0.5s
unit_of_measurement: mm
attenuation: auto
filters:
- calibrate_linear:
method: least_squares
datapoints:
- 0.0 -> -2.38
- 3.1499 -> 99.8
- delta: 2.0
- clamp:
min_value: 0
max_value: 100
ignore_out_of_range: true
- round: 0
My intention was to use analog threshold binary sensors for the open_endstop and closed_endstop for the cover, thereby controlling the position.
binary_sensor:
- platform: analog_threshold
id: open_endstop
sensor_id: back_height
threshold: !!!!!!!insert lambda here!!!!!!!
filters:
- delayed_off: 0.8s
- platform: analog_threshold
id: closed_endstop
sensor_id: back_height
threshold: !!!!!!!insert lambda here!!!!!!!
filters:
- delayed_off: 0.8s
I am stuck with the analog_threshold binary sensors threshold.
When I try to set that I get an error saying float required.
The docs suggest that the threshold accepts shorthand float or a mapping, but not !lambda.
I can’t get how to use mapping to achieve my goal.
Any suggestions?