This commit is contained in:
Otto Winter 2018-12-01 09:46:37 +01:00
parent 80b4651c5f
commit cb2ec3e925
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
5 changed files with 109 additions and 4 deletions

View File

@ -24,8 +24,8 @@ The example below is an example of a custom component that can do anything you w
pinMode(6, OUTPUT);
}
void loop() override {
// This will be called once to set up the component
// think of it as the setup() call in Arduino
// This will be called very often after setup time.
// think of it as the loop() call in Arduino
if (digitalRead(5)) {
digitalWrite(6, HIGH);

View File

@ -0,0 +1,38 @@
Custom I²C Device
=================
Lots of devices communicate using the i2c protocol. If you want to integrate
a device into esphomelib that uses this protocol you can pretty much use almost
all Arduino-based code, since the ``Wire`` library is also available in esphomelib.
See the other custom component guides for how to register components and make
them publish values.
.. code-block:: cpp
#include "esphomelib.h"
using namespace esphomelib;
class MyCustomComponent : public Component {
public:
void setup() override {
// Initialize the device here. Usually Wire.begin() will be called in here,
// though that call is unnecessary if you have an 'i2c:' entry in your config
Wire.begin();
}
void loop() override {
// Example: write the value 0x42 to register 0x78 of device with address 0x21
Wire.beginTransmission(0x21);
Wire.write(0x78);
Wire.write(0x42);
Wire.endTransmission();
}
};
See Also
--------
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/custom/i2c.rst>`__
.. disqus::

View File

@ -0,0 +1,38 @@
Custom SPI Device
=================
Lots of devices communicate using the i2c protocol. If you want to integrate
a device into esphomelib that uses this protocol you can pretty much use almost
all Arduino-based code, since the ``Wire`` library is also available in esphomelib.
See the other custom component guides for how to register components and make
them publish values.
.. code-block:: cpp
#include "esphomelib.h"
using namespace esphomelib;
class MyCustomComponent : public Component {
public:
void setup() override {
// Initialize the device here. Usually Wire.begin() will be called in here,
// though that call is unnecessary if you have an 'i2c:' entry in your config
Wire.begin();
}
void loop() override {
// Example: write the value 0x42 to register 0x78 of device with address 0x21
Wire.beginTransmission(0x21);
Wire.write(0x78);
Wire.write(0x42);
Wire.endTransmission();
}
};
See Also
--------
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/custom/i2c.rst>`__
.. disqus::

View File

@ -141,6 +141,34 @@ There are several ways of doing this. See below examples to see how you can spec
update_interval: never # never update
update_interval: 0ms # update in every loop() iteration
.. _config-substitutions:
Substitutions
-------------
If you're using many ESPs in your home and have many similar configuration files, it can
be cumbersome to keep all files up to date. There are already some ways to minimize
repeating yourself in the configuration using the ``!include`` and ``!secret`` YAML
directives.
If you want to go one step further and reduce duplication even further, you can use
``substitutions`` in esphomeyaml's config. Substitutions allow you define top-level
variables which are then replaced everywhere in your configuration which are then
substituted with their value using the bash-style ``${}`` syntax.
.. code-block:: yaml
substitutions:
devicename: livingroom
esphomeyaml:
name: $devicename
# ...
switch:
- platform: ...
name: ${devicename} switch
See Also
--------

View File

@ -53,8 +53,9 @@ Starting with esphomelib 1.9.0, the esphomelib suite provides
`esphomeflasher <https://github.com/OttoWinter/esphomeflasher>`__, a tool to flash ESPs over USB.
First, you need to get the firmware file to flash. For Hass.io add-on based installs you can
use the ``COMPILE`` button and then press ``Download Binary``. For command line based installs you
can access the file under ``<CONFIG_DIR>/<NODE_NAME>/.pioenvs/<NODE_NAME>/firmware.bin``.
use the ``COMPILE`` button (click the overflow icon with the three dots) and then press
``Download Binary``. For command line based installs you can access the file under
``<CONFIG_DIR>/<NODE_NAME>/.pioenvs/<NODE_NAME>/firmware.bin``.
Then, install esphomeflasher by going to the `releases page <https://github.com/OttoWinter/esphomeflasher/releases>`__
and downloading one of the pre-compiled binaries. Open up the application and select the serial port