Hello, I was wondering if you could help me create a button or switch for my servo. I have been looking through diffrent forums and documentation and I can not figure it out. I would like to use my servo to push the button, so it needs to go so far as to press it and come back to default state. I will attach my code for servo, while I know that i would need to follow this:
Configuring HA would be so much easier if those guides had a possible use not just a snipet of code that could be placed anywhere between config files.
If anyone had maybe similar buttons/switches programed I would be greatful for sharing the code and placment of it.
tl dr:
button/switch/activator to make servo preset movment.
esphome:
api:
services:
- service: control_servo
variables:
level: float
then:
- servo.write:
id: my_servo
level: !lambda 'return level / 100.0;'
output:
- platform: esp8266_pwm
id: pwm_output
pin: D4
frequency: 50 Hz
servo:
- id: my_servo
output: pwm_output
configuration.yaml file:
input_number:
servo_control:
name: Servo Control
initial: 0
min: -10
max: 100
step: 1
mode: box
automation:
- alias: Write Servo Value to ESP
trigger:
platform: state
entity_id: input_number.servo_control
action:
# Replace livingroom with the name you gave the ESP
- service: esphome.temp_off_control_servo
data_template:
level: '{{ trigger.to_state.state | int }}'
Thank you in advance.
Jarek