ESPHome Lamda Calls Help

Anyone familiar with the ESPHome Lamda Calls? I’m a little confused on how to use the one I want. I am trying to get the current position of a stepper motor and this is what it say for Lamda Call:

current_postion: Get the current postion of the stepper as an integer.
int pos = id(my_stepper).current_position;

I am not sure how to set this up in the esphome yaml, and once this is done I am guessing that it will create a senor in Homeassistant that will get me the results. Any help on the issue would be greatly appreciated, Thanks…

Edit: @OttoWinter , is it possible you can ring in on this and push me in the right direction, thanks.

Hi there,

I am also interested in this.
current_postion: Get the current postion of the stepper as an integer.
int pos = id(my_stepper).current_position;

I try to use HassIO for everything but I do not have the skills yet.
A simple example can guide us in the right direction.

Please assist.
Thank you
Kind Regards,
Louis van Dyk

esphome:
  name: some_template_sensor
  platform: ESP8266
  board: esp12e

wifi:
  ssid: "SSID"
  password: "PASSWORD"

sensor:
  - platform: template
    name: "Template Sensor"
    lambda: |-
      if (id(my_stepper).state) {
        return id(my_stepper).current_position;
      } else {
        return NAN;
      }
    update_interval: 60s
    
# Enable logging
logger:

# Enable Home Assistant API
api:

# Enable OTA
ota:

2 Likes

@Lisheng2016, Thanks for the info.

Wow thank you very much! You are awesome @Lisheng2016! I searched for days :rofl: