From a8024228fb77acf18ca5898ee290467f9ab99ea3 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Thu, 28 Oct 2021 12:06:28 +1100 Subject: [PATCH 01/18] Add suggestion for reducing DTIM to improve WiFi This change improved my use case from ~50% packet loss to roughly zero and allows OTA updates to work reliably. --- guides/faq.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/guides/faq.rst b/guides/faq.rst index 5b3e04aa8..6ef91ea43 100644 --- a/guides/faq.rst +++ b/guides/faq.rst @@ -240,6 +240,11 @@ Some steps that can help with the issue: the log viewer on the web dashboard. In production, you will likely only have a single connection from Home Assistant, making this less of an issue. But beware that attaching a log viewer might have impact. +- Reducing the Delivery Traffic Indication Message (DTIM) interval in the WiFi access point may help + improve the ESP's WiFi reliability and responsiveness. This will cause WiFi devices in power + save mode, such as the ESP, to be woken up more frequently. This may improve things for the ESP, + although it may also increase power (and possibly battery) usage of other devices also using power + save mode. Docker Reference ---------------- From 87cc80b5828c3c9015e8a041b4b972f98927b095 Mon Sep 17 00:00:00 2001 From: Rebbe Pod <66928914+RebbePod@users.noreply.github.com> Date: Mon, 13 Dec 2021 00:25:17 -0500 Subject: [PATCH 02/18] Add See Also Base Text Sensor Perhaps also remove the reference to config right above --- components/text_sensor/custom.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/components/text_sensor/custom.rst b/components/text_sensor/custom.rst index b695bc3fb..e6d463dcf 100644 --- a/components/text_sensor/custom.rst +++ b/components/text_sensor/custom.rst @@ -63,5 +63,6 @@ Configuration variables: See Also -------- +- :doc:`/components/text_sensor/index` - :apiclass:`API Reference ` - :ghedit:`Edit` From 3df85517335aab73655a2ec73d20d890ba4f2d23 Mon Sep 17 00:00:00 2001 From: Rebbe Pod <66928914+RebbePod@users.noreply.github.com> Date: Mon, 13 Dec 2021 00:26:36 -0500 Subject: [PATCH 03/18] Add See Also Base Text Sensor --- components/text_sensor/template.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/components/text_sensor/template.rst b/components/text_sensor/template.rst index 60994ed8c..ac65bbd93 100644 --- a/components/text_sensor/template.rst +++ b/components/text_sensor/template.rst @@ -81,6 +81,7 @@ Configuration options: See Also -------- +- :doc:`/components/text_sensor/index` - :ref:`automation` - :apiref:`template/text_sensor/template_text_sensor.h` - :ghedit:`Edit` From a71bf7dd6d7e65ed507a9bb9344496345dc57f46 Mon Sep 17 00:00:00 2001 From: ludrao Date: Fri, 24 Dec 2021 00:04:11 +0100 Subject: [PATCH 04/18] Added a DIY sample configuration The linked repo also contain a quick description on how to transform a noname Tuya switch into a device that actually run ESPHome --- guides/diy.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/guides/diy.rst b/guides/diy.rst index 45d99603c..9d4390dc6 100644 --- a/guides/diy.rst +++ b/guides/diy.rst @@ -110,3 +110,4 @@ Sample Configurations - `Universal menu system for devices with rotary encoder with push and SSD1306 I2C display `__ by :ghuser:`mikosoft83` - `Show heart rate sensor values sent over Bluetooth Low Energy on a display `__ by :ghuser:`koenvervloesem` - `ESPHome floor heating controller (proportional valves) `__ by :ghuser:`nliaudat` +- `ESPHome Curtain/Cover/Shutter Switch from a noname Tuya switch `__ by :ghuser:`ludrao` From 5cfa8db745b9e44723b56d80b8b4f35973d4ce77 Mon Sep 17 00:00:00 2001 From: ludrao Date: Sun, 26 Dec 2021 13:42:18 +0100 Subject: [PATCH 05/18] Added a second config sample --- guides/diy.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/guides/diy.rst b/guides/diy.rst index 9d4390dc6..b29f87afa 100644 --- a/guides/diy.rst +++ b/guides/diy.rst @@ -110,4 +110,5 @@ Sample Configurations - `Universal menu system for devices with rotary encoder with push and SSD1306 I2C display `__ by :ghuser:`mikosoft83` - `Show heart rate sensor values sent over Bluetooth Low Energy on a display `__ by :ghuser:`koenvervloesem` - `ESPHome floor heating controller (proportional valves) `__ by :ghuser:`nliaudat` -- `ESPHome Curtain/Cover/Shutter Switch from a noname Tuya switch `__ by :ghuser:`ludrao` +- `ESPHome Curtain/Cover/Shutter Switch from a noname Tuya switch `__ by :ghuser:`ludrao` +- `ESPHome Free your Thomson Guardian gate controller `__ by :ghuser:`ludrao` From e5df907f48020710ab66aa878eef91753f8dde0d Mon Sep 17 00:00:00 2001 From: aquaticus <1891400+aquaticus@users.noreply.github.com> Date: Sun, 26 Dec 2021 20:41:59 +0100 Subject: [PATCH 06/18] Update rotary encoder doc Added extra options example for encoder pin configuration. --- components/sensor/rotary_encoder.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/sensor/rotary_encoder.rst b/components/sensor/rotary_encoder.rst index d2a4f96ee..8a42baf16 100644 --- a/components/sensor/rotary_encoder.rst +++ b/components/sensor/rotary_encoder.rst @@ -36,6 +36,18 @@ outputs go in the wrong direction, you can just swap these two pins. pin_a: D1 pin_b: D2 +To modify additional parameters of pins like active state or pull-ups, you may add extra options. + +.. code-block:: yaml + + # Example of advanced pin configuration + pin_a: + number: D5 + inverted: true + mode: + input: true + pullup: true + Configuration variables: ------------------------ From 938a7cfa3ed970e649edd437971f2233bb574697 Mon Sep 17 00:00:00 2001 From: Gonzalo Paniagua Javier Date: Wed, 29 Dec 2021 00:50:13 -0500 Subject: [PATCH 07/18] Adds missing update_interval config variable --- components/display/st7735.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/components/display/st7735.rst b/components/display/st7735.rst index 805871a37..d42a9550d 100644 --- a/components/display/st7735.rst +++ b/components/display/st7735.rst @@ -63,6 +63,7 @@ Configuration variables: - **invert_colors** (*Optional*, boolean): Invert LCD colors. Default is false. - **eight_bit_color** (*Optional*, boolean): 8bit mode. Default is false. This saves 50% of the buffer required for the display. - **reset_pin** (*Optional*, :ref:`Pin Schema `): The RESET pin. +- **update_interval** (*Optional*, :ref:`config-time`): time between display updates. Memory notes: ************* From 163d6269ea2931861fd31fc494fe12b6604b914f Mon Sep 17 00:00:00 2001 From: Gonzalo Paniagua Javier Date: Wed, 29 Dec 2021 01:04:22 -0500 Subject: [PATCH 08/18] Update st7735.rst --- components/display/st7735.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/display/st7735.rst b/components/display/st7735.rst index d42a9550d..f29b34161 100644 --- a/components/display/st7735.rst +++ b/components/display/st7735.rst @@ -63,7 +63,7 @@ Configuration variables: - **invert_colors** (*Optional*, boolean): Invert LCD colors. Default is false. - **eight_bit_color** (*Optional*, boolean): 8bit mode. Default is false. This saves 50% of the buffer required for the display. - **reset_pin** (*Optional*, :ref:`Pin Schema `): The RESET pin. -- **update_interval** (*Optional*, :ref:`config-time`): time between display updates. +- **update_interval** (*Optional*, :ref:`config-time`): time between display updates. Default is 1s. Memory notes: ************* From bc65ab57702d1a90e1460db79c8bf70fc1e710d0 Mon Sep 17 00:00:00 2001 From: spacemanspiff2007 <10754716+spacemanspiff2007@users.noreply.github.com> Date: Tue, 4 Jan 2022 19:44:11 +0100 Subject: [PATCH 09/18] Clearified heartbeat --- components/sensor/index.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/sensor/index.rst b/components/sensor/index.rst index 595e3c54d..3ac3be459 100644 --- a/components/sensor/index.rst +++ b/components/sensor/index.rst @@ -389,7 +389,10 @@ In comparison to the ``throttle`` filter it won't discard any values. In compari ``heartbeat`` ************* -Send the last value that this sensor in the specified time interval. +Send the value periodically with the specified time interval. +If the sensor value changes during the interval the interval will not reset. +The last value of the sensor will be sent. + So a value of ``10s`` will cause the filter to output values every 10s regardless of the input values. From 1253896e6892592e2780713cb98804d9360e459a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ab=C3=ADlio=20Costa?= Date: Wed, 5 Jan 2022 00:01:53 +0000 Subject: [PATCH 10/18] Add docs to pzemac on how to change its address Most tutorials or suggestions online point to using either the official PZEM tool (windows only) or Tasmota. With the suggested snipped it is possible to do it using ESPHome. --- components/sensor/pzemac.rst | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/components/sensor/pzemac.rst b/components/sensor/pzemac.rst index 90f8a8896..a5430c498 100644 --- a/components/sensor/pzemac.rst +++ b/components/sensor/pzemac.rst @@ -83,6 +83,63 @@ Configuration variables: the same UART bus. You will need to set the address of each device manually. Defaults to ``1``. - **modbus_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the Modbus hub. + +Changing the address of a PZEM-004T: +------------------------ + +You can use the following configuration to change the address of a sensor. +You must set the ``address`` of the ``modbus_controller`` to the current address, and ``new_address`` of the ``on_boot`` lambda to the new one. + +.. warning:: + + This should be used only once! After changing the address, this code should be removed from the ESP before using the actual sensor code. + +.. code-block:: yaml + + esphome: + ... + on_boot: + ## configure controller settings at setup + ## make sure priority is lower than setup_priority of modbus_controller + priority: -100 + then: + - lambda: |- + auto new_address = 0x03; + + if(new_address < 0x01 || new_address > 0xF7) // sanity check + { + ESP_LOGE("ModbusLambda", "Address needs to be between 0x01 and 0xF7"); + return; + } + + esphome::modbus_controller::ModbusController *controller = id(epever); + auto set_addr_cmd = esphome::modbus_controller::ModbusCommandItem::create_write_single_command( + controller, 0x0002, new_address); + + delay(200) ; + controller->queue_command(set_addr_cmd); + ESP_LOGI("ModbusLambda", "PZEM Addr set"); + + modbus: + send_wait_time: 200ms + id: mod_bus_epever + + modbus_controller: + - id: epever + ## the current device addr + address: 0x1 + modbus_id: mod_bus_epever + command_throttle: 0ms + setup_priority: -10 + update_interval: 30s + + uart: + rx_pin: GPIO16 + tx_pin: GPIO17 + baud_rate: 9600 + stop_bits: 2 + + See Also -------- From 051c18e2b49913f393074313c3fb8f9765f335d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ab=C3=ADlio=20Costa?= Date: Wed, 5 Jan 2022 00:07:21 +0000 Subject: [PATCH 11/18] Use a better id --- components/sensor/pzemac.rst | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/components/sensor/pzemac.rst b/components/sensor/pzemac.rst index a5430c498..2250461f3 100644 --- a/components/sensor/pzemac.rst +++ b/components/sensor/pzemac.rst @@ -112,7 +112,7 @@ You must set the ``address`` of the ``modbus_controller`` to the current address return; } - esphome::modbus_controller::ModbusController *controller = id(epever); + esphome::modbus_controller::ModbusController *controller = id(pzem); auto set_addr_cmd = esphome::modbus_controller::ModbusCommandItem::create_write_single_command( controller, 0x0002, new_address); @@ -122,23 +122,17 @@ You must set the ``address`` of the ``modbus_controller`` to the current address modbus: send_wait_time: 200ms - id: mod_bus_epever + id: mod_bus_pzem modbus_controller: - - id: epever + - id: pzem ## the current device addr address: 0x1 - modbus_id: mod_bus_epever + modbus_id: mod_bus_pzem command_throttle: 0ms setup_priority: -10 update_interval: 30s - uart: - rx_pin: GPIO16 - tx_pin: GPIO17 - baud_rate: 9600 - stop_bits: 2 - See Also -------- From e4ce942762854c902b8c364a436dbede97918ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ab=C3=ADlio=20Costa?= Date: Wed, 5 Jan 2022 00:09:45 +0000 Subject: [PATCH 12/18] Fix underline lint --- components/sensor/pzemac.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/sensor/pzemac.rst b/components/sensor/pzemac.rst index 2250461f3..ad7351162 100644 --- a/components/sensor/pzemac.rst +++ b/components/sensor/pzemac.rst @@ -85,7 +85,7 @@ Configuration variables: Changing the address of a PZEM-004T: ------------------------- +------------------------------------ You can use the following configuration to change the address of a sensor. You must set the ``address`` of the ``modbus_controller`` to the current address, and ``new_address`` of the ``on_boot`` lambda to the new one. From 591ce9786d53ded685f35952fa4e8ccc31f0062a Mon Sep 17 00:00:00 2001 From: Stefan Gmeiner Date: Wed, 5 Jan 2022 21:41:29 +0100 Subject: [PATCH 13/18] Fix options and use smaller/better example. --- components/text_sensor/modbus_controller.rst | 75 ++++++-------------- 1 file changed, 21 insertions(+), 54 deletions(-) diff --git a/components/text_sensor/modbus_controller.rst b/components/text_sensor/modbus_controller.rst index e5aada311..7b08315d1 100644 --- a/components/text_sensor/modbus_controller.rst +++ b/components/text_sensor/modbus_controller.rst @@ -18,7 +18,6 @@ Configuration variables: - holding: Holding Registers - Holding registers are the most universal 16-bit register. Read and Write access - read: Read Input Registers - registers are 16-bit registers used for input, and may only be read - **address**: (**Required**, int): start address of the first register in a range -- **bitmask**: (*Optional*) some values are packed in a response. The bitmask can be used to extract a value from the response. For example, if the high byte value register 0x9013 contains the minute value of the current time. To only exctract this value use bitmask: 0xFF00. The result will be automatically right shifted by the number of 0 before the first 1 in the bitmask. For 0xFF00 (0b1111111100000000) the result is shifted 8 posistions. More than one sensor can use the same address/offset if the bitmask is different. - **skip_updates**: (*Optional*, int): By default all sensors of of a modbus_controller are updated together. For data points that don't change very frequently updates can be skipped. A value of 5 would only update this sensor range in every 5th update cycle - **register_count**: (*Optional*): The number of registers this data point spans. Default is 1 - **response_size**: (**Required**):response number of bytes of the response @@ -34,11 +33,11 @@ Configuration variables: Lambda to be evaluated every update interval to get the new value of the sensor - **offset**: (*Optional*, int): not required in most cases offset from start address in bytes. If more than one register is read a modbus read registers command this value is used to find the start of this datapoint relative to start address. The component calculates the size of the range based on offset and size of the value type - +- All options from :ref:`Text Sensor `. Parameters passed into the lambda -- **x** (std:string): The parsed float value of the modbus data +- **x** (std:string): The parsed value of the modbus data according to **raw_encode** - **data** (std::vectoroffset]`` to get the first response byte for your sensor. @@ -46,9 +45,8 @@ Parameters passed into the lambda Possible return values for the lambda: - - ``return ;`` the new value for the sensor. - - ``return NAN;`` if the state should be considered invalid to indicate an error (advanced). - - ``return {};`` if you don't want to publish a new state (advanced). + - ``return ;`` the new value for the sensor. + - ``return {};`` uses the parsed value for the state (same as ``return x;``). @@ -58,55 +56,24 @@ Possible return values for the lambda: .. code-block:: yaml text_sensor: - - platform: template - name: "RTC Time Sensor" - id: template_rtc - - - platform: modbus_controller - modbus_controller_id: traceranx - name: "rtc clock test" - id: rtc_clock_test - internal: true + - platform: modbus_controller + modbus_controller_id: modbus_device + id: reg_1002_text + bitmask: 0 register_type: holding - address: 0x9013 - register_count: 3 - hex_encode: true - response_size: 6 - on_value: - then: - - lambda: |- - ESP_LOGV("main", "decoding rtc hex encoded raw data: %s", x.c_str()); - uint8_t h=0,m=0,s=0,d=0,month_=0,y = 0 ; - m = esphome::modbus_controller::byte_from_hex_str(x,0); - s = esphome::modbus_controller::byte_from_hex_str(x,1); - d = esphome::modbus_controller::byte_from_hex_str(x,2); - h = esphome::modbus_controller::byte_from_hex_str(x,3); - y = esphome::modbus_controller::byte_from_hex_str(x,4); - month_ = esphome::modbus_controller::byte_from_hex_str(x,5); - // Now check if the rtc time of the controller is ok and correct it - time_t now = ::time(nullptr); - struct tm *time_info = ::localtime(&now); - int seconds = time_info->tm_sec; - int minutes = time_info->tm_min; - int hour = time_info->tm_hour; - int day = time_info->tm_mday; - int month = time_info->tm_mon + 1; - int year = time_info->tm_year - 2000; - // correct time if needed (ignore seconds) - if (d != day || month_ != month || y != year || h != hour || m != minutes) { - // create the payload - std::vector rtc_data = {uint16_t((minutes << 8) | seconds), uint16_t((day << 8) | hour), - uint16_t((year << 8) | month)}; - // Create a modbus command item with the time information as the payload - esphome::modbus_controller::ModbusCommandItem set_rtc_command = esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(traceranx, 0x9013, 3, rtc_data); - // Submit the command to the send queue - traceranx->queue_command(set_rtc_command); - ESP_LOGI("ModbusLambda", "EPSOLAR RTC set to %02d:%02d:%02d %02d.%02d.%04d", hour, minutes, seconds, day, month, year + 2000); - } - char buffer[20]; - // format time as YYYY:mm:dd hh:mm:ss - sprintf(buffer,"%04d:%02d:%02d %02d:%02d:%02d",y+2000,month_,d,h,m,s); - id(template_rtc).publish_state(buffer); + address: 1002 + raw_encode: HEXBYTES + name: Register 1002 (Text) + lambda: |- + uint16_t value = modbus_controller::word_from_hex_str(x, 0); + switch (value) { + case 1: return std::string("ready"); + case 2: return std::string("EV is present"); + case 3: return std::string("charging"); + case 4: return std::string("charging with ventilation"); + default: return std::string("Unknown"); + } + return x; See Also -------- From ce9bef8a6580d895f840510274f829c377ce2162 Mon Sep 17 00:00:00 2001 From: Stefan Gmeiner Date: Wed, 5 Jan 2022 21:52:53 +0100 Subject: [PATCH 14/18] Typos. --- components/text_sensor/modbus_controller.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/text_sensor/modbus_controller.rst b/components/text_sensor/modbus_controller.rst index 7b08315d1..f824a1a2e 100644 --- a/components/text_sensor/modbus_controller.rst +++ b/components/text_sensor/modbus_controller.rst @@ -20,8 +20,8 @@ Configuration variables: - **address**: (**Required**, int): start address of the first register in a range - **skip_updates**: (*Optional*, int): By default all sensors of of a modbus_controller are updated together. For data points that don't change very frequently updates can be skipped. A value of 5 would only update this sensor range in every 5th update cycle - **register_count**: (*Optional*): The number of registers this data point spans. Default is 1 -- **response_size**: (**Required**):response number of bytes of the response -- **raw_encode**: (*Optional*, enum) If the response is binary it can't be published directly. Since a text sensor only publishes strings the binary data can encoded +- **response_size**: (**Required**): Number of bytes of the response +- **raw_encode**: (*Optional*, enum) If the response is binary it can't be published directly. Since a text sensor only publishes strings the binary data can be encoded - ``NONE``: Don't encode data. - ``HEXBYTES``: 2 byte hex string. 0x2011 will be sent as "2011". - ``COMMA``: Byte values as integers, delimited by a coma. 0x2011 will be sent as "32,17" @@ -30,7 +30,7 @@ Configuration variables: custom data must contain all required bytes including the modbus device address. The crc is automatically calculated and appended to the command. See :ref:`modbus_custom_data` how to use ``custom_command`` - **lambda** (*Optional*, :ref:`lambda `): - Lambda to be evaluated every update interval to get the new value of the sensor + Lambda to be evaluated every update interval to get the new value of the sensor. It is called after the encoding according to **raw_encode**. - **offset**: (*Optional*, int): not required in most cases offset from start address in bytes. If more than one register is read a modbus read registers command this value is used to find the start of this datapoint relative to start address. The component calculates the size of the range based on offset and size of the value type - All options from :ref:`Text Sensor `. From c5e5e68c744eb1c2e0daa3c709a05134cdb41d36 Mon Sep 17 00:00:00 2001 From: Oxan van Leeuwen Date: Mon, 10 Jan 2022 13:57:26 +0100 Subject: [PATCH 15/18] Update components/display/st7735.rst --- components/display/st7735.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/display/st7735.rst b/components/display/st7735.rst index f29b34161..9e2f75eb7 100644 --- a/components/display/st7735.rst +++ b/components/display/st7735.rst @@ -63,7 +63,7 @@ Configuration variables: - **invert_colors** (*Optional*, boolean): Invert LCD colors. Default is false. - **eight_bit_color** (*Optional*, boolean): 8bit mode. Default is false. This saves 50% of the buffer required for the display. - **reset_pin** (*Optional*, :ref:`Pin Schema `): The RESET pin. -- **update_interval** (*Optional*, :ref:`config-time`): time between display updates. Default is 1s. +- **update_interval** (*Optional*, :ref:`config-time`): Time between display updates. Default is 1s. Memory notes: ************* From dcca9d3be1fc67796139264b238c43e0cd0805c4 Mon Sep 17 00:00:00 2001 From: DAVe3283 Date: Wed, 12 Jan 2022 11:08:51 -0700 Subject: [PATCH 16/18] Fix MAX31856 image The wrong image was selected, likely due to a simple typo. --- components/sensor/max31856.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/sensor/max31856.rst b/components/sensor/max31856.rst index 24669e62f..c656f24f3 100644 --- a/components/sensor/max31856.rst +++ b/components/sensor/max31856.rst @@ -3,12 +3,12 @@ MAX31856 Thermocouple Temperature Sensor .. seo:: :description: Instructions for setting up MAX31856 Thermocouple temperature sensors. - :image: max31865.jpg + :image: max31856.jpg The ``MAX31856`` temperature sensor allows you to use your MAX31856 Thermocouple temperature sensor (`datasheet `__) with ESPHome -.. figure:: images/max31865-full.jpg +.. figure:: images/max31856-full.jpg :align: center :width: 50.0% From aa80622136f12e973daf7a9cdb90457f067c29c0 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 17 Jan 2022 11:50:14 +1300 Subject: [PATCH 17/18] Add select and button to REST API docs (#1805) --- web-api/index.rst | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/web-api/index.rst b/web-api/index.rst index 4136fd079..1fb23fc1b 100644 --- a/web-api/index.rst +++ b/web-api/index.rst @@ -63,7 +63,7 @@ There's also a simple REST API available which can be used to get and set the cu calls to this API follow the URL schema ``//[/?=]``. The ``domain`` is the type of the component, for example ``sensor`` or ``light``. ``id`` refers to the id of the component - this ID is created by taking the name of the component, stripping out -all non-alphanumeric characters, making everything lowercase and replacing all spaces by underscores. +all non-alphanumeric characters, making everything lowercase and replacing all spaces by underscores. To confirm the ```` to use, you can set the :ref:`log level ` to ``VERY_VERBOSE`` and check the ``object_id:`` in the logs. @@ -161,7 +161,7 @@ the state of a light, send a GET request to ``/light/``, for example ``light - **effect**: The currently active effect, only if the light supports effects. - **white_value**: The white value of RGBW lights. From 0 to 255. Only if the light supports white value. - **color_temp**: The color temperature of the RGBWW light. Between minimum mireds and maximum mireds of the light. - Only if the light support color temperature. + Only if the light support color temperature. Setting light state can happen through three POST method calls: ``turn_on``, ``turn_off`` and ``toggle``. Turn on and off have additional URL encoded parameters that can be used to set other properties. For example @@ -249,3 +249,29 @@ can be used: Creating a POST request to ``/cover/front_window_blinds/set?position=0.1&tilt=0.3`` will start moving the blinds towards an almost completely closed position and a new tilt angle. + +Select +****** + +Selects can be set to an option and will return their current option. For example sending +a GET request to ``/select/house_mode`` could yield this payload: + +.. code-block:: json + + { + "id": "select-house_mode", + "state": "party", + "value": "party" + } + +POST requests on the other hand allow setting the select, the available +method is ``set``. The following parameter can be used: + +- **option**: The string option to set it to. Must be a valid option. + +For example POST ``/select/house_mode/set?option=guest`` will set the select to ``guest``. + +Button +****** + +A button can be ``pressed`` from the REST API by sending a POST request to ``button/do_something/press``. From a6736cebcb86f81016f779a2c9a8a28675167e3e Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 17 Jan 2022 17:18:44 +1300 Subject: [PATCH 18/18] Add discord and forums to keeping up (#1808) --- index.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.rst b/index.rst index 434f31e74..c13f0ea0f 100644 --- a/index.rst +++ b/index.rst @@ -82,6 +82,16 @@ ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configu