From cb2ec3e9256a9116451a56f694b9fdd1a3a4e847 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sat, 1 Dec 2018 09:46:37 +0100 Subject: [PATCH] Updates --- esphomeyaml/custom/custom_component.rst | 4 +-- esphomeyaml/custom/i2c.rst | 38 ++++++++++++++++++++++ esphomeyaml/custom/spi.rst | 38 ++++++++++++++++++++++ esphomeyaml/guides/configuration-types.rst | 28 ++++++++++++++++ esphomeyaml/guides/faq.rst | 5 +-- 5 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 esphomeyaml/custom/i2c.rst create mode 100644 esphomeyaml/custom/spi.rst diff --git a/esphomeyaml/custom/custom_component.rst b/esphomeyaml/custom/custom_component.rst index 4419ba82b..1e96c0fa3 100644 --- a/esphomeyaml/custom/custom_component.rst +++ b/esphomeyaml/custom/custom_component.rst @@ -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); diff --git a/esphomeyaml/custom/i2c.rst b/esphomeyaml/custom/i2c.rst new file mode 100644 index 000000000..d66995334 --- /dev/null +++ b/esphomeyaml/custom/i2c.rst @@ -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 `__ + +.. disqus:: diff --git a/esphomeyaml/custom/spi.rst b/esphomeyaml/custom/spi.rst new file mode 100644 index 000000000..725018b4a --- /dev/null +++ b/esphomeyaml/custom/spi.rst @@ -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 `__ + +.. disqus:: diff --git a/esphomeyaml/guides/configuration-types.rst b/esphomeyaml/guides/configuration-types.rst index 5186693a6..0cd51f445 100644 --- a/esphomeyaml/guides/configuration-types.rst +++ b/esphomeyaml/guides/configuration-types.rst @@ -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 -------- diff --git a/esphomeyaml/guides/faq.rst b/esphomeyaml/guides/faq.rst index fc8e31654..bd6e30342 100644 --- a/esphomeyaml/guides/faq.rst +++ b/esphomeyaml/guides/faq.rst @@ -53,8 +53,9 @@ Starting with esphomelib 1.9.0, the esphomelib suite provides `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 ``//.pioenvs//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 +``//.pioenvs//firmware.bin``. Then, install esphomeflasher by going to the `releases page `__ and downloading one of the pre-compiled binaries. Open up the application and select the serial port