So i’ve using ESPHome setup an esp8266 which control a stepper motor using the stepper driver.
The ESPHome setup works and i can without any problems in HA dev-services call the service
esphome.steppermotor_control_stepper with service data {"target": 2000}
and see the motor moving!.
But the frontend controls I haven’t managed to get that working yet…
I’ve on my dashboard, as ESPHome suggest created a slider as such:
# Home Assistant configuration
input_number:
stepper_control:
name: Stepper Control
initial: 0
min: -1000
max: 1000
step: 1
mode: slider
And this slider is “monitored” by an automation rule
# Control stepper motor
- alias: 'Write Stepper Value to ESP'
trigger:
platform: state
entity_id: input_number.stepper_control
action:
- service: esphome.steppermotor_stepper_control
data_template:
target: '{"target": {{ trigger.to_state.state | int }} }'
but every time I move the slider I get an error in the log that
Error while executing automation automation.write_stepper_value_to_esp. Service not found for call_service at pos 1: (ServiceNotFound(...), 'Service esphome.steppermotor_stepper_control not found')
which i know is untrue? as I can manually trigger it? so why am I getting this error, and why am I not able to control it using frontend slider?
The service I am calling is the wrong one.
The one that works in dev-services esphome.steppermotor_control_stepper
but the one my automation is calling is esphome.steppermotor_stepper_control
Kidi3, would you mind posting the config that you have in your esphome yaml, and any other info that you might have figured out. I have been fighting with this for day, and no luck at all, thanks.
This is the slider configuration for the stepper motor
# Home Assistant configuration
input_number:
stepper_control:
name: Stepper Control
initial: 0
min: -1000
max: 1000
step: 1
mode: slider
And the automation that calls the service on the esphome based on the slider position is
# Control stepper motor
- alias: 'Write Stepper Value to ESP'
trigger:
platform: state
entity_id: input_number.stepper_control
action:
- service: esphome.steppermotor_control_stepper
data_template:
target: '{{ trigger.to_state.state | int }}'
Alright, I broke things down and one found out part of the problem was the power supply. Swapped that and now a can make a service call and i can get it to work, but I am not having any luck with the automation and I appear to have the same code as you.
Edit: Ok, all is good automation working, thanks for the help
HI Everyone, just to share my experience, with a little modification in the automation.yaml file I managed to get it work on the slider UI by modifying data_template: by data:
Hope it might help