Esphome w/Stepper, I hit a roadblock need a hand please (Solved)

Hi,

Trying to set up a unl2003 stepper and a d1 mini with Esphome. However I keep receiving an error when attempting to use the automation.
The Error:

2019-10-11 14:07:09 INFO (MainThread) [homeassistant.components.automation] Executing Write Stepper Value to ESP
2019-10-11 14:07:09 INFO (MainThread) [homeassistant.helpers.script] Script Write Stepper Value to ESP: Running script
2019-10-11 14:07:09 INFO (MainThread) [homeassistant.helpers.script] Script Write Stepper Value to ESP: Executing step call service
2019-10-11 14:07:09 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.write_stepper_value_to_esp. Service not found for call_service at pos 1: Unable to find service esphome/stepper_test_control_stepper

Iā€™ve been through all the threadā€™s (I believe) referring to using a stepper with Esphome. however Iā€™m hitting this hurdle and could use a hand in spotting my error please.

My configā€™s:
Automatons.yaml:

    
- id: stepper_test_1
  alias: Write Stepper Value to ESP
  trigger:
    platform: state
    entity_id: input_number.stepper_control
  action:
   # Replace esphome."*"_control_stepper with the name you gave the ESP
    - service: esphome.stepper_test_control_stepper
      data_template:
        target: '{{ trigger.to_state.state | int }}'

My input_number.yaml:

#stepper test control
  stepper_control:
    name: Stepper Control
    initial: 0
    min: -1000
    max: 1000
    step: 1
    mode: slider

My Esphome stepper_test.yaml:

esphome:
  name: stepper_test
  platform: ESP8266
  board: d1_mini_lite

wifi:
  ssid: "[redacted]"
  password: "[redacted]"

# Enable logging
logger:

# Enable Home Assistant API
api:
  services:
    - service: control_stepper
      variables:
        target: int
      then:
        - stepper.set_target:
            id: my_stepper
            target: !lambda 'return target;'

ota:
  password: "[redacted]"
  
#commented out, read https://github.com/esphome/issues/issues/683
#web_server:
#  port: 80

stepper:
  - platform: uln2003
    id: my_stepper
    pin_a: D0
    pin_b: D1
    pin_c: D2
    pin_d: D3
    max_speed: 250 steps/s
    step_mode: FULL_STEP #HALF_STEP,WAVE_DRIVE
    sleep_when_done: true

    # Optional:
    acceleration: inf
    deceleration: inf
    

Esphome log of device:

INFO Reading configuration...
INFO Starting log output from stepper_test.local using esphome API
INFO Connecting to stepper_test.local:6053 (192.168.0.55)
INFO Successfully connected to stepper_test.local
[14:41:38][I][app:096]: esphome version 1.13.6 compiled on Oct 11 2019, 02:42:28
[14:41:38][C][wifi:372]: WiFi:
[14:41:38][C][wifi:254]:   SSID: [redacted]
[14:41:38][C][wifi:255]:   IP Address: 192.168.0.55
[14:41:38][C][wifi:257]:   BSSID: [redacted]
[14:41:38][C][wifi:258]:   Hostname: 'stepper_test'
[14:41:38][C][wifi:262]:   Signal strength: -57 dB ā–‚ā–„ā–†ā–ˆ
[14:41:38][C][wifi:263]:   Channel: 6
[14:41:38][C][wifi:264]:   Subnet: 255.255.255.0
[14:41:38][C][wifi:265]:   Gateway: 192.168.0.1
[14:41:38][C][wifi:266]:   DNS1: 192.168.0.1
[14:41:38][C][wifi:267]:   DNS2: 0.0.0.0
[14:41:38][C][uln2003.stepper:039]: ULN2003:
[14:41:38][C][uln2003.stepper:040]:   Pin A: GPIO16 (Mode: OUTPUT)
[14:41:38][C][uln2003.stepper:041]:   Pin B: GPIO5 (Mode: OUTPUT)
[14:41:38][C][uln2003.stepper:042]:   Pin C: GPIO4 (Mode: OUTPUT)
[14:41:38][C][uln2003.stepper:043]:   Pin D: GPIO0 (Mode: OUTPUT)
[14:41:38][C][uln2003.stepper:044]:   Sleep when done: YES
[14:41:38][C][uln2003.stepper:057]:   Step Mode: FULL STEP
[14:41:38][C][logger:137]: Logger:
[14:41:38][C][logger:138]:   Level: DEBUG
[14:41:38][C][logger:139]:   Log Baud Rate: 115200
[14:41:38][C][logger:140]:   Hardware UART: UART0
[14:41:38][C][web_server:125]: Web Server:
[14:41:38][C][web_server:126]:   Address: stepper_test.local:80
[14:41:38][C][ota:029]: Over-The-Air Updates:
[14:41:38][C][ota:030]:   Address: stepper_test.local:8266
[14:41:38][C][ota:032]:   Using Password.
[14:41:38][C][api:103]: API Server:
[14:41:38][C][api:104]:   Address: stepper_test.local:6053

I can log on to the web server of the device at ether ā€œhttp://stepper_test/ā€ or ā€œhttp://192.168.0.55/ā€. However Iā€™m not sure why in the logs it seems to be looking for the device at ā€œstepper_test.localā€?

Hope someone can spot where Iā€™m falling short.
Thanks.

.local is the default domain assigned in ESPHome.
It uses mDNS for discovery of nodes and that is by default .local.

So if you do not specify a domain in the wifi setup, it will default to this.
I have been doing a lot of research on this because my nodes are on a separate subnet, and mDNS has trouble with this (not designed to cross subnet, but can be done).

Cheers!
DeadEnd

ā€¦ quick follow upā€¦ so far looking through the error and your YAMLā€™s I canā€™t see anything wrongā€¦ but Iā€™m still a noviceā€¦ so hopefully someone more experienced will find it :man_shrugging:.

Ok that makes sense.

Need to read through the Esphome docā€™s some more.
thanks for the tip.

Quick question, when you setup the ESPHome device in Home Assistant, how did you do this?
Did you do it in configuration.yaml or through the integrations page?

If you did it through the integrations page, did you use the device name, or IP address?
I am just wondering if it is having issues resolving the hostname by chanceā€¦

In your Home Assistant, go to the Developer Tools --> Services.
In this screen use the drop down for services, and see if you can find your custom ESPHome service. If not, then it is not being setup correctly in Home Assistant. This will give us an idea if the issue is creating the service, or calling it.

Cheers!
DeadEnd

I played around with the domain setting. It seems ā€œ.localā€ is correct. If i change it i cant upload the .bin . Itā€™s strange. Iā€™m sure that my network useā€™s ā€œ.j_yard.homeā€ as the local domain. My other computers are reporting that they use that domian.

========================= [SUCCESS] Took 13.96 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of stepper_test.j_yard.home
ERROR Error resolving IP address of stepper_test.j_yard.home. Is it connected to WiFi?
ERROR (If this error persists, please set a static IP address: https://esphome.io/components/wifi.html#manual-ips)
ERROR Error resolving IP address: [Errno -5] No address associated with hostname

I have yet to see this device in the integration page. I have one other Esphome device in the integration page (esp32 cam) that works as expected, and was setup via that page. Not via configuration.yaml.

Iā€™m not seeing any named reference to that device on that page ā€œDeveloper Tools ā†’ Servicesā€

Thank you.

The .local is specific for mDNS - I wonā€™t worry about it, I donā€™t think that is your problem. Your ā€œnormalā€ domain name is for normal DNS, mDNS (multicast DNS) is something different.

Back to your setup - you need to add the device to Home Assistant before you will be able to use it as a call. You need to use the integration page, add a new ESPHome device, and use the IP or Hostname of the new device. This will add it to Home Assistant, and then you should be able to see and use the service you created.

I think the root of your problem is that you forgot to add the device in the Home Assistant integrations.

Cheers!
DeadEnd

1 Like

I think the most appropriate word in this situation is ā€œDoh!ā€

Bingo. That was it.
Still getting my footing with Esphome. =)

Thank you for the help.