I am trying to get a slider to work with a a4988 stepper driver. But I keep getting stuck.
If I change the stop_action to
stop_action:
- stepper.set_speed
id: my_stepper
speed: 250
then it changes the speed if I push stop so that works.
But when i change it with a lamba function it gives me this error
"/config/esphome/esp-motor.yaml: In lambda function:
/config/esphome/esp-motor.yaml:63:14: error: 'level' was not declared in this scope
speed: !lambda 'return level/100.0;'
^~~~~
/config/esphome/esp-motor.yaml:63:14: note: suggested alternative: 'Server'
speed: !lambda 'return level/100.0;'"
Can somebody help me and tell me what I doing wrong?
And how i can change it.
esphome:
name: 3d-photos
friendly_name: esp_motor
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "***********"
services:
- service: control_servo2
variables:
level: float
then:
stepper.set_speed:
id: my_stepper
speed: !lambda 'return level / 100.0;'
ota:
password: "********"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp-Motor Fallback Hotspot"
password: "yKW0YVbzhfWS"
captive_portal:
cover:
- platform: template
name: "Curtain"
id: my_blind
device_class: blind
open_action:
- stepper.set_target:
id: my_stepper
target: 40000
close_action:
- stepper.set_target:
id: my_stepper
target: 2
stop_action:
- stepper.set_target:
id: my_stepper
target: !lambda return id(my_stepper).current_position;
tilt_action:
- stepper.set_speed:
id: my_stepper
speed: !lambda 'return level/100.0;'
#- step per.set_target:
#id: my_stepper
#target: !lambda return id(my_stepper).current_position;
optimistic: true
assumed_state: true
has_position: true
globals:
# This variable stores the current mode chosen by pressing the buttons (physical or digital)
- id: totalClick
type: int
restore_value: no
initial_value: "0"
sensor:
stepper:
- platform: a4988
id: my_stepper
step_pin: 27
dir_pin:
number: 14
inverted: true
sleep_pin:
number: 13
inverted: true
max_speed: 15000
# Optional:
acceleration: inf
deceleration: inf