Skip to content

Commit 9e5cc9c

Browse files
committed
Merge branch 'next' into rc
2 parents e6caed8 + ed98774 commit 9e5cc9c

File tree

17 files changed

+329
-60
lines changed

17 files changed

+329
-60
lines changed

api/misc/stepper.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Stepper Component
2+
=================
3+
4+
.. cpp:namespace:: nullptr
5+
6+
API Reference
7+
-------------
8+
9+
.. cpp:namespace:: nullptr
10+
11+
Stepper
12+
*******
13+
14+
.. doxygenclass:: stepper::Stepper
15+
:members:
16+
:protected-members:
17+
:undoc-members:
18+
19+
.. doxygenclass:: stepper::SetTargetAction
20+
:members:
21+
:protected-members:
22+
:undoc-members:
23+
24+
.. doxygenclass:: stepper::ReportPositionAction
25+
:members:
26+
:protected-members:
27+
:undoc-members:
28+
29+
A4988
30+
*****
31+
32+
.. doxygenclass:: stepper::A4988
33+
:members:
34+
:protected-members:
35+
:undoc-members:

esphomeyaml/components/display/index.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ use any string you pass it, like ``"ON"`` or ``"OFF"``.
297297
// Shorthand:
298298
it.printf(0, 0, id(my_font), "State: %s", id(my_binary_sensor).state ? "ON" : "OFF");
299299
300+
.. note::
301+
302+
For displaying external data on the display, for example data from your Home Assistant instance,
303+
you can use the :doc:`/esphomeyaml/components/text_sensor/mqtt` (see the example there for more information).
304+
300305
.. _display-strftime:
301306

302307
Displaying Time

esphomeyaml/components/esp32_ble_beacon.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,6 @@ know when I'm home or away.
6767
:align: center
6868
:width: 75.0%
6969

70-
.. note::
71-
72-
The latest arduino ESP32 framework has a bug with the bluetooth module. Please set
73-
:ref:`esphomeyaml-arduino_version` to ``espressif32@1.0.2`` like so:
74-
75-
.. code:: yaml
76-
77-
esphomeyaml:
78-
# ...
79-
arduino_version: espressif32@1.0.2
80-
81-
See https://github.com/OttoWinter/esphomeyaml/issues/78#issuecomment-425746566
82-
8370
See Also
8471
--------
8572

esphomeyaml/components/esp32_ble_tracker.rst

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,6 @@ for information on how you can find out the MAC address of a device and track it
4343
battery_level:
4444
name: "Xiaomi MiJia Battery Level"
4545
46-
.. note::
47-
48-
The latest arduino ESP32 framework has a bug with the bluetooth module. Please set
49-
:ref:`esphomeyaml-arduino_version` to ``espressif32@1.0.2`` like so:
50-
51-
.. code:: yaml
52-
53-
esphomeyaml:
54-
# ...
55-
arduino_version: espressif32@1.0.2
56-
57-
See https://github.com/OttoWinter/esphomeyaml/issues/78#issuecomment-425746566
58-
59-
6046
.. note::
6147

6248
The first time this component is enabled for an ESP32, the code partition needs to be

esphomeyaml/components/mqtt.rst

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@ Configuration variables:
313313
then:
314314
- # ...
315315
316+
.. note::
317+
318+
This action can also be used in :ref:`lambdas <config-lambda>`:
319+
320+
.. code:: cpp
321+
322+
App.get_mqtt_client()->subscribe("the/topic", [=](const std::string &payload) {
323+
// do something with payload
324+
});
325+
316326
.. _mqtt-on_json_message:
317327

318328
``on_json_message`` Trigger
@@ -366,6 +376,16 @@ Configuration variables:
366376
Due to the way this trigger works internally it is incompatible with certain actions and will
367377
trigger a compile failure. For example with the ``delay`` action.
368378

379+
.. note::
380+
381+
This action can also be used in :ref:`lambdas <config-lambda>`:
382+
383+
.. code:: cpp
384+
385+
App.get_mqtt_client()->subscribe_json("the/topic", [=](JsonObject &root) {
386+
// do something with JSON-decoded value root
387+
});
388+
369389
.. _mqtt-publish_action:
370390

371391
``mqtt.publish`` Action
@@ -413,8 +433,7 @@ Configuration options:
413433
414434
.. code:: cpp
415435
416-
// in lambda, parameters: <TOPIC>, <PAYLOAD>, <QoS>, <retain>
417-
id(mqtt_client).publish("the/topic", "The Payload", 0, false);
436+
id(mqtt_client).publish("the/topic", "The Payload");
418437
419438
.. _mqtt-publish_json_action:
420439

@@ -452,6 +471,24 @@ Configuration options:
452471
- **retain** (*Optional*, boolean): If the published message should
453472
have a retain flag on or not. Defaults to ``False``.
454473

474+
475+
.. note::
476+
477+
This action can also be written in :ref:`lambdas <config-lambda>`:
478+
479+
.. code:: yaml
480+
481+
mqtt:
482+
# Give the mqtt component an ID
483+
id: mqtt_client
484+
485+
.. code:: cpp
486+
487+
id(mqtt_client).publish_json("the/topic", [=](JsonObject &root) {
488+
root["something"] = id(my_sensor).value;
489+
});
490+
491+
455492
See Also
456493
--------
457494

esphomeyaml/components/sensor/cse7766.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ esphomelib. This sensor is commonly found in Sonoff POW R2.
1212

1313
As the communication with the CSE7766 done using UART, you need
1414
to have an :ref:`UART bus <uart>` in your configuration with the ``rx_pin`` connected to the CSE7766.
15-
Additionally, you need to set the baud rate to 9600.
15+
Additionally, you need to set the baud rate to 4800.
1616

1717
.. code:: yaml
1818
@@ -23,7 +23,7 @@ Additionally, you need to set the baud rate to 9600.
2323
2424
uart:
2525
rx_pin: RX
26-
baud_rate: 9600
26+
baud_rate: 4800
2727
2828
sensor:
2929
- platform: cse7766

esphomeyaml/components/sensor/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ every filter there is currently:
126126
- **send_every**: How often a sensor value should be pushed out. For
127127
example, in above configuration the weighted average is only
128128
pushed out on every 15th received sensor value.
129+
- **send_first_at**: By default, the very first raw value on boot is immediately
130+
published. With this parameter you can specify when the very first value is to be sent.
131+
Defaults to ``1``.
129132

130133
- **exponential_moving_average**: A simple `exponential moving
131134
average <https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average>`__
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
Stepper Component
2+
=================
3+
4+
The ``stepper`` component allows you to use stepper motors with esphomelib.
5+
Currently only the A4988 stepper driver
6+
(`datasheet <https://www.pololu.com/file/0J450/a4988_DMOS_microstepping_driver_with_translator.pdf>`__)
7+
is supported.
8+
9+
.. code:: yaml
10+
11+
# Example configuration entry
12+
stepper:
13+
- platform: a4988
14+
id: my_stepper
15+
step_pin: D0
16+
dir_pin: D1
17+
max_speed: 250 steps/s
18+
19+
# Optional:
20+
sleep_pin: D2
21+
acceleration: inf
22+
deceleration: inf
23+
24+
25+
Configuration variables:
26+
------------------------
27+
28+
- **id** (**Required**, :ref:`config-id`): Specify the ID of the stepper so that you can control it.
29+
- **step_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The ``STEP`` pin of the A4988
30+
stepper driver.
31+
- **dir_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The ``DIRECTION`` pin of the A4988
32+
stepper driver.
33+
- **max_speed** (**Required**, float): The maximum speed in ``steps/s`` (steps per seconds) to drive the
34+
stepper at. Note most steppers can't step properly with speeds higher than 250 steps/s.
35+
- **sleep_pin** (*Optional*, :ref:`Pin Schema <config-pin_schema>`): Optionally also use the ``SLEEP`` pin
36+
of the A4988 stepper driver. If specified, the driver will be put into sleep mode as soon as the stepper
37+
reaches the target steps.
38+
- **acceleration** (*Optional*, float): The acceleration in ``steps/s^2`` (steps per seconds squared)
39+
to use when starting to move. The default is ``inf`` which means infinite acceleration, so the
40+
stepper will try to drive with the full speed immediately.
41+
- **deceleration** (*Optional*, float): The same as ``acceleration``, but for when the motor is decelerating
42+
shortly before reaching the set position. Defaults to ``inf`` (immediate deceleration).
43+
44+
45+
.. note::
46+
47+
Esphomelib's core loop only runs 60 times per second by default to conserve power. But this also means it's limited
48+
to 60 steps per second. To have higher step rater, you have to open up the ``<NODE_NAME>/src/main.cpp`` file,
49+
scroll down to the ``void loop()`` section and remove the ``delay(16);`` line.
50+
51+
.. note::
52+
53+
If the stepper is driving in the wrong direction, you can invert the ``dir_pin``:
54+
55+
.. code:: yaml
56+
57+
stepper:
58+
- platform: a4988
59+
# ...
60+
dir_pin:
61+
number: D1
62+
inverted: True
63+
64+
65+
.. _stepper-set_target_action:
66+
67+
``stepper.set_target`` Action
68+
-----------------------------
69+
70+
To use your stepper motor in :ref:`automations <automation>` or templates, you can use this action to set the target
71+
position (in steps). The stepper will always run towards the target position and stop once it has reached the target.
72+
73+
.. code:: yaml
74+
75+
on_...:
76+
then:
77+
- stepper.set_target:
78+
id: my_stepper
79+
target: 250
80+
81+
# Templated
82+
- stepper.set_target:
83+
id: my_stepper
84+
target: !lambda |-
85+
if (id(my_binary_sensor).value) {
86+
return 1000;
87+
} else {
88+
return -1000;
89+
}
90+
91+
Configuration options:
92+
93+
- **id** (**Required**, :ref:`config-id`): The ID of the stepper.
94+
- **target** (*Optional*, int, :ref:`templatable <config-templatable>`): The target position in steps.
95+
96+
.. note::
97+
98+
This action can also be expressed as a :ref:`lambda <config-lambda>`:
99+
100+
.. code:: cpp
101+
102+
id(my_stepper).set_target(250);
103+
104+
// Get the currently set target position:
105+
int target = id(my_stepper).target_position;
106+
107+
.. _stepper-report_position_action:
108+
109+
``stepper.report_position`` Action
110+
----------------------------------
111+
112+
All steppers start out with a target and current position of ``0`` on boot. However, if you for example want to home
113+
a stepper motor, it can be useful to **report** the stepper where it is currently at.
114+
115+
With this action, you can set the stepper's internal position counter to a specific value (in steps). Please note
116+
that reporting the position can create unexpected moves of the stepper. For example, if the stepper's target and
117+
current position is at 1000 steps and you "report" a position of 0, the stepper will move 1000 steps forward to match
118+
the target again.
119+
120+
.. code:: yaml
121+
122+
on_...:
123+
then:
124+
- stepper.report_position:
125+
id: my_stepper
126+
position: 250
127+
# It's best to call set_target directly after report_position, so that the stepper doesn't move
128+
- stepper.set_target:
129+
id: my_stepper
130+
target: 250
131+
132+
# Templated
133+
- stepper.report_position:
134+
id: my_stepper
135+
position: !lambda |-
136+
if (id(my_binary_sensor).value) {
137+
return 0;
138+
} else {
139+
return -1000;
140+
}
141+
142+
Configuration options:
143+
144+
- **id** (**Required**, :ref:`config-id`): The ID of the stepper.
145+
- **target** (*Optional*, int, :ref:`templatable <config-templatable>`): The target position in steps.
146+
147+
.. note::
148+
149+
This action can also be expressed as a :ref:`lambda <config-lambda>`:
150+
151+
.. code:: cpp
152+
153+
id(my_stepper).report_position(250);
154+
155+
// Get the current position:
156+
int pos = id(my_stepper).current_position;
157+
158+
See Also
159+
--------
160+
161+
- :doc:`API Reference </api/misc/stepper>`
162+
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/stepper.rst>`__
163+
164+
.. disqus::

esphomeyaml/components/switch/index.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ This action toggles a switch with the given ID when executed.
3737
3838
on_...:
3939
then:
40-
- switch.toggle:
41-
id: relay_1
40+
- switch.toggle: id: relay_1
4241
4342
.. _switch-turn_on_action:
4443

@@ -51,8 +50,7 @@ This action turns a switch with the given ID on when executed.
5150
5251
on_...:
5352
then:
54-
- switch.turn_on:
55-
id: relay_1
53+
- switch.turn_on: relay_1
5654
5755
.. _switch-turn_off_action:
5856

@@ -65,8 +63,7 @@ This action turns a switch with the given ID off when executed.
6563
6664
on_...:
6765
then:
68-
- switch.turn_off:
69-
id: relay_1
66+
- switch.turn_off: relay_1
7067
7168
lambda calls
7269
************

0 commit comments

Comments
 (0)