mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 00:51:49 +00:00 
			
		
		
		
	Compare commits
	
		
			16 Commits
		
	
	
		
			2024.6.0b1
			...
			2024.6.0b4
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					c053a33fe8 | ||
| 
						 | 
					ff07637dfd | ||
| 
						 | 
					43b5c2deb7 | ||
| 
						 | 
					d27e7b3b70 | ||
| 
						 | 
					5dec62bf1e | ||
| 
						 | 
					cfe28ce7a3 | ||
| 
						 | 
					25a3db1637 | ||
| 
						 | 
					65638bf614 | ||
| 
						 | 
					1e66241b26 | ||
| 
						 | 
					eb50f0eafd | ||
| 
						 | 
					4e8a7986cd | ||
| 
						 | 
					3db71b98ae | ||
| 
						 | 
					73cb3ec852 | ||
| 
						 | 
					91e72fe121 | ||
| 
						 | 
					be486e0ca6 | ||
| 
						 | 
					fdefc825bb | 
							
								
								
									
										6
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							@@ -454,7 +454,7 @@ jobs:
 | 
			
		||||
      matrix:
 | 
			
		||||
        file: ${{ fromJson(needs.list-components.outputs.components) }}
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Install libsodium
 | 
			
		||||
      - name: Install dependencies
 | 
			
		||||
        run: sudo apt-get install libsodium-dev libsdl2-dev
 | 
			
		||||
 | 
			
		||||
      - name: Check out code from GitHub
 | 
			
		||||
@@ -508,8 +508,8 @@ jobs:
 | 
			
		||||
      - name: List components
 | 
			
		||||
        run: echo ${{ matrix.components }}
 | 
			
		||||
 | 
			
		||||
      - name: Install libsodium
 | 
			
		||||
        run: sudo apt-get install libsodium-dev
 | 
			
		||||
      - name: Install dependencies
 | 
			
		||||
        run: sudo apt-get install libsodium-dev libsdl2-dev
 | 
			
		||||
 | 
			
		||||
      - name: Check out code from GitHub
 | 
			
		||||
        uses: actions/checkout@v4.1.6
 | 
			
		||||
 
 | 
			
		||||
@@ -488,6 +488,15 @@ def command_run(args, config):
 | 
			
		||||
    if exit_code != 0:
 | 
			
		||||
        return exit_code
 | 
			
		||||
    _LOGGER.info("Successfully compiled program.")
 | 
			
		||||
    if CORE.is_host:
 | 
			
		||||
        from esphome.platformio_api import get_idedata
 | 
			
		||||
 | 
			
		||||
        idedata = get_idedata(config)
 | 
			
		||||
        if idedata is None:
 | 
			
		||||
            return 1
 | 
			
		||||
        program_path = idedata.raw["prog_path"]
 | 
			
		||||
        return run_external_process(program_path)
 | 
			
		||||
 | 
			
		||||
    port = choose_upload_log_host(
 | 
			
		||||
        default=args.device,
 | 
			
		||||
        check_default=None,
 | 
			
		||||
 
 | 
			
		||||
@@ -96,16 +96,16 @@ def get_board(core_obj=None):
 | 
			
		||||
def get_download_types(storage_json):
 | 
			
		||||
    return [
 | 
			
		||||
        {
 | 
			
		||||
            "title": "Modern format",
 | 
			
		||||
            "title": "Factory format (Previously Modern)",
 | 
			
		||||
            "description": "For use with ESPHome Web and other tools.",
 | 
			
		||||
            "file": "firmware-factory.bin",
 | 
			
		||||
            "download": f"{storage_json.name}-factory.bin",
 | 
			
		||||
            "file": "firmware.factory.bin",
 | 
			
		||||
            "download": f"{storage_json.name}.factory.bin",
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "title": "Legacy format",
 | 
			
		||||
            "description": "For use with ESPHome Flasher.",
 | 
			
		||||
            "file": "firmware.bin",
 | 
			
		||||
            "download": f"{storage_json.name}.bin",
 | 
			
		||||
            "title": "OTA format (Previously Legacy)",
 | 
			
		||||
            "description": "For OTA updating a device.",
 | 
			
		||||
            "file": "firmware.ota.bin",
 | 
			
		||||
            "download": f"{storage_json.name}.ota.bin",
 | 
			
		||||
        },
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -17,17 +17,19 @@ from SCons.Script import ARGUMENTS
 | 
			
		||||
 | 
			
		||||
# Copy over the default sdkconfig.
 | 
			
		||||
from os import path
 | 
			
		||||
 | 
			
		||||
if path.exists("./sdkconfig.defaults"):
 | 
			
		||||
    os.makedirs(".temp", exist_ok=True)
 | 
			
		||||
    shutil.copy("./sdkconfig.defaults", "./.temp/sdkconfig-esp32-idf")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def esp32_create_combined_bin(source, target, env):
 | 
			
		||||
    verbose = bool(int(ARGUMENTS.get("PIOVERBOSE", "0")))
 | 
			
		||||
    if verbose:
 | 
			
		||||
        print("Generating combined binary for serial flashing")
 | 
			
		||||
    app_offset = 0x10000
 | 
			
		||||
 | 
			
		||||
    new_file_name = env.subst("$BUILD_DIR/${PROGNAME}-factory.bin")
 | 
			
		||||
    new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
 | 
			
		||||
    sections = env.subst(env.get("FLASH_EXTRA_IMAGES"))
 | 
			
		||||
    firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
 | 
			
		||||
    chip = env.get("BOARD_MCU")
 | 
			
		||||
@@ -62,5 +64,14 @@ def esp32_create_combined_bin(source, target, env):
 | 
			
		||||
    else:
 | 
			
		||||
        subprocess.run(["esptool.py", *cmd])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def esp32_copy_ota_bin(source, target, env):
 | 
			
		||||
    firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
 | 
			
		||||
    new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
 | 
			
		||||
 | 
			
		||||
    shutil.copyfile(firmware_name, new_file_name)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# pylint: disable=E0602
 | 
			
		||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin)  # noqa
 | 
			
		||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_copy_ota_bin)  # noqa
 | 
			
		||||
 
 | 
			
		||||
@@ -6,10 +6,18 @@ Import("env")  # noqa
 | 
			
		||||
 | 
			
		||||
def esp8266_copy_factory_bin(source, target, env):
 | 
			
		||||
    firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
 | 
			
		||||
    new_file_name = env.subst("$BUILD_DIR/${PROGNAME}-factory.bin")
 | 
			
		||||
    new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
 | 
			
		||||
 | 
			
		||||
    shutil.copyfile(firmware_name, new_file_name)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def esp8266_copy_ota_bin(source, target, env):
 | 
			
		||||
    firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
 | 
			
		||||
    new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
 | 
			
		||||
 | 
			
		||||
    shutil.copyfile(firmware_name, new_file_name)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# pylint: disable=E0602
 | 
			
		||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_factory_bin)  # noqa
 | 
			
		||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_ota_bin)  # noqa
 | 
			
		||||
 
 | 
			
		||||
@@ -60,7 +60,7 @@ void HOT IRAM_ATTR GPIOOneWireBus::write_bit_(bool bit) {
 | 
			
		||||
  // recovery time: t_rec: min=1µs
 | 
			
		||||
  // ds18b20 appears to read the bus after roughly 14µs
 | 
			
		||||
  uint32_t delay0 = bit ? 6 : 60;
 | 
			
		||||
  uint32_t delay1 = bit ? 54 : 5;
 | 
			
		||||
  uint32_t delay1 = bit ? 59 : 5;
 | 
			
		||||
 | 
			
		||||
  // delay A/C
 | 
			
		||||
  delayMicroseconds(delay0);
 | 
			
		||||
 
 | 
			
		||||
@@ -34,8 +34,8 @@ void ILI9XXXDisplay::setup() {
 | 
			
		||||
  ESP_LOGD(TAG, "Setting up ILI9xxx");
 | 
			
		||||
 | 
			
		||||
  this->setup_pins_();
 | 
			
		||||
  this->init_lcd_(this->init_sequence_);
 | 
			
		||||
  this->init_lcd_(this->extra_init_sequence_.data());
 | 
			
		||||
  this->init_lcd(this->init_sequence_);
 | 
			
		||||
  this->init_lcd(this->extra_init_sequence_.data());
 | 
			
		||||
  switch (this->pixel_mode_) {
 | 
			
		||||
    case PIXEL_MODE_16:
 | 
			
		||||
      if (this->is_18bitdisplay_) {
 | 
			
		||||
@@ -405,7 +405,7 @@ void ILI9XXXDisplay::reset_() {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ILI9XXXDisplay::init_lcd_(const uint8_t *addr) {
 | 
			
		||||
void ILI9XXXDisplay::init_lcd(const uint8_t *addr) {
 | 
			
		||||
  if (addr == nullptr)
 | 
			
		||||
    return;
 | 
			
		||||
  uint8_t cmd, x, num_args;
 | 
			
		||||
@@ -427,6 +427,20 @@ void ILI9XXXDisplay::init_lcd_(const uint8_t *addr) {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ILI9XXXGC9A01A::init_lcd(const uint8_t *addr) {
 | 
			
		||||
  if (addr == nullptr)
 | 
			
		||||
    return;
 | 
			
		||||
  uint8_t cmd, x, num_args;
 | 
			
		||||
  while ((cmd = *addr++) != 0) {
 | 
			
		||||
    x = *addr++;
 | 
			
		||||
    num_args = x & 0x7F;
 | 
			
		||||
    this->send_command(cmd, addr, num_args);
 | 
			
		||||
    addr += num_args;
 | 
			
		||||
    if (x & 0x80)
 | 
			
		||||
      delay(150);  // NOLINT
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Tell the display controller where we want to draw pixels.
 | 
			
		||||
void ILI9XXXDisplay::set_addr_window_(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
 | 
			
		||||
  x1 += this->offset_x_;
 | 
			
		||||
 
 | 
			
		||||
@@ -109,7 +109,7 @@ class ILI9XXXDisplay : public display::DisplayBuffer,
 | 
			
		||||
 | 
			
		||||
  virtual void set_madctl();
 | 
			
		||||
  void display_();
 | 
			
		||||
  void init_lcd_(const uint8_t *addr);
 | 
			
		||||
  virtual void init_lcd(const uint8_t *addr);
 | 
			
		||||
  void set_addr_window_(uint16_t x, uint16_t y, uint16_t x2, uint16_t y2);
 | 
			
		||||
  void reset_();
 | 
			
		||||
 | 
			
		||||
@@ -269,6 +269,7 @@ class ILI9XXXS3BoxLite : public ILI9XXXDisplay {
 | 
			
		||||
class ILI9XXXGC9A01A : public ILI9XXXDisplay {
 | 
			
		||||
 public:
 | 
			
		||||
  ILI9XXXGC9A01A() : ILI9XXXDisplay(INITCMD_GC9A01A, 240, 240, true) {}
 | 
			
		||||
  void init_lcd(const uint8_t *addr) override;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//-----------   ILI9XXX_24_TFT display --------------
 | 
			
		||||
 
 | 
			
		||||
@@ -6,12 +6,12 @@
 | 
			
		||||
#include "mqtt_const.h"
 | 
			
		||||
 | 
			
		||||
#ifdef USE_MQTT
 | 
			
		||||
#ifdef USE_DATETIME_TIME
 | 
			
		||||
#ifdef USE_DATETIME_DATETIME
 | 
			
		||||
 | 
			
		||||
namespace esphome {
 | 
			
		||||
namespace mqtt {
 | 
			
		||||
 | 
			
		||||
static const char *const TAG = "mqtt.datetime.time";
 | 
			
		||||
static const char *const TAG = "mqtt.datetime.datetime";
 | 
			
		||||
 | 
			
		||||
using namespace esphome::datetime;
 | 
			
		||||
 | 
			
		||||
@@ -80,5 +80,5 @@ bool MQTTDateTimeComponent::publish_state(uint16_t year, uint8_t month, uint8_t
 | 
			
		||||
}  // namespace mqtt
 | 
			
		||||
}  // namespace esphome
 | 
			
		||||
 | 
			
		||||
#endif  // USE_DATETIME_TIME
 | 
			
		||||
#endif  // USE_DATETIME_DATETIME
 | 
			
		||||
#endif  // USE_MQTT
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
#include "esphome/core/defines.h"
 | 
			
		||||
 | 
			
		||||
#ifdef USE_MQTT
 | 
			
		||||
#ifdef USE_DATETIME_TIME
 | 
			
		||||
#ifdef USE_DATETIME_DATETIME
 | 
			
		||||
 | 
			
		||||
#include "esphome/components/datetime/datetime_entity.h"
 | 
			
		||||
#include "mqtt_component.h"
 | 
			
		||||
@@ -17,7 +17,7 @@ class MQTTDateTimeComponent : public mqtt::MQTTComponent {
 | 
			
		||||
   *
 | 
			
		||||
   * @param time The time entity.
 | 
			
		||||
   */
 | 
			
		||||
  explicit MQTTDateTimeComponent(datetime::DateTimeEntity *time);
 | 
			
		||||
  explicit MQTTDateTimeComponent(datetime::DateTimeEntity *datetime);
 | 
			
		||||
 | 
			
		||||
  // ========== INTERNAL METHODS ==========
 | 
			
		||||
  // (In most use cases you won't need these)
 | 
			
		||||
@@ -41,5 +41,5 @@ class MQTTDateTimeComponent : public mqtt::MQTTComponent {
 | 
			
		||||
}  // namespace mqtt
 | 
			
		||||
}  // namespace esphome
 | 
			
		||||
 | 
			
		||||
#endif  // USE_DATETIME_DATE
 | 
			
		||||
#endif  // USE_DATETIME_DATETIME
 | 
			
		||||
#endif  // USE_MQTT
 | 
			
		||||
 
 | 
			
		||||
@@ -47,10 +47,16 @@ def set_core_data(config):
 | 
			
		||||
def get_download_types(storage_json):
 | 
			
		||||
    return [
 | 
			
		||||
        {
 | 
			
		||||
            "title": "UF2 format",
 | 
			
		||||
            "title": "UF2 factory format",
 | 
			
		||||
            "description": "For copying to RP2040 over USB.",
 | 
			
		||||
            "file": "firmware.uf2",
 | 
			
		||||
            "download": f"{storage_json.name}.uf2",
 | 
			
		||||
            "download": f"{storage_json.name}.factory.uf2",
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "title": "OTA format",
 | 
			
		||||
            "description": "For OTA updating a device.",
 | 
			
		||||
            "file": "firmware.ota.bin",
 | 
			
		||||
            "download": f"{storage_json.name}.ota.bin",
 | 
			
		||||
        },
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
@@ -160,6 +166,8 @@ async def to_code(config):
 | 
			
		||||
    cg.add_define("ESPHOME_BOARD", config[CONF_BOARD])
 | 
			
		||||
    cg.add_define("ESPHOME_VARIANT", "RP2040")
 | 
			
		||||
 | 
			
		||||
    cg.add_platformio_option("extra_scripts", ["post:post_build.py"])
 | 
			
		||||
 | 
			
		||||
    conf = config[CONF_FRAMEWORK]
 | 
			
		||||
    cg.add_platformio_option("framework", "arduino")
 | 
			
		||||
    cg.add_build_flag("-DUSE_ARDUINO")
 | 
			
		||||
@@ -225,4 +233,10 @@ def generate_pio_files() -> bool:
 | 
			
		||||
 | 
			
		||||
# Called by writer.py
 | 
			
		||||
def copy_files() -> bool:
 | 
			
		||||
    dir = os.path.dirname(__file__)
 | 
			
		||||
    post_build_file = os.path.join(dir, "post_build.py.script")
 | 
			
		||||
    copy_file_if_changed(
 | 
			
		||||
        post_build_file,
 | 
			
		||||
        CORE.relative_build_path("post_build.py"),
 | 
			
		||||
    )
 | 
			
		||||
    return generate_pio_files()
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										23
									
								
								esphome/components/rp2040/post_build.py.script
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								esphome/components/rp2040/post_build.py.script
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
import shutil
 | 
			
		||||
 | 
			
		||||
# pylint: disable=E0602
 | 
			
		||||
Import("env")  # noqa
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def rp2040_copy_factory_uf2(source, target, env):
 | 
			
		||||
    firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.uf2")
 | 
			
		||||
    new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.uf2")
 | 
			
		||||
 | 
			
		||||
    shutil.copyfile(firmware_name, new_file_name)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def rp2040_copy_ota_bin(source, target, env):
 | 
			
		||||
    firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
 | 
			
		||||
    new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
 | 
			
		||||
 | 
			
		||||
    shutil.copyfile(firmware_name, new_file_name)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# pylint: disable=E0602
 | 
			
		||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", rp2040_copy_factory_uf2)  # noqa
 | 
			
		||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", rp2040_copy_ota_bin)  # noqa
 | 
			
		||||
@@ -7,6 +7,7 @@ from esphome.const import (
 | 
			
		||||
    CONF_ID,
 | 
			
		||||
    CONF_MQTT_ID,
 | 
			
		||||
    CONF_WEB_SERVER_ID,
 | 
			
		||||
    DEVICE_CLASS_EMPTY,
 | 
			
		||||
    DEVICE_CLASS_FIRMWARE,
 | 
			
		||||
)
 | 
			
		||||
from esphome.core import CORE, coroutine_with_priority
 | 
			
		||||
@@ -24,6 +25,7 @@ PerformAction = update_ns.class_("PerformAction", automation.Action)
 | 
			
		||||
IsAvailableCondition = update_ns.class_("IsAvailableCondition", automation.Condition)
 | 
			
		||||
 | 
			
		||||
DEVICE_CLASSES = [
 | 
			
		||||
    DEVICE_CLASS_EMPTY,
 | 
			
		||||
    DEVICE_CLASS_FIRMWARE,
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -694,15 +694,15 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
 | 
			
		||||
    info.netmask = network::IPAddress(255, 255, 255, 0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  err = esp_netif_dhcpc_stop(s_ap_netif);
 | 
			
		||||
  err = esp_netif_dhcps_stop(s_ap_netif);
 | 
			
		||||
  if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
 | 
			
		||||
    ESP_LOGV(TAG, "esp_netif_dhcpc_stop failed: %s", esp_err_to_name(err));
 | 
			
		||||
    ESP_LOGE(TAG, "esp_netif_dhcps_stop failed: %s", esp_err_to_name(err));
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  err = esp_netif_set_ip_info(s_ap_netif, &info);
 | 
			
		||||
  if (err != ESP_OK) {
 | 
			
		||||
    ESP_LOGV(TAG, "esp_netif_set_ip_info failed! %d", err);
 | 
			
		||||
    ESP_LOGE(TAG, "esp_netif_set_ip_info failed! %d", err);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -712,20 +712,20 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
 | 
			
		||||
  start_address += 99;
 | 
			
		||||
  lease.start_ip = start_address;
 | 
			
		||||
  ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
 | 
			
		||||
  start_address += 100;
 | 
			
		||||
  start_address += 10;
 | 
			
		||||
  lease.end_ip = start_address;
 | 
			
		||||
  ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
 | 
			
		||||
  err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease));
 | 
			
		||||
 | 
			
		||||
  if (err != ESP_OK) {
 | 
			
		||||
    ESP_LOGV(TAG, "esp_netif_dhcps_option failed! %d", err);
 | 
			
		||||
    ESP_LOGE(TAG, "esp_netif_dhcps_option failed! %d", err);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  err = esp_netif_dhcps_start(s_ap_netif);
 | 
			
		||||
 | 
			
		||||
  if (err != ESP_OK) {
 | 
			
		||||
    ESP_LOGV(TAG, "esp_netif_dhcps_start failed! %d", err);
 | 
			
		||||
    ESP_LOGE(TAG, "esp_netif_dhcps_start failed! %d", err);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -716,12 +716,12 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
 | 
			
		||||
 | 
			
		||||
  if (wifi_softap_dhcps_status() == DHCP_STARTED) {
 | 
			
		||||
    if (!wifi_softap_dhcps_stop()) {
 | 
			
		||||
      ESP_LOGV(TAG, "Stopping DHCP server failed!");
 | 
			
		||||
      ESP_LOGW(TAG, "Stopping DHCP server failed!");
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!wifi_set_ip_info(SOFTAP_IF, &info)) {
 | 
			
		||||
    ESP_LOGV(TAG, "Setting SoftAP info failed!");
 | 
			
		||||
    ESP_LOGE(TAG, "Setting SoftAP info failed!");
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -735,17 +735,17 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
 | 
			
		||||
  start_address += 99;
 | 
			
		||||
  lease.start_ip = start_address;
 | 
			
		||||
  ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
 | 
			
		||||
  start_address += 100;
 | 
			
		||||
  start_address += 10;
 | 
			
		||||
  lease.end_ip = start_address;
 | 
			
		||||
  ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
 | 
			
		||||
  if (!wifi_softap_set_dhcps_lease(&lease)) {
 | 
			
		||||
    ESP_LOGV(TAG, "Setting SoftAP DHCP lease failed!");
 | 
			
		||||
    ESP_LOGE(TAG, "Setting SoftAP DHCP lease failed!");
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // lease time 1440 minutes (=24 hours)
 | 
			
		||||
  if (!wifi_softap_set_dhcps_lease_time(1440)) {
 | 
			
		||||
    ESP_LOGV(TAG, "Setting SoftAP DHCP lease time failed!");
 | 
			
		||||
    ESP_LOGE(TAG, "Setting SoftAP DHCP lease time failed!");
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -755,13 +755,13 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
 | 
			
		||||
  uint8_t mode = 1;
 | 
			
		||||
  // bit0, 1 enables router information from ESP8266 SoftAP DHCP server.
 | 
			
		||||
  if (!wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &mode)) {
 | 
			
		||||
    ESP_LOGV(TAG, "wifi_softap_set_dhcps_offer_option failed!");
 | 
			
		||||
    ESP_LOGE(TAG, "wifi_softap_set_dhcps_offer_option failed!");
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  if (!wifi_softap_dhcps_start()) {
 | 
			
		||||
    ESP_LOGV(TAG, "Starting SoftAP DHCPS failed!");
 | 
			
		||||
    ESP_LOGE(TAG, "Starting SoftAP DHCPS failed!");
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -823,15 +823,15 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
 | 
			
		||||
    info.netmask = network::IPAddress(255, 255, 255, 0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  err = esp_netif_dhcpc_stop(s_ap_netif);
 | 
			
		||||
  err = esp_netif_dhcps_stop(s_ap_netif);
 | 
			
		||||
  if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
 | 
			
		||||
    ESP_LOGV(TAG, "esp_netif_dhcpc_stop failed: %s", esp_err_to_name(err));
 | 
			
		||||
    ESP_LOGE(TAG, "esp_netif_dhcps_stop failed: %s", esp_err_to_name(err));
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  err = esp_netif_set_ip_info(s_ap_netif, &info);
 | 
			
		||||
  if (err != ESP_OK) {
 | 
			
		||||
    ESP_LOGV(TAG, "esp_netif_set_ip_info failed! %d", err);
 | 
			
		||||
    ESP_LOGE(TAG, "esp_netif_set_ip_info failed! %d", err);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -841,20 +841,20 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
 | 
			
		||||
  start_address += 99;
 | 
			
		||||
  lease.start_ip = start_address;
 | 
			
		||||
  ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
 | 
			
		||||
  start_address += 100;
 | 
			
		||||
  start_address += 10;
 | 
			
		||||
  lease.end_ip = start_address;
 | 
			
		||||
  ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
 | 
			
		||||
  err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease));
 | 
			
		||||
 | 
			
		||||
  if (err != ESP_OK) {
 | 
			
		||||
    ESP_LOGV(TAG, "esp_netif_dhcps_option failed! %d", err);
 | 
			
		||||
    ESP_LOGE(TAG, "esp_netif_dhcps_option failed! %d", err);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  err = esp_netif_dhcps_start(s_ap_netif);
 | 
			
		||||
 | 
			
		||||
  if (err != ESP_OK) {
 | 
			
		||||
    ESP_LOGV(TAG, "esp_netif_dhcps_start failed! %d", err);
 | 
			
		||||
    ESP_LOGE(TAG, "esp_netif_dhcps_start failed! %d", err);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -887,12 +887,12 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
 | 
			
		||||
 | 
			
		||||
  esp_err_t err = esp_wifi_set_config(WIFI_IF_AP, &conf);
 | 
			
		||||
  if (err != ESP_OK) {
 | 
			
		||||
    ESP_LOGV(TAG, "esp_wifi_set_config failed! %d", err);
 | 
			
		||||
    ESP_LOGE(TAG, "esp_wifi_set_config failed! %d", err);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!this->wifi_ap_ip_config_(ap.get_manual_ip())) {
 | 
			
		||||
    ESP_LOGV(TAG, "wifi_ap_ip_config_ failed!");
 | 
			
		||||
    ESP_LOGE(TAG, "wifi_ap_ip_config_ failed!");
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ from esphome.const import (
 | 
			
		||||
    CONF_INC_PIN,
 | 
			
		||||
    CONF_UD_PIN,
 | 
			
		||||
    CONF_INITIAL_VALUE,
 | 
			
		||||
    CONF_STEP_DELAY,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
CODEOWNERS = ["@EtienneMD"]
 | 
			
		||||
@@ -26,6 +27,7 @@ CONFIG_SCHEMA = cv.All(
 | 
			
		||||
            cv.Optional(CONF_INITIAL_VALUE, default=1.0): cv.float_range(
 | 
			
		||||
                min=0.01, max=1.0
 | 
			
		||||
            ),
 | 
			
		||||
            cv.Optional(CONF_STEP_DELAY, default=1): cv.int_range(min=1, max=100),
 | 
			
		||||
        }
 | 
			
		||||
    )
 | 
			
		||||
)
 | 
			
		||||
@@ -44,3 +46,4 @@ async def to_code(config):
 | 
			
		||||
    cg.add(var.set_ud_pin(ud_pin))
 | 
			
		||||
 | 
			
		||||
    cg.add(var.set_initial_value(config[CONF_INITIAL_VALUE]))
 | 
			
		||||
    cg.add(var.set_step_delay(config[CONF_STEP_DELAY]))
 | 
			
		||||
 
 | 
			
		||||
@@ -22,9 +22,9 @@ void X9cOutput::trim_value(int change_amount) {
 | 
			
		||||
 | 
			
		||||
  for (int i = 0; i < abs(change_amount); i++) {  // Move wiper
 | 
			
		||||
    this->inc_pin_->digital_write(true);
 | 
			
		||||
    delayMicroseconds(1);
 | 
			
		||||
    delayMicroseconds(this->step_delay_);
 | 
			
		||||
    this->inc_pin_->digital_write(false);
 | 
			
		||||
    delayMicroseconds(1);
 | 
			
		||||
    delayMicroseconds(this->step_delay_);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  delayMicroseconds(100);  // Let value settle
 | 
			
		||||
@@ -69,6 +69,7 @@ void X9cOutput::dump_config() {
 | 
			
		||||
  LOG_PIN("  Increment Pin: ", this->inc_pin_);
 | 
			
		||||
  LOG_PIN("  Up/Down Pin: ", this->ud_pin_);
 | 
			
		||||
  ESP_LOGCONFIG(TAG, "  Initial Value: %f", this->initial_value_);
 | 
			
		||||
  ESP_LOGCONFIG(TAG, "  Step Delay: %d", this->step_delay_);
 | 
			
		||||
  LOG_FLOAT_OUTPUT(this);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@ class X9cOutput : public output::FloatOutput, public Component {
 | 
			
		||||
  void set_inc_pin(InternalGPIOPin *pin) { inc_pin_ = pin; }
 | 
			
		||||
  void set_ud_pin(InternalGPIOPin *pin) { ud_pin_ = pin; }
 | 
			
		||||
  void set_initial_value(float initial_value) { initial_value_ = initial_value; }
 | 
			
		||||
  void set_step_delay(int step_delay) { step_delay_ = step_delay; }
 | 
			
		||||
 | 
			
		||||
  void setup() override;
 | 
			
		||||
  void dump_config() override;
 | 
			
		||||
@@ -26,6 +27,7 @@ class X9cOutput : public output::FloatOutput, public Component {
 | 
			
		||||
  InternalGPIOPin *ud_pin_;
 | 
			
		||||
  float initial_value_;
 | 
			
		||||
  float pot_value_;
 | 
			
		||||
  int step_delay_;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}  // namespace x9c
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
"""Constants used by esphome."""
 | 
			
		||||
 | 
			
		||||
__version__ = "2024.6.0b1"
 | 
			
		||||
__version__ = "2024.6.0b4"
 | 
			
		||||
 | 
			
		||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
 | 
			
		||||
VALID_SUBSTITUTIONS_CHARACTERS = (
 | 
			
		||||
@@ -784,6 +784,7 @@ CONF_STATIC_IP = "static_ip"
 | 
			
		||||
CONF_STATUS = "status"
 | 
			
		||||
CONF_STB_PIN = "stb_pin"
 | 
			
		||||
CONF_STEP = "step"
 | 
			
		||||
CONF_STEP_DELAY = "step_delay"
 | 
			
		||||
CONF_STEP_MODE = "step_mode"
 | 
			
		||||
CONF_STEP_PIN = "step_pin"
 | 
			
		||||
CONF_STOP = "stop"
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ pyserial==3.5
 | 
			
		||||
platformio==6.1.15  # When updating platformio, also update Dockerfile
 | 
			
		||||
esptool==4.7.0
 | 
			
		||||
click==8.1.7
 | 
			
		||||
esphome-dashboard==20240429.1
 | 
			
		||||
esphome-dashboard==20240613.0
 | 
			
		||||
aioesphomeapi==24.3.0
 | 
			
		||||
zeroconf==0.132.2
 | 
			
		||||
python-magic==0.4.27
 | 
			
		||||
 
 | 
			
		||||
@@ -5,3 +5,4 @@ output:
 | 
			
		||||
    inc_pin: 4
 | 
			
		||||
    ud_pin: 5
 | 
			
		||||
    initial_value: 0.5
 | 
			
		||||
    step_delay: 50
 | 
			
		||||
 
 | 
			
		||||
@@ -5,3 +5,4 @@ output:
 | 
			
		||||
    inc_pin: 4
 | 
			
		||||
    ud_pin: 5
 | 
			
		||||
    initial_value: 0.5
 | 
			
		||||
    step_delay: 50
 | 
			
		||||
 
 | 
			
		||||
@@ -5,3 +5,4 @@ output:
 | 
			
		||||
    inc_pin: 14
 | 
			
		||||
    ud_pin: 15
 | 
			
		||||
    initial_value: 0.5
 | 
			
		||||
    step_delay: 50
 | 
			
		||||
 
 | 
			
		||||
@@ -5,3 +5,4 @@ output:
 | 
			
		||||
    inc_pin: 14
 | 
			
		||||
    ud_pin: 15
 | 
			
		||||
    initial_value: 0.5
 | 
			
		||||
    step_delay: 50
 | 
			
		||||
 
 | 
			
		||||
@@ -5,3 +5,4 @@ output:
 | 
			
		||||
    inc_pin: 14
 | 
			
		||||
    ud_pin: 15
 | 
			
		||||
    initial_value: 0.5
 | 
			
		||||
    step_delay: 50
 | 
			
		||||
 
 | 
			
		||||
@@ -5,3 +5,4 @@ output:
 | 
			
		||||
    inc_pin: 4
 | 
			
		||||
    ud_pin: 5
 | 
			
		||||
    initial_value: 0.5
 | 
			
		||||
    step_delay: 50
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user