Add simpler Home Assistant configuration for servo control (#1960)
* Add simpler Home Assistant configuration for servo control Co-authored-by: Michiel Ryvers <demichiel@gmail.com>
This commit is contained in:
parent
b005d57b1e
commit
8551c30b39
|
@ -14,7 +14,7 @@ interface to the Arduino Servo library.
|
||||||
|
|
||||||
First, create an :ref:`output component <output>` (here ``esp8266_pwm``) for the pin the
|
First, create an :ref:`output component <output>` (here ``esp8266_pwm``) for the pin the
|
||||||
servo is connected to. Then connect that output to the servo component by assigning an ID.
|
servo is connected to. Then connect that output to the servo component by assigning an ID.
|
||||||
Please note the frequency of the output must be around 50Hz, as most servo controllers
|
Please note the frequency of the output should be around 50Hz, as most servo controllers
|
||||||
only operate in this frequency range.
|
only operate in this frequency range.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
@ -141,46 +141,22 @@ this will make the servo motor stop immediately and disable its active control.
|
||||||
Home Assistant Configuration
|
Home Assistant Configuration
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
This component will not show up in the Home Assistant frontend automatically because Home Assistant
|
The easiest way to control your servo from Home Assistant is to add a ``number`` to your ESPHome
|
||||||
does not support servos natively (raise this issue in Home Assistant forums to make this a
|
configuration. See :ref:`Number <config-number>` for more information.
|
||||||
higher priority for Home Assistant). You can add this to your Home Assistant configuration to
|
|
||||||
be able to control the servo from the frontend.
|
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
# Home Assistant configuration
|
number:
|
||||||
input_number:
|
- platform: template
|
||||||
servo_control:
|
|
||||||
name: Servo Control
|
name: Servo Control
|
||||||
initial: 0
|
min_value: -100
|
||||||
min: -100
|
max_value: 100
|
||||||
max: 100
|
|
||||||
step: 1
|
step: 1
|
||||||
mode: slider
|
set_action:
|
||||||
|
|
||||||
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.livingroom_control_servo
|
|
||||||
data_template:
|
|
||||||
level: '{{ trigger.to_state.state | int }}'
|
|
||||||
|
|
||||||
.. code-block:: yaml
|
|
||||||
|
|
||||||
# ESPHome configuration
|
|
||||||
api:
|
|
||||||
services:
|
|
||||||
- service: control_servo
|
|
||||||
variables:
|
|
||||||
level: float
|
|
||||||
then:
|
then:
|
||||||
- servo.write:
|
- servo.write:
|
||||||
id: my_servo
|
id: my_servo
|
||||||
level: !lambda 'return level / 100.0;'
|
level: !lambda 'return x / 100.0;'
|
||||||
|
|
||||||
servo:
|
servo:
|
||||||
- platform: ...
|
- platform: ...
|
||||||
|
|
Loading…
Reference in New Issue