From 74787342286ccb755980ccdf23210b239bddc5f4 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Wed, 27 Feb 2019 18:32:47 +0100 Subject: [PATCH] Add more lints --- changelog/v1.10.0.rst | 5 +- changelog/v1.11.0.rst | 1 + changelog/v1.7.0.rst | 3 +- changelog/v1.8.0.rst | 51 +++++++++----- changelog/v1.9.0.rst | 2 +- components/api.rst | 56 ++++++++-------- components/binary_sensor/index.rst | 36 +++++----- components/display/index.rst | 3 +- components/display/lcd_display.rst | 3 +- components/display/max7219.rst | 3 +- components/display/ssd1306.rst | 9 ++- components/ota.rst | 12 ++-- components/output/my9231.rst | 26 ++++---- components/sensor/dallas.rst | 6 +- components/sensor/dht.rst | 6 +- components/sensor/htu21d.rst | 3 +- components/sensor/ms5611.rst | 3 +- components/sensor/xiaomi_mijia.rst | 3 +- components/switch/remote_transmitter.rst | 15 +++-- components/time.rst | 4 +- cookbook/bme280_environment.rst | 26 +++++--- cookbook/display_time_temp_oled.rst | 23 +++---- cookbook/dual-r2-cover.rst | 16 ++--- cookbook/h801.rst | 19 +++--- cookbook/sonoff-fishpond-pump.rst | 3 +- devices/esp8266.rst | 3 +- devices/sonoff_basic.rst | 84 ++++++++++++------------ guides/automations.rst | 10 +-- guides/contributing.rst | 28 ++++---- guides/faq.rst | 12 ++-- images/index.rst | 9 +++ index.rst | 7 +- seo.py | 2 +- travis.py | 82 +++++++++++++++++++++-- web-api/index.rst | 2 +- 35 files changed, 360 insertions(+), 216 deletions(-) diff --git a/changelog/v1.10.0.rst b/changelog/v1.10.0.rst index ddae1773e..13b4b5f4c 100644 --- a/changelog/v1.10.0.rst +++ b/changelog/v1.10.0.rst @@ -53,8 +53,9 @@ of time to find+fix some final bugs. **How do I migrate from MQTT?** -First, make sure you run at least Home Assistant 0.85.0 (currently a `beta release `__). Then, go through the -:ref:`migration guide here `. +First, make sure you run at least Home Assistant 0.85.0 (currently a +`beta release `__). +Then, go through the :ref:`migration guide here `. Python 3 Compatibility ---------------------- diff --git a/changelog/v1.11.0.rst b/changelog/v1.11.0.rst index e10a38648..dcc0d4fc4 100644 --- a/changelog/v1.11.0.rst +++ b/changelog/v1.11.0.rst @@ -148,6 +148,7 @@ Beta Fixes All changes ----------- + - core: Attemp to fix the addressable flicker effect :corepr:`392` by :ghuser:`RomRider` - esphome: typing is only required for python < 3.5 :esphomepr:`341` by :ghuser:`dotlambda` - esphome: Fix install pillow in docker image :esphomepr:`338` diff --git a/changelog/v1.7.0.rst b/changelog/v1.7.0.rst index 3336e2959..618a3a0d4 100644 --- a/changelog/v1.7.0.rst +++ b/changelog/v1.7.0.rst @@ -190,6 +190,7 @@ for using esphomeyaml to create a simple wireless doorbell: .. raw:: html - + .. disqus:: diff --git a/changelog/v1.8.0.rst b/changelog/v1.8.0.rst index 0269c2fd3..61e1046af 100644 --- a/changelog/v1.8.0.rst +++ b/changelog/v1.8.0.rst @@ -69,18 +69,30 @@ awesome projects ☀️ Special thanks to all the contributors for this release: -- esphomeyaml: Add ‘only-generate’ parameter to generate command to only generate the C++ code `#84 `__ by `@apeeters `__ -- esphomeyaml: Fix esphomeyaml logs for tls enabled mqtt brokers `#118 `__ by `@johnerikhalse `__ -- esphomelib: Add Samsung IR codes `#141 `__ by `@escoand `__ -- esphomelib: Add support for SNTP and RTC `#76 `__ by `@brandond `__ -- esphomelib: Run travis jobs in parallel `#123 `__ by `@lobradov `__ -- esphomelib: Fix typo in dallas error message `#125 `__ by `@janpieper `__ -- esphomelib: Fix esphomelib examples `#124 `__ by `@lobradov `__ -- esphomelib: Fix panic in binary_sensor template `#111 `__ by `@nunofgs `__ -- esphomelib: Add ESP8266 library dependency to Arduino IDE instructions `#99 `__ by `@per1234 `__ -- esphomelib: Fixing I2C readings `#98 `__ by `@exxamalte `__ -- esphomedocs: Note added about resetting the ESP after serial upload before OTA upload `#14 `__ by `@exxamalte `__ -- esphomedocs: Add cookbook for dual relay cover `#10 `__ by `@aequitas `__ +- esphomeyaml: Add ‘only-generate’ parameter to generate command to only generate the C++ code + `#84 `__ by `@apeeters `__ +- esphomeyaml: Fix esphomeyaml logs for tls enabled mqtt brokers + `#118 `__ by `@johnerikhalse `__ +- esphomelib: Add Samsung IR codes `#141 `__ + by `@escoand `__ +- esphomelib: Add support for SNTP and RTC `#76 `__ + by `@brandond `__ +- esphomelib: Run travis jobs in parallel `#123 `__ + by `@lobradov `__ +- esphomelib: Fix typo in dallas error message `#125 `__ + by `@janpieper `__ +- esphomelib: Fix esphomelib examples `#124 `__ + by `@lobradov `__ +- esphomelib: Fix panic in binary_sensor template `#111 `__ + by `@nunofgs `__ +- esphomelib: Add ESP8266 library dependency to Arduino IDE instructions `#99 `__ + by `@per1234 `__ +- esphomelib: Fixing I2C readings `#98 `__ + by `@exxamalte `__ +- esphomedocs: Note added about resetting the ESP after serial upload before OTA upload + `#14 `__ by `@exxamalte `__ +- esphomedocs: Add cookbook for dual relay cover `#10 `__ + by `@aequitas `__ And in some more personal news, you might have noticed that I was not very active in online communications (github, discord, ...) and that's partly been due to me concentrating on other stuff (university applications, work and @@ -94,7 +106,8 @@ Other notable changes - Fixed certain occasions where esphomeyaml could run into recursive dependencies - Fixed i2c scans not showing up via MQTT -- Improved build times by about 60%. Now, the build time should depend on the amount of components you're using, not the total esphomelib code base size. +- Improved build times by about 60%. Now, the build time should depend on the amount of components you're using, + not the total esphomelib code base size. - Fixed ESP32 Touch setup mode - Fixed template binary sensors - Added the option to specify ``never`` for ``update_interval`` to never @@ -181,11 +194,15 @@ Changes in 1.8.2 - esphomedocs: Typo in display docs `#28 `__ by `@yuanl `__ - esphomedocs: Typo fix. `#33 `__ by `@corbanmailloux `__ - esphomelib: Fix typo "noting" `#172 `__ by `@TheJulianJES `__ -- esphomedocs: Added docker local USB port mapping `#31 `__ by `@ladefoged81 `__ -- esphomedocs: Fixed typo `#30 `__ by `@ladefoged81 `__ -- esphomedocs: Add missing (required) name to example. `#29 `__ by `@corbanmailloux `__ +- esphomedocs: Added docker local USB port mapping `#31 `__ + by `@ladefoged81 `__ +- esphomedocs: Fixed typo `#30 `__ + by `@ladefoged81 `__ +- esphomedocs: Add missing (required) name to example. `#29 `__ + by `@corbanmailloux `__ - esphomedocs: Add ESP32 BLE workaround docs `#34 `__ -- esphomelib: Apply effect after changing colors `#169 `__ by `@TheJulianJES `__ +- esphomelib: Apply effect after changing colors `#169 `__ + by `@TheJulianJES `__ - esphomelib: Add 64x48 SSD1306 Display `#161 `__ - esphomedocs: Fix output link `#35 `__ - esphomedocs: Fix pulse counter API typo `#36 `__ diff --git a/changelog/v1.9.0.rst b/changelog/v1.9.0.rst index ed97b117e..56edc5752 100644 --- a/changelog/v1.9.0.rst +++ b/changelog/v1.9.0.rst @@ -96,7 +96,7 @@ New Features .. code-block:: text - [13:57:33][I][application:092]: You're running esphomelib v1.9.0 compiled on Nov 3 2018, 13:55:11 + [13:57:33][I][application:092]: You're running esphomelib v1.9.0 compiled on Nov 3 2018, 13:55:11 - Stack traces in the USB logs are now automatically decoded to make debugging easier (:yamlpr:`214`) diff --git a/components/api.rst b/components/api.rst index 5ff03d070..5b33517a8 100644 --- a/components/api.rst +++ b/components/api.rst @@ -48,7 +48,7 @@ If you've previously used ESPHome with Home Assistant via MQTT and have enabled the upgrade process is unfortunately not just swapping out the ``mqtt`` for ``api`` in your configuration: Home Assistant's `entity registry `__ complicates things a bit. If you don't follow these steps, all your new native API entities will have a trailing -`_2` at the end of the entity ID. +``_2`` at the end of the entity ID. You can repeat these steps for all your nodes, or convert them over to the new native API one by one. @@ -70,32 +70,32 @@ You can repeat these steps for all your nodes, or convert them over to the new n .. raw:: html - - - + var entities = data.data.entities; + var newEntities = []; + for (var i = 0; i < entities.length; i++) { + var entity = entities[i]; + if (entity.platform != "mqtt") { + newEntities.push(entity); + } + } + data.data.entities = newEntities; + elem.value = JSON.stringify(data, null, 4); + }); + 4. Stop Home Assistant - this is necessary for the entity registry changes not to become overriden. @@ -108,8 +108,8 @@ You can repeat these steps for all your nodes, or convert them over to the new n .. code-block:: yaml - # Example configuration entry - api: + # Example configuration entry + api: 8. In Home Assistant, go to "Configuration" -> "Integrations" - if you've set up the ``discovery:`` component, you'll already see the ESP as a suggestion to be configured. But if you're having issues with that, you can diff --git a/components/binary_sensor/index.rst b/components/binary_sensor/index.rst index 4eef94ded..9a79a7ff2 100644 --- a/components/binary_sensor/index.rst +++ b/components/binary_sensor/index.rst @@ -264,24 +264,24 @@ presses. .. code-block:: yaml - on_multi_click: - - timing: - - ON for at most 1s - - OFF for at most 1s - - ON for at most 1s - - OFF for at least 0.2s - then: - - logger.log: "Double Clicked" - - timing: - - ON for 1s to 2s - - OFF for at least 0.5s - then: - - logger.log: "Single Long Clicked" - - timing: - - ON for at most 1s - - OFF for at least 0.5s - then: - - logger.log: "Single Short Clicked" + on_multi_click: + - timing: + - ON for at most 1s + - OFF for at most 1s + - ON for at most 1s + - OFF for at least 0.2s + then: + - logger.log: "Double Clicked" + - timing: + - ON for 1s to 2s + - OFF for at least 0.5s + then: + - logger.log: "Single Long Clicked" + - timing: + - ON for at most 1s + - OFF for at least 0.5s + then: + - logger.log: "Single Short Clicked" .. _binary_sensor-is_on_condition: .. _binary_sensor-is_off_condition: diff --git a/components/display/index.rst b/components/display/index.rst index e0f478a39..a5f8d8010 100644 --- a/components/display/index.rst +++ b/components/display/index.rst @@ -243,7 +243,8 @@ As you can see, when you call ``printf`` most of the string is printed as-is, bu stuff after it is encountered, it is magically replaced by the argument after the format (here ``id(my_sensor).state``). Every time you type a percent sign ``%`` in a printf format string, it will treat the following letters as a format tag -until a so-called "specifier" is encountered (in this case ``f``). You can read more about it `here `__, +until a so-called "specifier" is encountered (in this case ``f``). You can read more about it +`here `__, but for ESPHome there are really just a few things you need to know. Let's break ``%.1f`` down: diff --git a/components/display/lcd_display.rst b/components/display/lcd_display.rst index 89f3f9618..0e5582ed6 100644 --- a/components/display/lcd_display.rst +++ b/components/display/lcd_display.rst @@ -10,7 +10,8 @@ Character-Based LCD Display PCF8574 ------- -The ``lcd_pcf8574`` display platform allows you to use standard character-based LCD displays like `this one `__ +The ``lcd_pcf8574`` display platform allows you to use standard character-based LCD displays like +`this one `__ with ESPHome. This integration is only for LCD displays that display individual characters on a screen (usually 16-20 columns and 2-4 rows), and not for LCD displays that can control each pixel individually. diff --git a/components/display/max7219.rst b/components/display/max7219.rst index 6e20aedf5..09c234c2f 100644 --- a/components/display/max7219.rst +++ b/components/display/max7219.rst @@ -5,7 +5,8 @@ MAX7219 7-Segment Display :description: Instructions for setting up MAX7219 7-segment displays. :image: max7219.jpg -The ``max7219`` display platform allows you to use MAX7219 7-segment display drivers (`datasheet `__, +The ``max7219`` display platform allows you to use MAX7219 7-segment display drivers ( +`datasheet `__, `hobbycomponents `__) with ESPHome. Please note that this integration is *only* for 7-segment display, not matrix configurations. diff --git a/components/display/ssd1306.rst b/components/display/ssd1306.rst index ee4216337..da9ec08e0 100644 --- a/components/display/ssd1306.rst +++ b/components/display/ssd1306.rst @@ -11,8 +11,10 @@ Over I²C -------- The ``ssd1306_i2c`` display platform allows you to use -SSD1306 (`datasheet `__, `Adafruit `__) -and SH1106 (`datasheet `__, `electrodragon `__) +SSD1306 (`datasheet `__, +`Adafruit `__) +and SH1106 (`datasheet `__, +`electrodragon `__) displays with ESPHome. Note that this component is for displays that are connected via the :ref:`I²C Bus `. If your SSD1306 or SH1106 is connected via the 4-Wire :ref:`SPI bus `, see :ref:`ssd1306-spi`. @@ -78,7 +80,8 @@ Over SPI The ``ssd1306_spi`` display platform allows you to use SSD1306 (`datasheet `__, `Adafruit `__) -and SH1106 (`datasheet `__, `electrodragon `__) +and SH1106 (`datasheet `__, +`electrodragon `__) displays with ESPHome. Note that this component is for displays that are connected via the 4-Wire :ref:`SPI bus `. If your SSD1306 or SH1106 is connected via the :ref:`I²C Bus `, see :ref:`ssd1306-i2c`. diff --git a/components/ota.rst b/components/ota.rst index df68d0e94..21df1fad1 100644 --- a/components/ota.rst +++ b/components/ota.rst @@ -36,12 +36,12 @@ Configuration variables: .. note:: - Please be aware that ESP8266 modules must be reset after a serial - upload before OTA can work. - When you are trying to conduct an OTA update and receive an error message - ``Bad Answer: ERR: ERROR[11]: Invalid bootstrapping`` the reason is - very likely that power-cycling the ESP module is required once after - the serial upload. + Please be aware that ESP8266 modules must be reset after a serial + upload before OTA can work. + When you are trying to conduct an OTA update and receive an error message + ``Bad Answer: ERR: ERROR[11]: Invalid bootstrapping`` the reason is + very likely that power-cycling the ESP module is required once after + the serial upload. Updating the password: ---------------------- diff --git a/components/output/my9231.rst b/components/output/my9231.rst index b9e2340e2..9408cb6f9 100644 --- a/components/output/my9231.rst +++ b/components/output/my9231.rst @@ -124,21 +124,21 @@ complete configuration for a Sonoff B1 looks like: .. note:: - One of the features of the MY9231/MY9291 driver is that the chips - remember their state after a power cycling. Unfortunately, the - state of the driver can not be read. Therefore, if ESPHome can - not restore the previous state, it will result in a mismatch of - the driver output and the internal state (= MQTT state). So you - can configure the behaviour on boot time: + One of the features of the MY9231/MY9291 driver is that the chips + remember their state after a power cycling. Unfortunately, the + state of the driver can not be read. Therefore, if ESPHome can + not restore the previous state, it will result in a mismatch of + the driver output and the internal state (= MQTT state). So you + can configure the behaviour on boot time: - ``update_on_boot: True`` - On device power up/boot, the light may flash shortly, to the - state before powering off. + ``update_on_boot: True`` + On device power up/boot, the light may flash shortly, to the + state before powering off. - ``update_on_boot: False`` - On device power up/boot, the light show the last state, but the - internal data will not reflect this state. Thus, the first fade - is wrong, as well as the MQTT state. + ``update_on_boot: False`` + On device power up/boot, the light show the last state, but the + internal data will not reflect this state. Thus, the first fade + is wrong, as well as the MQTT state. .. _my9231-output: diff --git a/components/sensor/dallas.rst b/components/sensor/dallas.rst index 263e36384..fe8516ec7 100644 --- a/components/sensor/dallas.rst +++ b/components/sensor/dallas.rst @@ -2,7 +2,8 @@ Dallas Temperature Sensor ========================= .. seo:: - :description: Instructions for setting up dallas temperature sensor hubs that can expose many temperature sensors on a single pin using the one wire protocol. + :description: Instructions for setting up dallas temperature sensor hubs that can + expose many temperature sensors on a single pin using the one wire protocol. :image: dallas.jpg :keywords: Dallas, ds18b20, onewire @@ -148,7 +149,8 @@ See Also - :ref:`sensor-filters` - :doc:`max6675` -- `Arduino DallasTemperature library `__ by `Miles Burton `__ +- `Arduino DallasTemperature library `__ + by `Miles Burton `__ - :apiref:`sensor/dallas_component.h` - :ghedit:`Edit` diff --git a/components/sensor/dht.rst b/components/sensor/dht.rst index d5812961d..aafdc98de 100644 --- a/components/sensor/dht.rst +++ b/components/sensor/dht.rst @@ -71,9 +71,9 @@ Configuration variables: .. note:: - If you're seeing lots of invalid temperature/humidity warnings in the logs, try manually setting the - DHT model with the ``model:`` configuration variable. Other problems could be wrong pull-up resistor values - on the DATA pin or too long cables. + If you're seeing lots of invalid temperature/humidity warnings in the logs, try manually setting the + DHT model with the ``model:`` configuration variable. Other problems could be wrong pull-up resistor values + on the DATA pin or too long cables. See Also -------- diff --git a/components/sensor/htu21d.rst b/components/sensor/htu21d.rst index 66eb3dfbf..eaf005e41 100644 --- a/components/sensor/htu21d.rst +++ b/components/sensor/htu21d.rst @@ -7,8 +7,7 @@ HTU21D Temperature+Humidity Sensor :keywords: HTU21D The HTU21D Temperature+Humidity sensor allows you to use your HTU21D -(`datasheet `__, -`adafruit `__) sensors with +(`adafruit `__) sensors with ESPHome. The :ref:`I²C Bus ` is required to be set up in your configuration for this sensor to work. diff --git a/components/sensor/ms5611.rst b/components/sensor/ms5611.rst index 967c7bc68..f10326413 100644 --- a/components/sensor/ms5611.rst +++ b/components/sensor/ms5611.rst @@ -7,8 +7,7 @@ MS5611 Atmospheric Pressure Sensor :keywords: MS5611 The ``ms5611`` sensor platform allows you to use your MS5611 atmospheric pressure sensors -(`datasheet `__, -`hobbytronics`_) temperature and pressure sensors with ESPHome. The :ref:`I²C ` is +(`hobbytronics`_) temperature and pressure sensors with ESPHome. The :ref:`I²C ` is required to be set up in your configuration for this sensor to work. .. figure:: images/ms5611-full.jpg diff --git a/components/sensor/xiaomi_mijia.rst b/components/sensor/xiaomi_mijia.rst index 3778afbe6..d66286fea 100644 --- a/components/sensor/xiaomi_mijia.rst +++ b/components/sensor/xiaomi_mijia.rst @@ -91,7 +91,8 @@ See Also - :doc:`/components/sensor/xiaomi_miflora` - :doc:`/components/sensor/index` - :apiref:`esp32_ble_tracker.h` -- `Xiaomi Mijia BLE protocol `__ by `@mspider65 `__ +- `Xiaomi Mijia BLE protocol `__ + by `@mspider65 `__ - `OpenMQTTGateway `__ by `@1technophile `__ - :ghedit:`Edit` diff --git a/components/switch/remote_transmitter.rst b/components/switch/remote_transmitter.rst index 2e3217fcc..6801ea3ad 100644 --- a/components/switch/remote_transmitter.rst +++ b/components/switch/remote_transmitter.rst @@ -215,14 +215,17 @@ Configuration variables: Must be a string of 0s and 1s. For example ``'11001``. - **device** (**Required**, string): The device within the group, usually the state of the last 5 DIP switches. Must be a string of 0s and 1s. For example ``'01000``. - - **state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch is triggered. See :ref:`remote_transmitter-on_off_template`. + - **state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch + is triggered. See :ref:`remote_transmitter-on_off_template`. - **protocol** (*Optional*, :ref:`RCSwitch protocol `): The RCSwitch protocol to use. Defaults to ``1``. -- **rc_switch_type_b**: Send an RCSwitch `type B code `__. +- **rc_switch_type_b**: Send an RCSwitch + `type B code `__. - **address** (**Required**, int): The number of the first rotary switch. For example ``4``. - **channel** (**Required**, int): The number of the first rotary switch. For example ``2``. - - **state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch is triggered. See :ref:`remote_transmitter-on_off_template`. + - **state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch + is triggered. See :ref:`remote_transmitter-on_off_template`. - **protocol** (*Optional*, :ref:`RCSwitch protocol `): The RCSwitch protocol to use. Defaults to ``1``. - **rc_switch_type_c**: Send an RCSwitch `type C code `__. @@ -230,14 +233,16 @@ Configuration variables: - **family** (**Required**, string): The family of the device. Must be a character from ``a`` to ``p``. - **group** (**Required**, int): The group of the device. For example ``4``. - **address** (**Required**, int): The address of the device. For example ``2``. - - **state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch is triggered. See :ref:`remote_transmitter-on_off_template`. + - **state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch + is triggered. See :ref:`remote_transmitter-on_off_template`. - **protocol** (*Optional*, :ref:`RCSwitch protocol `): The RCSwitch protocol to use. Defaults to ``1``. - **rc_switch_type_d**: Send an RCSwitch type D code. - **group** (**Required**, string): The group of the device. Must be a character from ``a`` to ``d``. - **device** (**Required**, int): The address of the device. For example ``3``. - - **state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch is triggered. See :ref:`remote_transmitter-on_off_template`. + - **state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch + is triggered. See :ref:`remote_transmitter-on_off_template`. - **protocol** (*Optional*, :ref:`RCSwitch protocol `): The RCSwitch protocol to use. Defaults to ``1``. - **rc5**: Send a RC5 IR code. diff --git a/components/time.rst b/components/time.rst index 43d45af2f..0ffc1ec79 100644 --- a/components/time.rst +++ b/components/time.rst @@ -51,7 +51,9 @@ Configuration variables: - **id** (*Optional*, :ref:`config-id`): Specify the ID of the time for use in lambdas. - **timezone** (*Optional*, string): Manually tell ESPHome what timezone to use with `this format - `__ (warning: the format is quite complicated) or the simpler `TZ database name `__ in the form /. + `__ (warning: the + format is quite complicated) or the simpler `TZ database name `__ + in the form /. ESPHome tries to automatically infer the timezone string based on the timezone of the computer that is running ESPHome, but this might not always be accurate. - **servers** (*Optional*, list of strings): Choose up to 3 NTP servers that are used for the clock source. diff --git a/cookbook/bme280_environment.rst b/cookbook/bme280_environment.rst index 89e5837fd..bea9513c9 100644 --- a/cookbook/bme280_environment.rst +++ b/cookbook/bme280_environment.rst @@ -8,7 +8,8 @@ BME280 Environment The :doc:`/components/sensor/bme280` is a simple temperature, humidity, and pressure sensor with communication over I2C. With some simple math it is possible to either determine the height of the sensor, or the current pressure at sea level. -This guide can be applied to any sensor measuring temperature and pressure at the same time, like the :doc:`/components/sensor/bmp280`, or :doc:`/components/sensor/bme680`. +This guide can be applied to any sensor measuring temperature and pressure at the same time, like the +:doc:`/components/sensor/bmp280`, or :doc:`/components/sensor/bme680`. .. figure:: images/bme280-header.jpg :align: center @@ -36,30 +37,38 @@ After validating the sensor is working, we can proceed and add some formulas. name: "Altitude" lambda: |- const float STANDARD_SEA_LEVEL_PRESSURE = 1013.25; //in hPa, see note - return ((id(bme280_temperature).state + 273.15) / 0.0065) * (powf((STANDARD_SEA_LEVEL_PRESSURE / id(bme280_pressure).state), 0.190234) - 1); // in meter + return ((id(bme280_temperature).state + 273.15) / 0.0065) * + (powf((STANDARD_SEA_LEVEL_PRESSURE / id(bme280_pressure).state), 0.190234) - 1); // in meter update_interval: 15s - platform: template name: "Absolute Humidity" lambda: |- const float mw = 18.01534; // molar mass of water g/mol const float r = 8.31447215; // Universal gas constant J/mol/K - return (6.112 * powf(2.718281828, (17.67 * id(bme280_temperature).state) / (id(bme280_temperature).state + 243.5)) * id(bme280_humidity).state * mw) / ((273.15 + id(bme280_temperature).state) * r); // in grams/m^3 + return (6.112 * powf(2.718281828, (17.67 * id(bme280_temperature).state) / + (id(bme280_temperature).state + 243.5)) * id(bme280_humidity).state * mw) / + ((273.15 + id(bme280_temperature).state) * r); // in grams/m^3 update_interval: 15s Altitude and absolute humidity: ------------------------------- -The first block ``sensor`` starts with the normal bme280 sensor components ``temperature``, ``pressure``, and ``humidity`` with each their own id. +The first block ``sensor`` starts with the normal bme280 sensor components ``temperature``, ``pressure``, +and ``humidity`` with each their own id. After the bme280 sensor, a :doc:`/components/sensor/template` is defined to calculate the altitude in a lambda. The variable ``STANDARD_SEA_LEVEL_PRESSURE`` (in hPa), should be filled in for your location. -The formula derived from `here `, converts the currently measured pressure to the altitudes in meters including temperature compensation. +The formula derived from `here `__, +converts the currently measured pressure to the altitudes in meters including temperature compensation. -The lambda in the second :doc:`/components/sensor/template` defines two physical constants and converts the currently measured pressure to absolute humidity (grams/m^3). +The lambda in the second :doc:`/components/sensor/template` defines two physical constants and +converts the currently measured pressure to absolute humidity (grams/m^3). .. note:: Calculating the altitude with the BME280 sensor accurately requires this value to be known at sea level for your location and day. - This can be achieved by replacing the global constant ``STANDARD_SEA_LEVEL_PRESSURE`` by for example pulling this value live from the internet or a stationary sensor via MQTT. + + This can be achieved by replacing the global constant ``STANDARD_SEA_LEVEL_PRESSURE`` by for example + pulling this value live from the internet or a stationary sensor via MQTT. Equivalent sea level pressure: ------------------------------ @@ -85,7 +94,8 @@ Calculating the sea level pressure with a statically mounted sensor can be be us name: "Equivalent sea level pressure" lambda: |- const float STANDARD_ALTITUDE = 0.6; // in meters, see note - return id(bme280_pressure).state / powf(1 - ((0.0065 * STANDARD_ALTITUDE) / (id(bme280_temperature).state + (0.0065 * STANDARD_ALTITUDE) + 273.15)), 5.257); // in hPa + return id(bme280_pressure).state / powf(1 - ((0.0065 * STANDARD_ALTITUDE) / + (id(bme280_temperature).state + (0.0065 * STANDARD_ALTITUDE) + 273.15)), 5.257); // in hPa update_interval: 15s .. note:: diff --git a/cookbook/display_time_temp_oled.rst b/cookbook/display_time_temp_oled.rst index a49444892..a15138d8f 100644 --- a/cookbook/display_time_temp_oled.rst +++ b/cookbook/display_time_temp_oled.rst @@ -10,7 +10,8 @@ Time & Temperature on OLED Display :align: left :width: 75.0% -In this example I have used a :doc:`SSD1306 OLED Display over I²C ` to show current time and two different temperature values from Home Assistant. +In this example I have used a :doc:`SSD1306 OLED Display over I²C ` to +show current time and two different temperature values from Home Assistant. ESPHome has support for several different types of displays. The display used here is 1.3" with 128x64 monochrome pixels (``SH1106 128x64``). @@ -45,7 +46,7 @@ Get the time from Home Assistant to sync the onboard real-time-clock. Getting Temperature ******************* -Next, we want to get two temperature sensors imported from Home Assistant. +Next, we want to get two temperature sensors imported from Home Assistant. I named them ``inside_temperature`` and ``outside_temperature``. You will use those references later. @@ -56,7 +57,7 @@ By adding ``internal: true`` to the sensors they won't be published back to Home sensor: - platform: homeassistant id: inside_temperature - entity_id: sensor.mellanvaning_temperature + entity_id: sensor.mellanvaning_temperature internal: true - platform: homeassistant @@ -68,8 +69,8 @@ Define the Fonts **************** - TrueType fonts are used. If you ever worked with fonts on microcontrollers you will love this! -- Save font files in ``/config/esphome`` folder where your esphome configuration is stored. -- The ``.ttf`` suffix must be lowercase and of course match your filename. +- Save font files in ``/config/esphome`` folder where your esphome configuration is stored. +- The ``.ttf`` suffix must be lowercase and of course match your filename. - Selection of fonts can be a little bit tricky for small sizes to look good. Experiment and share your findings in the comments below! .. code-block:: yaml @@ -90,7 +91,7 @@ Define the Fonts Display Definition ****************** -Now setup the communication to the display and start fill the screen with live data! +Now setup the communication to the display and start fill the screen with live data! The ``reset_pin`` was not used in my hardware configuration as the display didn't had that pin exposed. @@ -113,16 +114,16 @@ Note your ``address`` and ``model`` might be different, use the scan option to f it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "Mitt Smarta Hus"); // Print time in HH:MM format - it.strftime(0, 60, id(font2), TextAlign::BASELINE_LEFT, "%H:%M", id(time).now()); + it.strftime(0, 60, id(font2), TextAlign::BASELINE_LEFT, "%H:%M", id(time).now()); // Print inside temperature (from homeassistant sensor) - if (id(inside_temperature).has_state()) { + if (id(inside_temperature).has_state()) { it.printf(127, 23, id(font3), TextAlign::TOP_RIGHT , "%.1f°", id(inside_temperature).state); - } + } // Print outside temperature (from homeassistant sensor) - if (id(outside_temperature).has_state()) { - it.printf(127, 60, id(font3), TextAlign::BASELINE_RIGHT , "%.1f°", id(outside_temperature).state); + if (id(outside_temperature).has_state()) { + it.printf(127, 60, id(font3), TextAlign::BASELINE_RIGHT , "%.1f°", id(outside_temperature).state); } Rendering diff --git a/cookbook/dual-r2-cover.rst b/cookbook/dual-r2-cover.rst index 98b2b9c8b..bc118b02d 100644 --- a/cookbook/dual-r2-cover.rst +++ b/cookbook/dual-r2-cover.rst @@ -30,22 +30,22 @@ for some motors. .. code-block:: yaml - esphome: + esphome: name: cover platform: ESP8266 board: esp01_1m - wifi: + wifi: ssid: '***' password: '***' - api: + api: - logger: + logger: - ota: + ota: - binary_sensor: + binary_sensor: - platform: gpio pin: number: 10 @@ -73,7 +73,7 @@ for some motors. } } - switch: + switch: - platform: gpio pin: 12 id: open @@ -81,7 +81,7 @@ for some motors. pin: 5 id: close - cover: + cover: - platform: template name: "Cover" id: cover diff --git a/cookbook/h801.rst b/cookbook/h801.rst index 1f0e20836..d8e62e8ef 100644 --- a/cookbook/h801.rst +++ b/cookbook/h801.rst @@ -2,7 +2,8 @@ H801 RGBW LED controller ======================== The H801 is pretty afordable and easy to hack and adapt to your needs. It can be found on `Aliexpress `__ -`Here `__ is an article about the hardware for those who have an interest for more details about the board. +`Here `__ is an article about the +hardware for those who have an interest for more details about the board. It can be used as a RGB, RGBW, RGB dual white or even control 5 individual monochromatic strips if you want or combinations of these. .. figure:: images/h801.jpg @@ -21,7 +22,7 @@ and the :doc:`ESP8266 Software PWM output ` comp wifi: ssid: 'WIFI' password: 'WIFIPASS' - manual_ip: + manual_ip: static_ip: x.x.x.x gateway: x.x.x.x subnet: 255.255.255.0 @@ -37,15 +38,15 @@ and the :doc:`ESP8266 Software PWM output ` comp - platform: esp8266_pwm pin: 12 frequency: 1000 Hz - id: pwm_b + id: pwm_b - platform: esp8266_pwm pin: 15 frequency: 1000 Hz - id: pwm_g + id: pwm_g - platform: esp8266_pwm pin: 13 frequency: 1000 Hz - id: pwm_r + id: pwm_r - platform: esp8266_pwm pin: 14 frequency: 1000 Hz @@ -87,10 +88,12 @@ This LED strip can be used with the sketch as-is For this type of led strip you have to swap the white and blue gpio numbers in the sketch -You will need to solder pins to the board inside the h801 (fortunately its pretty roomy and not a lot of components or stuff in the way part from the 2 wires on the back) +You will need to solder pins to the board inside the h801 (fortunately its pretty roomy and +not a lot of components or stuff in the way part from the 2 wires on the back) -3.3v, GND, TX and RX (RX to RX and TX to TX) needs to be connected to your serial adapter, the two other pins must be shorted by a jumper or a breadboard cable when flashing. -(Remember to remove it after flashing) +3.3v, GND, TX and RX (RX to RX and TX to TX) needs to be connected to your serial adapter, the +two other pins must be shorted by a jumper or a breadboard cable when flashing. +(Remember to remove it after flashing) See Also -------- diff --git a/cookbook/sonoff-fishpond-pump.rst b/cookbook/sonoff-fishpond-pump.rst index 49f153306..9ccc1647b 100644 --- a/cookbook/sonoff-fishpond-pump.rst +++ b/cookbook/sonoff-fishpond-pump.rst @@ -31,7 +31,7 @@ As many of the details on here a predicated on existing installations and knowle * You have installed the relevant environment and it is functional (Home Assisant, ESPHome). * You need to create your own secrets.yaml file. * You are proficient in reading instructions and capable of using a search engine. -* You will look at the documentation on https://esphome.io/ (we may have missed something in this example). +* You will look at the documentation on this website (we may have missed something in this example). * This serves only as a guide and errors and outlets are excluded. .. warning:: @@ -137,6 +137,7 @@ Here is the configuration with the basic operations outlined above. 2. Programming ************** + Follow the standard way of uploading to your Sonoff basic. .. figure:: images/sonoff-fishpond-pump-1-programming.jpg diff --git a/devices/esp8266.rst b/devices/esp8266.rst index eace588bb..4125beebc 100644 --- a/devices/esp8266.rst +++ b/devices/esp8266.rst @@ -145,7 +145,8 @@ Reset Causes ------------ Additionally, the first line also contains the **reset cause**. -These reset causes `are documented `__: +These reset causes `are documented +`__: == =================================== 0 Undefined diff --git a/devices/sonoff_basic.rst b/devices/sonoff_basic.rst index 2bd960520..c4b77a140 100644 --- a/devices/sonoff_basic.rst +++ b/devices/sonoff_basic.rst @@ -116,7 +116,8 @@ See https://randomnerdtutorials.com/how-to-flash-a-custom-firmware-to-sonoff/ fo * Press and hold the toggle pin (long black pin next to LED and custom soldered pins). * Supply USB power to Sonoff via FTDI (e.g. plug in USB to the FTDI, or use a power switch as explained in link above). -* Keep holding the toggle pin for approx 3-5 seconds now you should be ready to program. If you get a message unable to communicate when trying flash, check your TX/RX pin or retry entering boot mode again. +* Keep holding the toggle pin for approx 3-5 seconds now you should be ready to program. + If you get a message unable to communicate when trying flash, check your TX/RX pin or retry entering boot mode again. Quick notes: @@ -140,58 +141,59 @@ You should get an output starting like this .. code-block:: text - INFO Reading configuration... - INFO Detected timezone 'SAST' with UTC offset 2 - INFO Generating C++ source... - INFO Compiling app... - INFO Running: platformio run -d fishpond - ******************************************************************************************************** - Obsolete PIO Core v3.6.3 is used (previous was 3.6.4b1) - Please remove multiple PIO Cores from a system: - https://docs.platformio.org/page/faq.html#multiple-pio-cores-in-a-system - ... - lots of compile stuff - ... - Memory Usage -> http://bit.ly/pio-memory-usage - DATA: [====== ] 55.6% (used 45512 bytes from 81920 bytes) - PROGRAM: [==== ] 38.1% (used 390576 bytes from 1023984 bytes) - ===================================== [SUCCESS] Took 4.70 seconds ===================================== - INFO Successfully compiled program. - Found multiple options, please choose one: + INFO Reading configuration... + INFO Detected timezone 'SAST' with UTC offset 2 + INFO Generating C++ source... + INFO Compiling app... + INFO Running: platformio run -d fishpond + ******************************************************************************************************** + Obsolete PIO Core v3.6.3 is used (previous was 3.6.4b1) + Please remove multiple PIO Cores from a system: + https://docs.platformio.org/page/faq.html#multiple-pio-cores-in-a-system + ... + lots of compile stuff + ... + Memory Usage -> http://bit.ly/pio-memory-usage + DATA: [====== ] 55.6% (used 45512 bytes from 81920 bytes) + PROGRAM: [==== ] 38.1% (used 390576 bytes from 1023984 bytes) + ===================================== [SUCCESS] Took 4.70 seconds ===================================== + INFO Successfully compiled program. + Found multiple options, please choose one: [1] /dev/ttyUSB0 (FT232R USB UART) [2] Over The Air (fishpond.device) - (number): 1 - INFO Running: esptool.py --before default_reset --after hard_reset --chip esp8266 --port /dev/ttyUSB0 write_flash 0x0 fishpond/.pioenvs/fishpond/firmware.bin - esptool.py v2.6 - Serial port /dev/ttyUSB0 - Connecting.... - Chip is ESP8266EX - Features: WiFi - MAC: xx:xx:xx:xx:xx:xx - Uploading stub... - Running stub... - Stub running... - Configuring flash size... - Auto-detected Flash size: 1MB - Compressed 394720 bytes to 267991... - Wrote 394720 bytes (267991 compressed) at 0x00000000 in 23.8 seconds (effective 132.7 kbit/s)... - Hash of data verified. + (number): 1 + ... + esptool.py v2.6 + Serial port /dev/ttyUSB0 + Connecting.... + Chip is ESP8266EX + Features: WiFi + MAC: xx:xx:xx:xx:xx:xx + Uploading stub... + Running stub... + Stub running... + Configuring flash size... + Auto-detected Flash size: 1MB + Compressed 394720 bytes to 267991... + Wrote 394720 bytes (267991 compressed) at 0x00000000 in 23.8 seconds (effective 132.7 kbit/s)... + Hash of data verified. - Leaving... - Hard resetting via RTS pin... - INFO Successfully uploaded program. - INFO Starting log output from /dev/ttyUSB0 with baud rate 115200 + Leaving... + Hard resetting via RTS pin... + INFO Successfully uploaded program. + INFO Starting log output from /dev/ttyUSB0 with baud rate 115200 1.3. And then nothing will happen ********************************* -Once you have flashed the device, nothing will happen. You need to power cycle the device. You will notice the LED will start to flash and then becomes solid once connected to the WiFi network. +Once you have flashed the device, nothing will happen. You need to power cycle the device. +You will notice the LED will start to flash and then becomes solid once connected to the WiFi network. You can follow the logs produced by the running module by running the command .. code-block:: bash - esphome .yaml logs + esphome .yaml logs Your output will possibly look like this diff --git a/guides/automations.rst b/guides/automations.rst index 5f0839ae4..9bf0076ad 100644 --- a/guides/automations.rst +++ b/guides/automations.rst @@ -313,8 +313,10 @@ All Triggers - :ref:`mqtt.on_message ` / :ref:`mqtt.on_json_message ` - :ref:`sensor.on_value ` / :ref:`sensor.on_raw_value ` / :ref:`sensor.on_value_range ` -- :ref:`binary_sensor.on_press ` / :ref:`binary_sensor.on_release ` / :ref:`binary_sensor.on_state ` -- :ref:`binary_sensor.on_click ` / :ref:`binary_sensor.on_double_click ` / :ref:`binary_sensor.on_multi_click ` +- :ref:`binary_sensor.on_press ` / :ref:`binary_sensor.on_release ` / + :ref:`binary_sensor.on_state ` +- :ref:`binary_sensor.on_click ` / :ref:`binary_sensor.on_double_click ` / + :ref:`binary_sensor.on_multi_click ` - :ref:`esphome.on_boot ` / :ref:`esphome.on_shutdown ` / :ref:`esphome.on_loop ` - :ref:`pn532.on_tag ` - :ref:`time.on_time ` @@ -363,8 +365,8 @@ time period. .. code-block:: yaml - on_...: - then: + on_...: + then: - switch.turn_on: relay_1 - delay: 2s - switch.turn_off: relay_1 diff --git a/guides/contributing.rst b/guides/contributing.rst index 6a5ffb20f..3b67867c9 100644 --- a/guides/contributing.rst +++ b/guides/contributing.rst @@ -109,11 +109,11 @@ RST primer: .. code-block:: yaml - # Sample configuration entry - switch: - - platform: gpio - name: "Relay #42" - pin: GPIO13 + # Sample configuration entry + switch: + - platform: gpio + name: "Relay #42" + pin: GPIO13 .. note:: @@ -130,10 +130,10 @@ RST primer: Optional figure caption. .. figure:: images/dashboard.png - :align: center - :width: 40.0% + :align: center + :width: 40.0% - Optional figure caption. + Optional figure caption. .. note:: @@ -149,19 +149,19 @@ RST primer: .. note:: - This is a note. + This is a note. .. warning:: - This is a warning. + This is a warning. .. note:: - This is a note. + This is a note. .. warning:: - This is a warning. + This is a warning. - **Italic and boldface font families**: To *italicize* text, use one asterisk around the text. To put **a strong emphasis** on a piece of text, put two asterisks around it. @@ -198,7 +198,8 @@ RST primer: 1. Ordered Item #1 2. Ordered Item #2 -- **imgtable**: ESPHome uses a custom RST directive to show the table on the front page (see `index.rst `__). +- **imgtable**: ESPHome uses a custom RST directive to show the table on the front page (see + `index.rst `__). New pages need to be added to the ``imgtable`` list. The syntax is CSV with , (without RST), (in top-level images/ directory). The aspect ratio of these images should be 8:10 (or 10:8) but exceptions are possible. @@ -215,6 +216,7 @@ please have a look at the `Sphinx reStructuredText Primer `__: diff --git a/guides/faq.rst b/guides/faq.rst index 2ba138b6b..bf918b1fb 100644 --- a/guides/faq.rst +++ b/guides/faq.rst @@ -8,7 +8,8 @@ Frequently Asked Questions Tips for using ESPHome ---------------------- -1. ESPHome supports (most of) `Home Assistant's YAML configuration directives `__ like +1. ESPHome supports (most of) `Home Assistant's YAML configuration directives + `__ like ``!include``, ``!secret``. So you can store all your secret WiFi passwords and so on in a file called ``secrets.yaml`` within the directory where the configuration file is. @@ -252,11 +253,12 @@ And a docker compose file looks like this: ESPHome uses mDNS to show online/offline state in the dashboard view. So for that feature to work you need to enable host networking mode - - mDNS might not work if your Home Assistant server and your ESPHome nodes are on different subnets. If your router supports Avahi, you are able to get mDNS working over different subnets. - + + mDNS might not work if your Home Assistant server and your ESPHome nodes are on different subnets. + If your router supports Avahi, you are able to get mDNS working over different subnets. + Just follow the next steps: - + 1. Enable Avahi on both subnets. 2. Enable UDP traffic from ESPHome node's subnet to 224.0.0.251/32 on port 5353. diff --git a/images/index.rst b/images/index.rst index 1153ece16..ce073c487 100644 --- a/images/index.rst +++ b/images/index.rst @@ -5,13 +5,22 @@ This is a dummy file to include images in the sphinx output that will only be used in raw HTML and thus not auto-included. .. image:: shield-discord.svg + .. image:: shield-github.svg + .. image:: shield-donate.svg + .. image:: shield-twitter.svg + .. image:: logo.svg + .. image:: logo-core.svg + .. image:: logo-docs.svg + .. image:: logo-flasher.svg + .. image:: logo-release.svg + .. image:: logo-text.svg diff --git a/index.rst b/index.rst index 9242073ed..23e6771e4 100644 --- a/index.rst +++ b/index.rst @@ -5,14 +5,17 @@ ESPHome :google-site-verification: Q5q5TFbCofxA8-cSa1Frv5Hj4RopF5zwEZf_zaNHqf4 .. seo:: - :description: ESPHome Homepage - Reimagining DIY Home Automation. ESPHome is a framework that tries to provide the best possible use experience for using ESP8266 and ESP32 microcontrollers for Home Automation. Just write a simple YAML configuration file and get your own customized firmware. + :description: ESPHome Homepage - Reimagining DIY Home Automation. ESPHome is a framework that + tries to provide the best possible use experience for using ESP8266 and ESP32 microcontrollers + for Home Automation. Just write a simple YAML configuration file and get your own customized firmware. :image: logo.png .. image:: /images/logo-text.svg .. raw:: html - GitHub + GitHub Discord Twitter Donate diff --git a/seo.py b/seo.py index 0a7a5ec81..546e737d9 100644 --- a/seo.py +++ b/seo.py @@ -10,7 +10,7 @@ class SEONode(nodes.General, nodes.Element): author=None, author_twitter=None, keywords=None): super(SEONode, self).__init__() self.title = title - self.description = description + self.description = description.replace('\n', ' ') self.image = image self.author = author self.author_twitter = author_twitter diff --git a/travis.py b/travis.py index 91dff439f..9d7f048ef 100644 --- a/travis.py +++ b/travis.py @@ -6,7 +6,7 @@ errors = [] def find_all(a_str, sub): - for i, line in enumerate(a_str.splitlines(keepends=False)): + for i, line in enumerate(a_str.splitlines()): column = 0 while True: column = line.find(sub, column) @@ -17,6 +17,9 @@ def find_all(a_str, sub): section_regex = re.compile(r'^(=+|-+|\*+|~+)$') +directive_regex = re.compile(r'^(\s*)\.\. (.*)::.*$') +directive_arg_regex = re.compile(r'^(\s+):.*:\s*.*$') +esphome_io_regex = re.compile(r'https://esphome.io/') for f in sorted(Path('.').glob('**/*.rst')): @@ -25,14 +28,29 @@ for f in sorted(Path('.').glob('**/*.rst')): except UnicodeDecodeError: errors.append("File {} is not readable as UTF-8. Please set your editor to UTF-8 mode." "".format(f)) + continue + + if not content.endswith('\n'): + errors.append("Newline at end of file missing. Please insert an empty line at end " + "of file {}".format(f)) + + # Check tab character for line, col in find_all(content, '\t'): errors.append("File {} contains tab character on line {}:{}. " - "Please convert tabs to spaces.".format(f, line, col)) + "Please convert tabs to spaces.".format(f, line + 1, col)) + # Check windows newline for line, col in find_all(content, '\r'): errors.append("File {} contains windows newline on line {}:{}. " - "Please set your editor to unix newline mode.".format(f, line, col)) + "Please set your editor to unix newline mode.".format(f, line + 1, col)) lines = content.splitlines(keepends=False) + + # Check whitespace at end of line + for i, line in enumerate(lines): + if line.rstrip() != line: + errors.append("Lines must not contain spaces at the end of the line. Please " + "remove spaces at the end of {}:{}".format(f, i+1)) + for i, line in enumerate(lines): if i == 0: continue @@ -42,7 +60,63 @@ for f in sorted(Path('.').glob('**/*.rst')): line_above = lines[i - 1] if len(line_above) != len(line): errors.append("The title length must match the bar length below it. See {}:{}" - "".format(f, i)) + "".format(f, i+1)) + if i + 1 < len(lines) and lines[i + 1]: + errors.append("Empty line after heading is missing. Please insert an " + "empty line. See {}:{}".format(f, i+1)) + + for i, line in enumerate(lines): + m = directive_regex.match(line) + if m is None: + continue + base_indentation = len(m.group(1)) + directive_name = m.group(2) + if directive_name.startswith('|') or directive_name == 'seo': + continue + # Match directive args + for j in range(i + 1, len(lines)): + if not directive_arg_regex.match(lines[j]): + break + else: + # Reached end of file + continue + + # Empty line must follow + if lines[j]: + errors.append("Directive '{}' is not followed by an empty line. Please insert an " + "empty line after {}:{}".format(directive_name, f, j)) + continue + + k = j + 1 + for j in range(k, len(lines)): + if not lines[j]: + # Ignore Empty lines + continue + + num_spaces = len(lines[j]) - len(lines[j].lstrip()) + if num_spaces <= base_indentation: + # Finished with this directive + break + num_indent = num_spaces - base_indentation + if j == k and num_indent != 4: + errors.append("Directive '{}' must be indented with 4 spaces, not {}. See " + "{}:{}".format(directive_name, num_indent, f, j+1)) + break + + # Check line length + for i, line in enumerate(lines): + max_line_length = 160 + if len(line) > max_line_length: + errors.append("Lines must not be longer than {} characters. Line {}:{} is {} " + "characters long. Please insert newlines." + "".format(max_line_length, f, i+1, len(line))) + + for i, line in enumerate(lines): + if esphome_io_regex.search(line): + if 'privacy.rst' in str(f) or 'web_server.rst' in str(f): + continue + errors.append("All links to esphome.io should be relative, please remove esphome.io " + "from URL. See {}:{}".format(f, i+1)) for error in errors: diff --git a/web-api/index.rst b/web-api/index.rst index f343c60dc..acf8f8bf5 100644 --- a/web-api/index.rst +++ b/web-api/index.rst @@ -182,7 +182,7 @@ Fan *** Fans are similar to switches as they can be turned on/off and toggled. In addition, if the -underlying fan supports it, fans in the web server also support the speed settings "low", +underlying fan supports it, fans in the web server also support the speed settings "low", "medium" and "high" and an oscillation setting. To get the current state of a fan, create a GET request to ``/fan/``.