Have you verified the code without substitution first? cycle_start and cycle_steps shouldn’t include the device class (the period and the text before the period), for example:
You define the domain in your yaml. In your code you already posted you have defined that “tank_feed_start” is the ID for a binary_sensor device. ID’s are required to be unique. Elsewhere in your code I have assumed you’ve already defined what domain tank_feed_cycle_start and tank_feeder_step_counts are in.
Regarding being unique: In your code, try to create a duplicate ID by adding the code below and see what happens – you should get an error complaining about the ID being reused:
button:
- platform: template
name: Test Button
id: tank_feed_start
and reading your post above I may be misunderstanding something else.
I want to set the start bit and the number of counts in HA. So in HA I created an input_boolean for the start cycle (input_boolean.tank_feed_cycle_start) and an input_number for the counts (input_number.tank_feeder_step_counts).
then I called those entities in my substitutions file and referenced them in the binary_sensor in the ESPHome yaml.
so cycle_start in ESPHome should equal the HA entity “input_boolean.tank_feed_cycle_start”
and cycle_steps in ESPHome should equal the HA entity “input_number.tank_feeder_step_counts”
is that not the correct way of doing that?
Sorry, I’m not understanding. The ESPHome docs are fairly vague.
OK I see what you are trying to do. You have to create a sensor within your ESP device that will take its state from an existing entity in Home Assistant. You can’t simply reference a home assistant entity anywhere in your ESP’s yaml code.
So if you have created an input number entity in Home Assistant called input_number.tank_feed_cycle_start and you want your ESP to know about it, you have to have this in your code:
So far I got the code to compile and flashed but I don’t have all of the hardware wired up yet. as soon as I do and it works as expected I’ll post the results here along with the full working code.
I think I’ll change the title to better reflect the full project instead of just the substitution aspect.
Now I’m going to use it to drive sweeper that will move a certain number of steps once a day that will discharge fish food into my aquarium for use when we go on vacation, etc.
Hello, thank you for this efforts and for sharing here your solution. I think it might be very helpful for the issue I’m currently facing in setting up a stepper motor based fertilizers dosing system, but I simply have no idea of what “substitutions” are, and this sensor inside a ESPHome device is something I’m also unfamiliar with. Maybe someone here can give me an hand?
Here is the code I currently have for my ESPHome device:
- id: '1661897634736'
alias: Control Stepper
trigger:
platform: state
entity_id: input_number.stepper_control
action:
- service: esphome.stepper1
data_template:
target: "{{ trigger.to_state.state | int }}"
The current look of my dashboard:
My final objective is to be able to control the amount (and direction) of steps I need a motor to perform, through an input number (instead of a finite and fiddly slider).
Also, it would be great to have a simple control with a start/stop button for non-automatized purposes.
From this, I think I have what I need to create the automatizations and expansions I will need for the whole project.
Thank you in advance for putting your time on this.