diff --git a/components/api.rst b/components/api.rst index aa4628e21..fbd63dd3b 100644 --- a/components/api.rst +++ b/components/api.rst @@ -23,7 +23,7 @@ A Python library that implements this protocol is `aioesphomeapi ` to be configured. Put the ``tuya`` component in -the config and it will list the possible devices for you in the config log. - -.. code-block:: yaml - - # Example configuration entry - # Make sure your WiFi will connect - wifi: - ssid: "ssid" - password: "password" - - # Make sure logging is not using the serial port - logger: - baud_rate: 0 - - # Enable Home Assistant API - api: - - # Make sure you can upload new firmware OTA - ota: - - # My cover used the hardware serial port on the alternate pins - uart: - rx_pin: GPIO13 - tx_pin: GPIO15 - baud_rate: 9600 - - # Register the Tuya MCU connection - tuya: +This requires the :doc:`/components/tuya` component to be set up before you can use this platform. Here is an example output for a Tuya M515EGWT (motor for chain roller blinds): diff --git a/components/dfplayer.rst b/components/dfplayer.rst index c574965b2..9bc19771e 100644 --- a/components/dfplayer.rst +++ b/components/dfplayer.rst @@ -311,18 +311,6 @@ Sample code .. code-block:: yaml - esphome: - name: test_node - platform: ESP8266 - board: nodemcu - - wifi: - ssid: !secret wifi_ssid - password: !secret wifi_pass - - logger: - level: VERBOSE - uart: tx_pin: GPIO2 rx_pin: GPIO5 diff --git a/components/display/inkplate6.rst b/components/display/inkplate6.rst index df467cc86..708c85a45 100644 --- a/components/display/inkplate6.rst +++ b/components/display/inkplate6.rst @@ -129,17 +129,16 @@ Wi-Fi, API, and OTA configuration. # Example configuration entry esphome: name: inkplate - platform: ESP32 + + esp32: board: esp-wrover-kit logger: wifi: - ssid: - password: - ap: - ssid: Inkplate-AP - password: '12345678' + ssid: !secret wifi_ssid + password: !secret wifi_password + ap: {} captive_portal: diff --git a/components/display/st7789v.rst b/components/display/st7789v.rst index 7bdeb8fa8..b9c796b92 100644 --- a/components/display/st7789v.rst +++ b/components/display/st7789v.rst @@ -108,8 +108,7 @@ To bring in color images: Complete example **************** -The following is a complete example YAML configuration that does a few things beyond the usual -Wi-Fi, API, and OTA configuration. It defines: +The following is an example YAML configuration that you can add to your base device configuration. It defines: - three fonts (well, one font in three sizes) - a ``binary_sensor`` that indicates the state of connectivity to the API @@ -134,32 +133,6 @@ appropriate lines of C code in the lambda to hide or show the image or text as y .. code-block:: yaml - esphome: - name: esp_tdisplay - platform: ESP32 - board: featheresp32 - - wifi: - ssid: "ssid" - password: "password" - - # Enable fallback hotspot (captive portal) in case wifi connection fails - ap: - ssid: "esp_tdisplay" - password: "some_password" - - captive_portal: - - # Enable logging - logger: - - # Enable Home Assistant API - api: - password: "some_api_password" - - ota: - password: "some_ota_password" - color: - id: my_red red: 100% diff --git a/components/esphome.rst b/components/esphome.rst index 6e4f622e2..2ad9c9d89 100644 --- a/components/esphome.rst +++ b/components/esphome.rst @@ -15,7 +15,8 @@ where you specify the **name** of the node. esphome: name: livingroom comment: Living room ESP32 controller - platform: ESP32 + + esp32: board: nodemcu-32s .. _esphome-configuration_variables: @@ -50,8 +51,8 @@ Advanced options: - **name** (**Required**, string): Name of the project - **version** (**Required**, string): Version of the project -Old-style platform options, which have been moved to the platform-specific :doc:`esp32 ` and -:doc:`esp8266 ` sections but are still accepted here for compatibility reasons (usage not +Old-style platform options, which have been moved to the platform-specific :doc:`esp32 ` and +:doc:`esp8266 ` sections but are still accepted here for compatibility reasons (usage not recommended for new projects): - **platform** (**Required**, string): The platform used, either ``esp8266`` or ``esp32``. diff --git a/components/fingerprint_grow.rst b/components/fingerprint_grow.rst index b972c88db..79c8d4ffa 100644 --- a/components/fingerprint_grow.rst +++ b/components/fingerprint_grow.rst @@ -39,61 +39,16 @@ If available on your reader model, it's recommended to connect 3.3VT (touch indu fingerprint_grow: sensing_pin: GPIO12 on_finger_scan_matched: - - text_sensor.template.publish: - id: fingerprint_state - state: "Authorized finger" - - switch.turn_on: gate - - delay: 500ms - - switch.turn_off: gate + ... on_finger_scan_unmatched: - - text_sensor.template.publish: - id: fingerprint_state - state: "Unauthorized finger" + ... on_enrollment_scan: - - text_sensor.template.publish: - id: fingerprint_state - state: "Finger scanned" + ... on_enrollment_done: - - text_sensor.template.publish: - id: fingerprint_state - state: "Enrolled fingerprint" + ... on_enrollment_failed: - - text_sensor.template.publish: - id: fingerprint_state - state: "Failed to enroll fingerprint" + ... - # Optional template text sensor for visual feedback - text_sensor: - - platform: template - id: fingerprint_state - name: "Fingerprint State" - - # Optional component (GPIO switch, lock etc.) to control in on_finger_scan_matched trigger - switch: - - platform: gpio - pin: GPIO14 - id: gate - - # Optional sensors - binary_sensor: - - platform: fingerprint_grow - id: fingerprint_enrolling - name: "Fingerprint Enrolling" - - sensor: - - platform: fingerprint_grow - fingerprint_count: - name: "Fingerprint Count" - last_finger_id: - name: "Fingerprint Last Finger ID" - last_confidence: - name: "Fingerprint Last Confidence" - status: - name: "Fingerprint Status" - capacity: - name: "Fingerprint Capacity" - security_level: - name: "Fingerprint Security Level" Configuration variables: @@ -458,17 +413,6 @@ Sample code .. code-block:: yaml - esphome: - name: test_node - platform: ESP8266 - board: nodemcu - - wifi: - ssid: !secret wifi_ssid - password: !secret wifi_pass - - logger: - uart: rx_pin: GPIO13 tx_pin: GPIO15 diff --git a/components/light/tuya.rst b/components/light/tuya.rst index 4838e7456..2c2ee3df5 100644 --- a/components/light/tuya.rst +++ b/components/light/tuya.rst @@ -16,36 +16,7 @@ tuya serial component. The dimmer switch I got would hang if the logger was configured to use the serial port which meant it was bricked until I cut it open. -There are two components, the Tuya bus and the dimmer that uses it. The :doc:`/components/tuya` -component requires a :ref:`UART bus ` to be configured. Put the ``tuya`` component in -the config and it will list the possible devices for you in the config log. - -.. code-block:: yaml - - # Example configuration entry - # Make sure your WiFi will connect - wifi: - ssid: "ssid" - password: "password" - - # Make sure logging is not using the serial port - logger: - baud_rate: 0 - - # Enable Home Assistant API - api: - - # Make sure you can upload new firmware OTA - ota: - - # My dimmer used the hardware serial port on the alternate pins - uart: - rx_pin: GPIO13 - tx_pin: GPIO15 - baud_rate: 9600 - - # Register the Tuya MCU connection - tuya: +This requires the :doc:`/components/tuya` component to be set up before you can use this platform. Here is an example output for a Tuya dimmer: diff --git a/components/modbus_controller.rst b/components/modbus_controller.rst index bf99dbd6f..701c55439 100644 --- a/components/modbus_controller.rst +++ b/components/modbus_controller.rst @@ -28,13 +28,13 @@ The controller connects to the UART of the MCU. For ESP32 GPIO PIN 16 to TXD PI .. note:: If you are using an ESP8266, serial logging may cause problems reading from UART. For best results, hardware serial is recommended. Software serial may not be able to read all received data if other components spend a lot of time in the ``loop()``. - + For hardware serial only a limited set of pins can be used. Either ``tx_pin: GPIO1`` and ``rx_pin: GPIO3`` or ``tx_pin: GPIO15`` and ``rx_pin: GPIO13``. - + The disadvantage of using the hardware uart is that you can't use serial logging because the serial logs would be sent to the modbus device and cause errors. - + Serial logging can be disabled by setting ``baud_rate: 0``. - + See :doc:`logger` for more details .. code-block:: yaml @@ -67,26 +67,6 @@ Technically there is no difference between the "inline" and the standard definit .. code-block:: yaml - esphome: - name: solarstation - platform: ESP32 - board: esp32dev - - substitutions: - updates: 30s - - wifi: - ssid: !secret wifi_sid - password: !secret wifi_password - reboot_timeout: 2min - - logger: - level: INFO - baud_rate: 0 - - api: - password: !secret api_password - uart: id: mod_bus tx_pin: 17 @@ -324,85 +304,72 @@ Then battery charge settings are sent. .. code-block:: yaml esphome: - name: solarstation-test - platform: ESP32 - board: esp32dev - - ## send config values at startup - ## configure rtc clock and battery charge settings on_boot: + ## configure controller settings at setup + ## make sure priority is lower than setup_priority of modbus_controller priority: -100 then: - lambda: |- + // get local time and sync to controller + 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 % 100; + esphome::modbus_controller::ModbusController *controller = id(epever); + // if there is no internet connection localtime returns year 70 + if (year != 70) { + // 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(controller, 0x9013, 3, rtc_data); + // Submit the command to the send queue + epever->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); + } + // Battery settings + // Note: these values are examples only and apply my AGM Battery + std::vector battery_settings1 = { + 0, // 9000 Battery Type 0 = User + 0x0073, // 9001 Battery Cap 0x55 == 115AH + 0x012C, // 9002 Temp compensation -3V /°C/2V + 0x05DC, // 9003 0x5DC == 1500 Over Voltage Disconnect Voltage 15,0 + 0x058C, // 9004 0x58C == 1480 Charging Limit Voltage 14,8 + 0x058C, // 9005 Over Voltage Reconnect Voltage 14,8 + 0x05BF, // 9006 Equalize Charging Voltage 14,6 + 0x05BE, // 9007 Boost Charging Voltage 14,7 + 0x0550, // 9008 Float Charging Voltage 13,6 + 0x0528, // 9009 Boost Reconnect Charging Voltage 13,2 + 0x04C4, // 900A Low Voltage Reconnect Voltage 12,2 + 0x04B0, // 900B Under Voltage Warning Reconnect Voltage 12,0 + 0x04BA, // 900c Under Volt. Warning Volt 12,1 + 0x04BA, // 900d Low Volt. Disconnect Volt. 11.8 + 0x04BA // 900E Discharging Limit Voltage 11.8 + }; - on_boot: - ## configure controller settings at setup - ## make sure priority is lower than setup_priority of modbus_controller - priority: -100 - then: - - lambda: |- - // get local time and sync to controller - 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 % 100; - esphome::modbus_controller::ModbusController *controller = id(epever); - // if there is no internet connection localtime returns year 70 - if (year != 70) { - // 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(controller, 0x9013, 3, rtc_data); - // Submit the command to the send queue - epever->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); - } - // Battery settings - // Note: these values are examples only and apply my AGM Battery - std::vector battery_settings1 = { - 0, // 9000 Battery Type 0 = User - 0x0073, // 9001 Battery Cap 0x55 == 115AH - 0x012C, // 9002 Temp compensation -3V /°C/2V - 0x05DC, // 9003 0x5DC == 1500 Over Voltage Disconnect Voltage 15,0 - 0x058C, // 9004 0x58C == 1480 Charging Limit Voltage 14,8 - 0x058C, // 9005 Over Voltage Reconnect Voltage 14,8 - 0x05BF, // 9006 Equalize Charging Voltage 14,6 - 0x05BE, // 9007 Boost Charging Voltage 14,7 - 0x0550, // 9008 Float Charging Voltage 13,6 - 0x0528, // 9009 Boost Reconnect Charging Voltage 13,2 - 0x04C4, // 900A Low Voltage Reconnect Voltage 12,2 - 0x04B0, // 900B Under Voltage Warning Reconnect Voltage 12,0 - 0x04BA, // 900c Under Volt. Warning Volt 12,1 - 0x04BA, // 900d Low Volt. Disconnect Volt. 11.8 - 0x04BA // 900E Discharging Limit Voltage 11.8 - }; - - // Boost and equalization periods - std::vector battery_settings2 = { - 0x0000, // 906B Equalize Duration (min.) 0 - 0x0075 // 906C Boost Duration (aka absorb) 117 mins - }; - esphome::modbus_controller::ModbusCommandItem set_battery1_command = - esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(controller, 0x9000, battery_settings1.size() , - battery_settings1); - - esphome::modbus_controller::ModbusCommandItem set_battery2_command = - esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(controller, 0x906B, battery_settings3.size(), - battery_settings2); - delay(200) ; - controller->queue_command(set_battery1_command); - delay(200) ; - controller->queue_command(set_battery2_command); - ESP_LOGI("ModbusLambda", "EPSOLAR Battery set"); - + // Boost and equalization periods + std::vector battery_settings2 = { + 0x0000, // 906B Equalize Duration (min.) 0 + 0x0075 // 906C Boost Duration (aka absorb) 117 mins + }; + esphome::modbus_controller::ModbusCommandItem set_battery1_command = + esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(controller, 0x9000, battery_settings1.size() , + battery_settings1); + esphome::modbus_controller::ModbusCommandItem set_battery2_command = + esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(controller, 0x906B, battery_settings3.size(), + battery_settings2); + delay(200) ; + controller->queue_command(set_battery1_command); + delay(200) ; + controller->queue_command(set_battery2_command); + ESP_LOGI("ModbusLambda", "EPSOLAR Battery set"); uart: id: mod_bus diff --git a/components/mqtt.rst b/components/mqtt.rst index b7bd12c15..387c8cd25 100644 --- a/components/mqtt.rst +++ b/components/mqtt.rst @@ -22,7 +22,7 @@ in which case this is not needed. mqtt: broker: 10.0.0.2 username: livingroom - password: MyMQTTPassword + password: !secret mqtt_password Configuration variables: ------------------------ diff --git a/components/nspanel.rst b/components/nspanel.rst new file mode 100644 index 000000000..843909f92 --- /dev/null +++ b/components/nspanel.rst @@ -0,0 +1,31 @@ +Sonoff NSPanel +============== + +.. seo:: + :description: Instructions for using ESPHome of the Sonoff NSPanel + +The Sonoff NSPanel integration allows ESPHome to control features and functionality of the NSPanel's +built in display. + +.. code-block:: yaml + + nspanel: + time_id: REPLACEME + temperature: temperature_id + screen_power_switch: screen_power_switch_id + relays: + - relay_1_id + - relay_2_id + + widgets: + - type: scene + name: Test + on_click: + - logger.log: Test Scene tapped + + - type: empty + ... + + +Configuration Variables: +------------------------ diff --git a/components/ota.rst b/components/ota.rst index c11fa7aa4..eb67f5e1c 100644 --- a/components/ota.rst +++ b/components/ota.rst @@ -23,7 +23,7 @@ Logging+WiFi+OTA are initialized, so that you can upload a new binary. # Example configuration entry ota: safe_mode: true - password: VERYSECURE + password: !secret ota_password Configuration variables: ------------------------ diff --git a/components/output/gpio.rst b/components/output/gpio.rst index 5642cc6db..de9547819 100644 --- a/components/output/gpio.rst +++ b/components/output/gpio.rst @@ -26,7 +26,7 @@ Configuration variables: .. warning:: - This is an **output component** and will not visible from the frontend. Output components are intermediary + This is an **output component** and will not be visible from the frontend. Output components are intermediary components that can be attached to for example lights. To have a GPIO pin in the Home Assistant frontend, please see the :doc:`/components/switch/gpio`. diff --git a/components/output/my9231.rst b/components/output/my9231.rst index c3889ed75..f20b7c904 100644 --- a/components/output/my9231.rst +++ b/components/output/my9231.rst @@ -106,20 +106,20 @@ complete configuration for a Sonoff B1 looks like: .. code-block:: yaml esphome: - name: - platform: ESP8266 + name: REPLACEME + + esp8266: board: esp01_1m wifi: - ssid: - password: + ssid: !secret wifi_ssid + password: !secret wifi_password api: logger: ota: - password: my9231: data_pin: GPIO12 # GPIO13 for AiLight @@ -147,7 +147,7 @@ complete configuration for a Sonoff B1 looks like: light: - platform: rgbww - name: + name: REPLACEME red: output_red green: output_green blue: output_blue @@ -161,20 +161,20 @@ And here is a complete configuration for the AiThinker AiLight: .. code-block:: yaml esphome: - name: - platform: ESP8266 + name: REPLACEME + + esp8266: board: esp01_1m wifi: - ssid: - password: + ssid: !secret wifi_ssid + password: !secret wifi_password api: logger: ota: - password: my9231: data_pin: GPIO13 @@ -199,7 +199,7 @@ And here is a complete configuration for the AiThinker AiLight: light: - platform: rgbw - name: + name: REPLACEME red: output_red green: output_green blue: output_blue diff --git a/components/output/sm16716.rst b/components/output/sm16716.rst index bab404c31..e61270806 100644 --- a/components/output/sm16716.rst +++ b/components/output/sm16716.rst @@ -111,20 +111,21 @@ A complete configuration for a Feit Electric A19 looks like: .. code-block:: yaml esphome: - name: - platform: ESP8266 + name: REPLACEME + friendly_name: REPLACEME + + esp8266: board: esp01_1m wifi: - ssid: - password: + ssid: !secret wifi_ssid + password: !secret wifi_password api: logger: ota: - password: sm16716: data_pin: GPIO14 diff --git a/components/rtttl.rst b/components/rtttl.rst index 1b71b8b76..077edceb8 100644 --- a/components/rtttl.rst +++ b/components/rtttl.rst @@ -129,12 +129,13 @@ Sample code esphome: name: test_esp8266 - platform: ESP8266 + + esp8266: board: nodemcuv2 wifi: ssid: !secret wifi_ssid - password: !secret wifi_pass + password: !secret wifi_password output: - platform: esp8266_pwm diff --git a/components/switch/modbus_controller.rst b/components/switch/modbus_controller.rst index bd245f921..bc7e6d539 100644 --- a/components/switch/modbus_controller.rst +++ b/components/switch/modbus_controller.rst @@ -13,7 +13,7 @@ Configuration variables: - **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation. - **name** (**Required**, string): The name of the sensor. -- **modbus_functioncode** (**Required**): type of the modbus register. +- **register_type** (**Required**): type of the modbus register. - **address**: (**Required**, int): start address of the first register in a range - **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 @@ -41,7 +41,8 @@ Configuration variables: Possible return values for the lambda: - ``return ;`` the new value for the sensor. - - ``return ; and fill payload with data`` if the payload is added from the lambda then these bytes will be sent + - ``return ; and fill payload with data`` if the payload is added from the lambda then these bytes will be sent. + - ``return {};`` in the case the lambda handles the sending of the value itself. **Example** @@ -63,6 +64,7 @@ Possible return values for the lambda: payload.push_back(0x6); // low byte address of the coil payload.push_back(0xFF); // ON = 0xFF00 OFF=0000 payload.push_back(0x00); + return true; diff --git a/components/tuya.rst b/components/tuya.rst index b14446926..6067dc5c4 100644 --- a/components/tuya.rst +++ b/components/tuya.rst @@ -16,22 +16,10 @@ Put the ``tuya`` component in the config and it will list the possible devices f .. code-block:: yaml - # Example configuration entry - # Make sure your wifi will connect - wifi: - ssid: "ssid" - password: "password" - # Make sure logging is not using the serial port logger: baud_rate: 0 - # Enable Home Assistant API - api: - - # Make sure you can upload new firmware OTA - ota: - uart: rx_pin: GPIO3 tx_pin: GPIO1 @@ -55,7 +43,7 @@ Here is an example output for a Tuya fan controller: Configuration variables: ------------------------ -- **time_id** (*Optional*, :ref:`config-id`): Some Tuya devices support obtaining local time from ESPHome. +- **time_id** (*Optional*, :ref:`config-id`): Some Tuya devices support obtaining local time from ESPHome. Specify the ID of the :ref:`Time Component