diff --git a/api/binary_sensor/index.rst b/api/binary_sensor/index.rst index 85e9af687..b3c359807 100644 --- a/api/binary_sensor/index.rst +++ b/api/binary_sensor/index.rst @@ -14,14 +14,9 @@ Supported Binary Sensors ------------------------ .. toctree:: + :glob: - esp32_touch - gpio - pn532 - rdm6300 - remote_receiver - status - template + * Example Usage ------------- diff --git a/api/cover/index.rst b/api/cover/index.rst index 9e4a79cfe..9b45233fd 100644 --- a/api/cover/index.rst +++ b/api/cover/index.rst @@ -5,8 +5,9 @@ Supported Covers ---------------- .. toctree:: + :glob: - template + * Example Usage ------------- diff --git a/api/display/index.rst b/api/display/index.rst index 72765761f..b0ac025da 100644 --- a/api/display/index.rst +++ b/api/display/index.rst @@ -5,12 +5,9 @@ Supported Displays ------------------ .. toctree:: + :glob: - lcd_display - max7219 - nextion - ssd1306 - waveshare_epaper + * API Reference ------------- diff --git a/api/light/index.rst b/api/light/index.rst index 485609b73..09a26600b 100644 --- a/api/light/index.rst +++ b/api/light/index.rst @@ -8,7 +8,9 @@ access a combined :cpp:class:`LightState` object and use only that to set state state updates. .. toctree:: - fastled.rst + :glob: + + * Example Usage ------------- diff --git a/api/misc/index.rst b/api/misc/index.rst index 3722329b1..1ab8ec106 100644 --- a/api/misc/index.rst +++ b/api/misc/index.rst @@ -2,9 +2,6 @@ Miscellaneous Components ======================== .. toctree:: + :glob: - pcf8574 - esp32_ble_tracker - debug - status_led - esp32_ble_beacon + * diff --git a/api/output/index.rst b/api/output/index.rst index de9463d09..e11223748 100644 --- a/api/output/index.rst +++ b/api/output/index.rst @@ -4,10 +4,9 @@ Output The `output` namespace contains all peripheral output components. .. toctree:: - GPIO Binary Output - LEDC PWM Output - PCA9685 Output - ESP8266 Software PWM + :glob: + + * API Reference ------------- diff --git a/api/sensor/index.rst b/api/sensor/index.rst index e16357321..7cb8bfaed 100644 --- a/api/sensor/index.rst +++ b/api/sensor/index.rst @@ -8,43 +8,9 @@ The `sensor` namespace contains all sensors. See :cpp:func:`Application::register_sensor`. .. toctree:: - :maxdepth: 1 + :glob: - adc - ads1115 - bh1750 - bme280 - bme680 - bmp085 - bmp280 - cse7766 - dallas - dht - dht12 - duty_cycle - esp32_hall - hdc1080 - hlw8012 - hmc5883l - htu21d - hx711 - ina219 - ina3221 - max6675 - mhz19 - mpu6050 - mqtt_subscribe - ms5611 - pmsx003 - pulse_counter - rotary_encoder - sht3xd - tcs34725 - template - tsl2561 - ultrasonic - uptime - wifi_signal + * API Reference diff --git a/api/switch/index.rst b/api/switch/index.rst index 82db2e459..c17897b8a 100644 --- a/api/switch/index.rst +++ b/api/switch/index.rst @@ -4,12 +4,9 @@ Switch The `switch_` namespace contains all switch helpers. .. toctree:: + :glob: - remote_transmitter - restart - shutdown - template - uart + * API Reference ------------- diff --git a/esphomeyaml/components/binary_sensor/index.rst b/esphomeyaml/components/binary_sensor/index.rst index 425c71fce..189efebdd 100644 --- a/esphomeyaml/components/binary_sensor/index.rst +++ b/esphomeyaml/components/binary_sensor/index.rst @@ -61,7 +61,7 @@ They are similar to :ref:`Sensor Filters `. - delayed_on: 100ms - delayed_off: 100ms - lambda: >- - if (id(other_binary_sensor).value) { + if (id(other_binary_sensor).state) { return x; } else { return {}; @@ -93,7 +93,7 @@ perfectly fit every use case, but at least makes the naming consistent. For exam in the first moment when the button on your mouse is pushed down. You can access the current state of the binary sensor in :ref:`lambdas ` using -``id(binary_sensor_id).value``. +``id(binary_sensor_id).state``. .. _binary_sensor-on_press: @@ -206,12 +206,12 @@ advanced stuff (see the full :doc:`API Reference ` for // Within lambda, publish an ON state. id(my_binary_sensor).publish_state(true); -- ``value``: Retrieve the current value of the binary sensor. +- ``.state``: Retrieve the current state of the binary sensor. .. code:: yaml // Within lambda, get the binary sensor state and conditionally do something - if (id(my_binary_sensor).value) { + if (id(my_binary_sensor).state) { // Binary sensor is ON, do something here } else { // Binary sensor is OFF, do something else here @@ -226,15 +226,8 @@ See Also .. toctree:: :maxdepth: 1 + :glob: - gpio - status - esp32_ble_tracker - esp32_touch - template - remote_receiver - pn532 - rdm6300 - nextion + * .. disqus:: diff --git a/esphomeyaml/components/binary_sensor/template.rst b/esphomeyaml/components/binary_sensor/template.rst index 91dd6a505..29a59969f 100644 --- a/esphomeyaml/components/binary_sensor/template.rst +++ b/esphomeyaml/components/binary_sensor/template.rst @@ -14,12 +14,12 @@ a binary sensor. - platform: template name: "Garage Door Open" lambda: >- - if (isnan(id(ultrasonic_sensor1).value)) { + if (isnan(id(ultrasonic_sensor1).state)) { // isnan checks if the ultrasonic sensor echo // has timed out, resulting in a NaN (not a number) state // in that case, return {} to indicate that we don't know. return {}; - } else if (id(ultrasonic_sensor1).value > 30) { + } else if (id(ultrasonic_sensor1).state > 30) { // Garage Door is open. return true; } else { diff --git a/esphomeyaml/components/cover/index.rst b/esphomeyaml/components/cover/index.rst index 7d7938b71..542557346 100644 --- a/esphomeyaml/components/cover/index.rst +++ b/esphomeyaml/components/cover/index.rst @@ -16,8 +16,15 @@ This action opens the cover with the given ID when executed. on_...: then: - - cover.open: - id: cover_1 + - cover.open: cover_1 + +.. note:: + + This action can also be expressed in :ref:`lambdas `: + + .. code:: cpp + + id(cover_1).open(); .. _cover-close_action: @@ -30,8 +37,15 @@ This action closes the cover with the given ID when executed. on_...: then: - - cover.close: - id: cover_1 + - cover.close: cover_1 + +.. note:: + + This action can also be expressed in :ref:`lambdas `: + + .. code:: cpp + + id(cover_1).close(); .. _cover-stop_action: @@ -44,8 +58,15 @@ This action stops the cover with the given ID when executed. on_...: then: - - cover.stop: - id: cover_1 + - cover.stop: cover_1 + +.. note:: + + This action can also be expressed in :ref:`lambdas `: + + .. code:: cpp + + id(cover_1).stop(); lambda calls @@ -69,34 +90,10 @@ advanced stuff (see the full :doc:`API Reference ` for more in if (id(my_cover).state == cover::COVER_OPEN) { // Cover is open - } else if (id(my_cover).state == cover::COVER_CLOSED) { - // Cover is closed } else { - // The cover hasn't reported any state yet. + // Cover is closed } -- ``open()``: Manually cause the cover to open from code. Similar to the ``cover.open`` - action, but can be used in complex lambda expressions. - - .. code:: yaml - - id(my_cover).open(); - -- ``close()``: Manually cause the cover to close from code. Similar to the ``cover.close`` - action, but can be used in complex lambda expressions. - - .. code:: yaml - - id(my_cover).close(); - -- ``stop()``: Manually cause the cover to stop from code. Similar to the ``cover.stop`` - action, but can be used in complex lambda expressions. - - .. code:: yaml - - id(my_cover).stop(); - - See Also -------- @@ -105,7 +102,8 @@ See Also .. toctree:: :maxdepth: 1 + :glob: - template.rst + * .. disqus:: diff --git a/esphomeyaml/components/cover/template.rst b/esphomeyaml/components/cover/template.rst index e7044923b..d1fbb3ac8 100644 --- a/esphomeyaml/components/cover/template.rst +++ b/esphomeyaml/components/cover/template.rst @@ -16,7 +16,7 @@ as a cover and can be controlled through the frontend. - platform: template name: "Template Cover" lambda: >- - if (id(top_end_stop).value) { + if (id(top_end_stop).state) { return cover::COVER_OPEN; } else { return cover::COVER_CLOSED; diff --git a/esphomeyaml/components/display/index.rst b/esphomeyaml/components/display/index.rst index 16e2f8415..db6b74f40 100644 --- a/esphomeyaml/components/display/index.rst +++ b/esphomeyaml/components/display/index.rst @@ -232,11 +232,11 @@ For example, a printf call can look like this: - platform: ... # ... lambda: |- - it.printf(0, 0, id(my_font), "The sensor value is: %.1f", id(my_sensor).value); + it.printf(0, 0, id(my_font), "The sensor value is: %.1f", id(my_sensor).state); // If the sensor has the value 30.02, the result will be: "The sensor value is: 30.0" As you can see, when you call ``printf`` most of the string is printed as-is, but when this weird percent sign with some -stuff after it is encountered, it is magically replaced by the argument after the format (here ``id(my_sensor).value``). +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 `__, @@ -270,7 +270,7 @@ arguments after the format string in the right order. # ... lambda: |- // %% - literal % sign - it.printf(0, 0, id(my_font), "Temperature: %.1f°C, Humidity: %.1f%%", id(temperature).value, id(humidity).value); + it.printf(0, 0, id(my_font), "Temperature: %.1f°C, Humidity: %.1f%%", id(temperature).state, id(humidity).state); The last printf tip for use in displays I will discuss here is how to display binary sensor values. You @@ -289,13 +289,13 @@ use any string you pass it, like ``"ON"`` or ``"OFF"``. - platform: ... # ... lambda: |- - if (id(my_binary_sensor).value) { + if (id(my_binary_sensor).state) { it.print(0, 0, id(my_font), "state: ON"); } else { it.print(0, 0, id(my_font), "state: OFF"); } // Shorthand: - it.printf(0, 0, id(my_font), "State: %s", id(my_binary_sensor).value ? "ON" : "OFF"); + it.printf(0, 0, id(my_font), "State: %s", id(my_binary_sensor).state ? "ON" : "OFF"); .. _display-strftime: @@ -347,13 +347,8 @@ See Also .. toctree:: :maxdepth: 1 + :glob: - lcd_gpio - lcd_pcf8574 - max7219 - nextion - ssd1306_i2c - ssd1306_spi - waveshare_epaper + * .. disqus:: diff --git a/esphomeyaml/components/display/lcd_gpio.rst b/esphomeyaml/components/display/lcd_gpio.rst index 576adb1ef..2789abad1 100644 --- a/esphomeyaml/components/display/lcd_gpio.rst +++ b/esphomeyaml/components/display/lcd_gpio.rst @@ -80,11 +80,11 @@ by default which means the character at the top left. it.print(1, 1, "1"); // Let's write a sensor value (let's assume it's 42.1) - it.printf("%.1f", id(my_sensor).value); + it.printf("%.1f", id(my_sensor).state); // Result: "42.1" (the dot will appear on the "2" segment) // Print a right-padded sensor value with 0 digits after the decimal - it.printf("Sensor value: %8.0f", id(my_sensor).value); + it.printf("Sensor value: %8.0f", id(my_sensor).state); // Result: "Sensor value: 42" // Print the current time diff --git a/esphomeyaml/components/display/max7219.rst b/esphomeyaml/components/display/max7219.rst index 01dd39c92..2257e749d 100644 --- a/esphomeyaml/components/display/max7219.rst +++ b/esphomeyaml/components/display/max7219.rst @@ -86,13 +86,13 @@ segment of the previous position will be enabled. // Result: "01 " // Let's write a sensor value (let's assume it's 42.1) - it.printf(3, "%.1f", id(my_sensor).value); + it.printf(3, "%.1f", id(my_sensor).state); // Result: "01 42.1 " (the dot will appear on the "2" segment) // Overwrite the previous content with blank it.print(" "); // Print a right-padded sensor value with 0 digits after the decimal - it.printf("SENS%4.0f", id(my_sensor).value); + it.printf("SENS%4.0f", id(my_sensor).state); // Result: "SENS 42" // Print the current time diff --git a/esphomeyaml/components/display/nextion.rst b/esphomeyaml/components/display/nextion.rst index 0194501d2..52804e755 100644 --- a/esphomeyaml/components/display/nextion.rst +++ b/esphomeyaml/components/display/nextion.rst @@ -72,7 +72,7 @@ you can call to populate data on the display: it.set_component_text("textview", "Hello World!"); // set the text of a component with formatting - it.set_component_text("textview", "The uptime is: %.1f", id(uptime_sensor).value); + it.set_component_text("textview", "The uptime is: %.1f", id(uptime_sensor).state); Please see :ref:`display-printf` for a quick introduction into the ``printf`` formatting rules and diff --git a/esphomeyaml/components/fan/index.rst b/esphomeyaml/components/fan/index.rst index 12f3d51fa..5ac71282a 100644 --- a/esphomeyaml/components/fan/index.rst +++ b/esphomeyaml/components/fan/index.rst @@ -45,8 +45,7 @@ Toggles the ON/OFF state of the fan with the given ID when executed. on_...: then: - - fan.toggle: - id: fan_1 + - fan.toggle: fan_1 .. _fan-turn_off_action: @@ -59,8 +58,7 @@ Turns the fan with the given ID off when executed. on_...: then: - - fan.turn_off: - id: fan_1 + - fan.turn_off: fan_1 .. _fan-turn_on_action: @@ -93,8 +91,8 @@ Full Fan Index .. toctree:: :maxdepth: 1 + :glob: - binary.rst - speed.rst + * .. disqus:: diff --git a/esphomeyaml/components/light/index.rst b/esphomeyaml/components/light/index.rst index 2be3c6627..8ef979396 100644 --- a/esphomeyaml/components/light/index.rst +++ b/esphomeyaml/components/light/index.rst @@ -25,6 +25,16 @@ Configuration options: - **transition_length** (*Optional*, :ref:`config-time`, :ref:`templatable `): The length of the transition if the light supports it. +.. note:: + + This action can also be expressed in :ref:`lambdas `: + + .. code:: cpp + + auto call = id(light_1).toggle(); + // perform action: + call.perform(); + .. _light-turn_on_action: ``light.turn_on`` Action @@ -48,7 +58,7 @@ This action turns a light with the given ID on when executed. id: light_1 brightness: !lambda >- // output value must be in range 0 - 1.0 - return id(some_sensor).value / 100.0; + return id(some_sensor).state / 100.0; Configuration options: @@ -70,6 +80,21 @@ Configuration options: - **effect** (*Optional*, string, :ref:`templatable `): If set, will attempt to start an effect with the given name. +.. note:: + + This action can also be expressed in :ref:`lambdas `: + + .. code:: cpp + + auto call = id(light_1).turn_on(); + // set parameters (optional) + call.set_transition_length(1000); // in ms + call.set_brightness(1.0); // 1.0 is full brightness + call.set_rgb(1.0, 1.0, 1.0); // color, 1.0 is fully lit + call.set_effect("The Effect"); + // perform action: + call.perform(); + .. _light-turn_off_action: ``light.turn_off`` Action @@ -90,7 +115,17 @@ Configuration options: - **transition_length** (*Optional*, :ref:`config-time`, :ref:`templatable `): The length of the transition if the light supports it. -This action turns a switch with the given ID off when executed. +.. note:: + + This action can also be expressed in :ref:`lambdas `: + + .. code:: cpp + + auto call = id(light_1).turn_off(); + // set parameters (optional) + call.set_transition_length(1000); // in ms + // perform action: + call.perform(); .. _light-effects: @@ -462,14 +497,8 @@ See Also .. toctree:: :maxdepth: 1 + :glob: - binary.rst - cwww.rst - monochromatic.rst - rgb.rst - rgbw.rst - rgbww.rst - fastled_clockless.rst - fastled_spi.rst + * .. disqus:: diff --git a/esphomeyaml/components/mqtt.rst b/esphomeyaml/components/mqtt.rst index 810d3e85f..765ed248c 100644 --- a/esphomeyaml/components/mqtt.rst +++ b/esphomeyaml/components/mqtt.rst @@ -384,10 +384,10 @@ Publish an MQTT message on a topic using this action in automations. # Templated: - mqtt.publish: topic: !lambda >- - if (id(reed_switch).value) return "topic1"; + if (id(reed_switch).state) return "topic1"; else return "topic2"; payload: !lambda >- - return id(reed_switch).value ? "YES" : "NO"; + return id(reed_switch).state ? "YES" : "NO"; Configuration options: diff --git a/esphomeyaml/components/output/index.rst b/esphomeyaml/components/output/index.rst index 94aa65444..82f18763c 100644 --- a/esphomeyaml/components/output/index.rst +++ b/esphomeyaml/components/output/index.rst @@ -52,6 +52,14 @@ This action turns the output with the given ID on when executed. then: - output.turn_on: relay_1 +.. note:: + + This action can also be expressed in :ref:`lambdas `: + + .. code:: cpp + + id(relay_1).turn_on(); + .. _output-turn_off_action: ``output.turn_off`` Action @@ -65,6 +73,14 @@ This action turns the output with the given ID off when executed. then: - output.turn_off: relay_1 +.. note:: + + This action can also be expressed in :ref:`lambdas `: + + .. code:: cpp + + id(relay_1).turn_off(); + .. _output-set_level_action: ``output.set_level`` Action @@ -81,6 +97,15 @@ works with floating point outputs like ESP8266 PWM or LEDC. id: output_1 level: 50% +.. note:: + + This action can also be expressed in :ref:`lambdas `: + + .. code:: cpp + + // range is 0.0 (off) to 1.0 (on) + id(relay_1).set_level(0.5); + Full Output Index ----------------- @@ -96,10 +121,8 @@ Full Output Index .. toctree:: :maxdepth: 1 + :glob: - esp8266_pwm.rst - gpio.rst - ledc.rst - pca9685.rst + * .. disqus:: diff --git a/esphomeyaml/components/sensor/ads1115.rst b/esphomeyaml/components/sensor/ads1115.rst index 7a7f73989..e8cac52a3 100644 --- a/esphomeyaml/components/sensor/ads1115.rst +++ b/esphomeyaml/components/sensor/ads1115.rst @@ -38,8 +38,8 @@ Configuration variables: - **name** (**Required**, string): The name for this sensor. - **ads1115_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the :doc:`ADS1115 Hub ` you want to use this sensor. -- **update_interval** (*Optional*, :ref:`config-time`): The interval - to check the sensor. Defaults to ``15s``. See :ref:`sensor-default_filter`. +- **update_interval** (*Optional*, :ref:`config-time`): The interval + to check the sensor. Defaults to ``15s``. See :ref:`sensor-default_filter`. - **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation. Multiplexer And Gain diff --git a/esphomeyaml/components/sensor/bmp085.rst b/esphomeyaml/components/sensor/bmp085.rst index 24c6bb6da..10109b4e6 100644 --- a/esphomeyaml/components/sensor/bmp085.rst +++ b/esphomeyaml/components/sensor/bmp085.rst @@ -13,7 +13,7 @@ your configuration for this sensor to work. :align: center :width: 50.0% - BMP180 Temperature & Pressure Sensor.. + BMP180 Temperature & Pressure Sensor. .. figure:: images/temperature-pressure.png :align: center @@ -31,7 +31,7 @@ your configuration for this sensor to work. update_interval: 15s Configuration variables: -~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------ - **temperature** (**Required**): The information for the temperature sensor. @@ -52,7 +52,7 @@ Configuration variables: sensor. Defaults to ``15s``. See :ref:`sensor-default_filter`. See Also -^^^^^^^^ +-------- - :ref:`sensor-filters` - :doc:`bme280` diff --git a/esphomeyaml/components/sensor/custom.rst b/esphomeyaml/components/sensor/custom.rst index 1ef266200..18ceb613d 100644 --- a/esphomeyaml/components/sensor/custom.rst +++ b/esphomeyaml/components/sensor/custom.rst @@ -138,7 +138,7 @@ Let's also now make our sensor actually *output* values (42 for now): // class CustomSensor ... // ... previous code void update() override { - push_new_value(42.0); // 42°C + publish_state(42.0); // 42°C } std::string unit_of_measurement() override { return "°C"; } @@ -255,7 +255,7 @@ Then update our sensor for BMP180 support: void update() override { int pressure = bmp.readPressure(); // in Pa, or 1/100 hPa - push_new_value(pressure / 100.0); // convert to hPa + publish_state(pressure / 100.0); // convert to hPa } std::string unit_of_measurement() override { return "hPa"; } @@ -330,10 +330,10 @@ Let's look at what that could look like in code: void update() override { // This is the actual sensor reading logic. int pressure = bmp.readPressure(); - pressure_sensor->push_new_value(pressure / 100.0); + pressure_sensor->publish_state(pressure / 100.0); float temperature = bmp.readTemperature(); - temperature_sensor->push_new_value(temperature); + temperature_sensor->publish_state(temperature); } }; diff --git a/esphomeyaml/components/sensor/duty_cycle.rst b/esphomeyaml/components/sensor/duty_cycle.rst index 51f138b82..fe3e8367b 100644 --- a/esphomeyaml/components/sensor/duty_cycle.rst +++ b/esphomeyaml/components/sensor/duty_cycle.rst @@ -29,4 +29,11 @@ Configuration variables: - **id** (*Optional*, :ref:`config-id`): Set the ID of this sensor for use in lambdas. - All other options from :ref:`Sensor ` and :ref:`MQTT Component `. +See Also +-------- + +- :ref:`sensor-filters` +- :doc:`API Reference ` +- `Edit this page on GitHub `__ + .. disqus:: diff --git a/esphomeyaml/components/sensor/index.rst b/esphomeyaml/components/sensor/index.rst index b5edb84b8..382f371c6 100644 --- a/esphomeyaml/components/sensor/index.rst +++ b/esphomeyaml/components/sensor/index.rst @@ -195,15 +195,17 @@ directly, put an empty ``filters:`` block in your configuration: .. code:: yaml + # Example configuration entry sensor: - - platform: ... - filters: + - platform: adc + # ... + filters: [] Sensor Automation ----------------- You can access the most recent state of the sensor in :ref:`lambdas ` using -``id(sensor_id).value`` and the most recent raw state using ``id(sensor_id).raw_value``. +``id(sensor_id).state`` and the most recent raw state using ``id(sensor_id).raw_value``. .. _sensor-on_value: @@ -287,29 +289,29 @@ lambda calls From :ref:`lambdas `, you can call several methods on all sensors to do some advanced stuff (see the full :doc:`API Reference ` for more info). -- ``push_new_value()``: Manually cause the sensor to push out a value. It will then +- ``publish_state()``: Manually cause the sensor to push out a value. It will then be processed by the sensor filters, and once done be published to MQTT. .. code:: yaml // Within lambda, push a value of 42.0 - id(my_sensor).push_new_value(42.0); + id(my_sensor).publish_state(42.0); -- ``value``: Retrieve the current value of the sensor that has passed through all sensor filters. +- ``.state``: Retrieve the current value of the sensor that has passed through all sensor filters. Is ``NAN`` if no value has gotten through all filters yet. .. code:: yaml // For example, create a custom log message when a value is received: - ESP_LOGI("main", "Value of my sensor: %f", id(my_sensor).value); + ESP_LOGI("main", "Value of my sensor: %f", id(my_sensor).state); -- ``raw_value``: Retrieve the current value of the sensor that has not passed through any filters +- ``raw_state``: Retrieve the current value of the sensor that has not passed through any filters Is ``NAN`` if no value if no value has been pushed by the sensor itself yet. .. code:: yaml // For example, create a custom log message when a value is received: - ESP_LOGI("main", "Raw Value of my sensor: %f", id(my_sensor).value); + ESP_LOGI("main", "Raw Value of my sensor: %f", id(my_sensor).raw_state); See Also @@ -320,45 +322,8 @@ See Also .. toctree:: :maxdepth: 1 + :glob: - adc - ads1115 - bh1750 - ble_rssi - bme280 - bme680 - bmp085 - bmp280 - cse7766 - custom - dallas - dht - dht12 - duty_cycle - esp32_hall - hdc1080 - hlw8012 - hmc5883l - htu21d - hx711 - ina219 - ina3221 - max6675 - mhz19 - mpu6050 - mqtt_subscribe - ms5611 - pulse_counter - pmsx003 - rotary_encoder - sht3xd - tcs34725 - template - tsl2561 - ultrasonic - uptime - wifi_signal - xiaomi_miflora - xiaomi_mijia + * .. disqus:: diff --git a/esphomeyaml/components/sensor/template.rst b/esphomeyaml/components/sensor/template.rst index 00299a17a..a27e5964b 100644 --- a/esphomeyaml/components/sensor/template.rst +++ b/esphomeyaml/components/sensor/template.rst @@ -11,7 +11,7 @@ using :ref:`lambdas `. - platform: template name: "Template Sensor" lambda: >- - if (id(some_binary_sensor).value) { + if (id(some_binary_sensor).state) { return 42.0; } else { return 0.0; diff --git a/esphomeyaml/components/switch/index.rst b/esphomeyaml/components/switch/index.rst index 7ca9ec63d..fc5ad7b68 100644 --- a/esphomeyaml/components/switch/index.rst +++ b/esphomeyaml/components/switch/index.rst @@ -88,7 +88,7 @@ advanced stuff (see the full :doc:`API Reference ` for more in .. code:: yaml // Within lambda, get the switch state and conditionally do something - if (id(my_switch).value) { + if (id(my_switch).state) { // Switch is ON, do something here } else { // Switch is OFF, do something else here @@ -113,13 +113,8 @@ See Also .. toctree:: :maxdepth: 1 + :glob: - gpio - output - remote_transmitter - restart - shutdown - template - uart + * .. disqus:: diff --git a/esphomeyaml/components/switch/template.rst b/esphomeyaml/components/switch/template.rst index 6822e0527..822adc207 100644 --- a/esphomeyaml/components/switch/template.rst +++ b/esphomeyaml/components/switch/template.rst @@ -12,7 +12,7 @@ as a switch and can be controlled through the frontend. - platform: template name: "Template Switch" lambda: >- - if (id(some_binary_sensor).value) { + if (id(some_binary_sensor).state) { return true; } else { return false; diff --git a/esphomeyaml/cookbook/dual-r2-cover.rst b/esphomeyaml/cookbook/dual-r2-cover.rst index 6a0e13dee..311743690 100644 --- a/esphomeyaml/cookbook/dual-r2-cover.rst +++ b/esphomeyaml/cookbook/dual-r2-cover.rst @@ -48,29 +48,21 @@ Of the four main components (button sensor, 2 relays switches and the cover), on # logic for cycling through movements: open->stop->close->stop->... - lambda: | if (id(cover).state == cover::COVER_OPEN) { - if (id(open).value){ + if (id(open).state){ // cover is in opening movement, stop it id(cover).stop(); } else { // cover has finished opening, close it id(cover).close(); } - } else if (id(cover).state == cover::COVER_CLOSED) { - if (id(close).value){ + } else { + if (id(close).state){ // cover is in closing movement, stop it id(cover).stop(); } else { // cover has finished closing, open it id(cover).open(); } - } else { - // state of cover is not known - if (id(open).value || id(close).value){ - // cover is either opening or closing, stop it - id(cover).stop(); - } else { - id(cover).open(); - } } switch: diff --git a/esphomeyaml/cookbook/index.rst b/esphomeyaml/cookbook/index.rst index b524cf1bc..587193c93 100644 --- a/esphomeyaml/cookbook/index.rst +++ b/esphomeyaml/cookbook/index.rst @@ -2,11 +2,6 @@ Cookbook ======== .. toctree:: + :glob: - garage-door - pir - bruh - temt6000 - relay - power_meter - dual-r2-cover + * diff --git a/esphomeyaml/devices/index.rst b/esphomeyaml/devices/index.rst index 56c96ec59..587193c93 100644 --- a/esphomeyaml/devices/index.rst +++ b/esphomeyaml/devices/index.rst @@ -2,12 +2,6 @@ Cookbook ======== .. toctree:: + :glob: - esp32 - esp8266 - nodemcu_esp32 - nodemcu_esp8266 - sonoff - sonoff_4ch - sonoff_s20 - sonoff_basic + * diff --git a/esphomeyaml/guides/automations.rst b/esphomeyaml/guides/automations.rst index bc3500e55..70b2f4b37 100644 --- a/esphomeyaml/guides/automations.rst +++ b/esphomeyaml/guides/automations.rst @@ -182,7 +182,7 @@ first: - platform: template name: Living Room Cover lambda: !lambda >- - if (id(top_end_stop).value) { + if (id(top_end_stop).state) { return cover::COVER_OPEN; } else { return cover::COVER_CLOSED; @@ -213,7 +213,7 @@ we're either *returning* ``cover::COVER_OPEN`` or ``cover::COVER_CLOSED`` to ind Finally, ``id(...)`` is a helper function that makes esphomeyaml fetch an object with the supplied ID (which you defined somewhere else, like ``top_end_stop```) and let's you call any of esphomelib's many APIs directly. For example, here -we're retrieving the current state of the end stop using ``.value`` and using it to construct our cover state. +we're retrieving the current state of the end stop using ``.state`` and using it to construct our cover state. .. note:: @@ -234,7 +234,7 @@ we're retrieving the current state of the end stop using ``.value`` and using it ESP_LOGV("main", "This is a gray verbose message"); // doesn't show up with the default log level. // Use printf-style syntax (http://www.cplusplus.com/reference/cstdio/printf/) - ESP_LOGD("main", "The temperature inside is %.1f", id(outside_temperature_sensor).value); + ESP_LOGD("main", "The temperature inside is %.1f", id(outside_temperature_sensor).state); .. tip:: @@ -269,7 +269,7 @@ if you have a light and want to set it to a pre-defined color when a button is p blue: !lambda >- # The sensor outputs values from 0 to 100. The blue # part of the light color will be determined by the sensor value. - return id(some_sensor).value / 100.0; + return id(some_sensor).state / 100.0; Every parameter in actions that has the label "templatable" in the docs can be templated like above, using all of the usual lambda syntax. @@ -337,7 +337,7 @@ time period. - switch.turn_off: id: relay_1 # Templated, waits for 1s (1000ms) only if a reed switch is active - - delay: !lambda "if (id(reed_switch).value) return 1000; else return 0;" + - delay: !lambda "if (id(reed_switch).state) return 1000; else return 0;" .. note:: @@ -376,7 +376,7 @@ turns on a light for 5 seconds. Otherwise, the light is turned off immediately. on_...: then: - if: - lambda: 'return id(some_sensor).value < 30;' + lambda: 'return id(some_sensor).state < 30;' then: - lambda: 'ESP_LOGD("main", "The sensor value is below 30!"); - light.turn_on: my_light diff --git a/esphomeyaml/guides/index.rst b/esphomeyaml/guides/index.rst index 01a8ea924..1dd6ba9d7 100644 --- a/esphomeyaml/guides/index.rst +++ b/esphomeyaml/guides/index.rst @@ -2,14 +2,6 @@ Guides ====== .. toctree:: + :glob: - automations - configuration-types - faq - getting_started_command_line - getting_started_hassio - migrate_espeasy - migrate_espurna - migrate_sonoff_tasmota - contributing - changelog + *