mirror of
https://github.com/esphome/esphome.git
synced 2025-11-03 00:21:56 +00:00
Compare commits
49 Commits
2024.6.0b1
...
2024.6.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04225d5717 | ||
|
|
86791422f0 | ||
|
|
9c2af6318c | ||
|
|
c747d7d45d | ||
|
|
bbd7c9cf86 | ||
|
|
169fb79c97 | ||
|
|
1579dfeb80 | ||
|
|
d8a6d8594a | ||
|
|
7be071a0e9 | ||
|
|
0262a99274 | ||
|
|
09a947beaa | ||
|
|
a6e1ef2dd1 | ||
|
|
c5aae8ee25 | ||
|
|
5bd5b777a6 | ||
|
|
e39961f7f1 | ||
|
|
0d3cf5cb78 | ||
|
|
96d63de292 | ||
|
|
ae2962259e | ||
|
|
7dbc20b776 | ||
|
|
a21dab334c | ||
|
|
1863523cfd | ||
|
|
a7a9eb6f71 | ||
|
|
c868dae44a | ||
|
|
ad8cf69897 | ||
|
|
0fe18a6144 | ||
|
|
a6d1aa91de | ||
|
|
9747811b82 | ||
|
|
ff803aa108 | ||
|
|
8bac82f804 | ||
|
|
6682451ee0 | ||
|
|
c17090c1e5 | ||
|
|
acf69bb56f | ||
|
|
fd7a212562 | ||
|
|
c053a33fe8 | ||
|
|
ff07637dfd | ||
|
|
43b5c2deb7 | ||
|
|
d27e7b3b70 | ||
|
|
5dec62bf1e | ||
|
|
cfe28ce7a3 | ||
|
|
25a3db1637 | ||
|
|
65638bf614 | ||
|
|
1e66241b26 | ||
|
|
eb50f0eafd | ||
|
|
4e8a7986cd | ||
|
|
3db71b98ae | ||
|
|
73cb3ec852 | ||
|
|
91e72fe121 | ||
|
|
be486e0ca6 | ||
|
|
fdefc825bb |
4
.github/actions/build-image/action.yaml
vendored
4
.github/actions/build-image/action.yaml
vendored
@@ -46,7 +46,7 @@ runs:
|
||||
|
||||
- name: Build and push to ghcr by digest
|
||||
id: build-ghcr
|
||||
uses: docker/build-push-action@v5.4.0
|
||||
uses: docker/build-push-action@v6.0.1
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/Dockerfile
|
||||
@@ -69,7 +69,7 @@ runs:
|
||||
|
||||
- name: Build and push to dockerhub by digest
|
||||
id: build-dockerhub
|
||||
uses: docker/build-push-action@v5.4.0
|
||||
uses: docker/build-push-action@v6.0.1
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/Dockerfile
|
||||
|
||||
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
|
||||
|
||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -65,7 +65,7 @@ jobs:
|
||||
pip3 install build
|
||||
python3 -m build
|
||||
- name: Publish
|
||||
uses: pypa/gh-action-pypi-publish@v1.8.14
|
||||
uses: pypa/gh-action-pypi-publish@v1.9.0
|
||||
|
||||
deploy-docker:
|
||||
name: Build ESPHome ${{ matrix.platform }}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -60,6 +60,7 @@ from esphome.cpp_types import ( # noqa
|
||||
std_ns,
|
||||
std_shared_ptr,
|
||||
std_string,
|
||||
std_string_ref,
|
||||
std_vector,
|
||||
uint8,
|
||||
uint16,
|
||||
|
||||
@@ -145,24 +145,21 @@ bool DallasTemperatureSensor::check_scratch_pad_() {
|
||||
float DallasTemperatureSensor::get_temp_c_() {
|
||||
int16_t temp = (this->scratch_pad_[1] << 8) | this->scratch_pad_[0];
|
||||
if ((this->address_ & 0xff) == DALLAS_MODEL_DS18S20) {
|
||||
if (this->scratch_pad_[7] != 0x10)
|
||||
ESP_LOGE(TAG, "unexpected COUNT_PER_C value: %u", this->scratch_pad_[7]);
|
||||
temp = ((temp & 0xfff7) << 3) + (0x10 - this->scratch_pad_[6]) - 4;
|
||||
} else {
|
||||
switch (this->resolution_) {
|
||||
case 9:
|
||||
temp &= 0xfff8;
|
||||
break;
|
||||
case 10:
|
||||
temp &= 0xfffc;
|
||||
break;
|
||||
case 11:
|
||||
temp &= 0xfffe;
|
||||
break;
|
||||
case 12:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (temp >> 1) + (this->scratch_pad_[7] - this->scratch_pad_[6]) / float(this->scratch_pad_[7]) - 0.25;
|
||||
}
|
||||
switch (this->resolution_) {
|
||||
case 9:
|
||||
temp &= 0xfff8;
|
||||
break;
|
||||
case 10:
|
||||
temp &= 0xfffc;
|
||||
break;
|
||||
case 11:
|
||||
temp &= 0xfffe;
|
||||
break;
|
||||
case 12:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return temp / 16.0f;
|
||||
|
||||
@@ -12,7 +12,7 @@ std::string DebugComponent::get_reset_reason_() { return lt_get_reboot_reason_na
|
||||
uint32_t DebugComponent::get_free_heap_() { return lt_heap_get_free(); }
|
||||
|
||||
void DebugComponent::get_device_info_(std::string &device_info) {
|
||||
str::string reset_reason = get_reset_reason_();
|
||||
std::string reset_reason = get_reset_reason_();
|
||||
ESP_LOGD(TAG, "LibreTiny Version: %s", lt_get_version());
|
||||
ESP_LOGD(TAG, "Chip: %s (%04x) @ %u MHz", lt_cpu_get_model_name(), lt_cpu_get_model(), lt_cpu_get_freq_mhz());
|
||||
ESP_LOGD(TAG, "Chip ID: 0x%06X", lt_cpu_get_mac_id());
|
||||
|
||||
@@ -37,14 +37,18 @@ void DS1307Component::read_time() {
|
||||
ESP_LOGW(TAG, "RTC halted, not syncing to system clock.");
|
||||
return;
|
||||
}
|
||||
ESPTime rtc_time{.second = uint8_t(ds1307_.reg.second + 10 * ds1307_.reg.second_10),
|
||||
.minute = uint8_t(ds1307_.reg.minute + 10u * ds1307_.reg.minute_10),
|
||||
.hour = uint8_t(ds1307_.reg.hour + 10u * ds1307_.reg.hour_10),
|
||||
.day_of_week = uint8_t(ds1307_.reg.weekday),
|
||||
.day_of_month = uint8_t(ds1307_.reg.day + 10u * ds1307_.reg.day_10),
|
||||
.day_of_year = 1, // ignored by recalc_timestamp_utc(false)
|
||||
.month = uint8_t(ds1307_.reg.month + 10u * ds1307_.reg.month_10),
|
||||
.year = uint16_t(ds1307_.reg.year + 10u * ds1307_.reg.year_10 + 2000)};
|
||||
ESPTime rtc_time{
|
||||
.second = uint8_t(ds1307_.reg.second + 10 * ds1307_.reg.second_10),
|
||||
.minute = uint8_t(ds1307_.reg.minute + 10u * ds1307_.reg.minute_10),
|
||||
.hour = uint8_t(ds1307_.reg.hour + 10u * ds1307_.reg.hour_10),
|
||||
.day_of_week = uint8_t(ds1307_.reg.weekday),
|
||||
.day_of_month = uint8_t(ds1307_.reg.day + 10u * ds1307_.reg.day_10),
|
||||
.day_of_year = 1, // ignored by recalc_timestamp_utc(false)
|
||||
.month = uint8_t(ds1307_.reg.month + 10u * ds1307_.reg.month_10),
|
||||
.year = uint16_t(ds1307_.reg.year + 10u * ds1307_.reg.year_10 + 2000),
|
||||
.is_dst = false, // not used
|
||||
.timestamp = 0 // overwritten by recalc_timestamp_utc(false)
|
||||
};
|
||||
rtc_time.recalc_timestamp_utc(false);
|
||||
if (!rtc_time.is_valid()) {
|
||||
ESP_LOGE(TAG, "Invalid RTC time, not syncing to system clock.");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
import esphome.final_validate as fv
|
||||
from esphome.components.ota import BASE_OTA_SCHEMA, ota_to_code, OTAComponent
|
||||
from esphome.const import (
|
||||
CONF_ESPHOME,
|
||||
CONF_ID,
|
||||
CONF_NUM_ATTEMPTS,
|
||||
CONF_OTA,
|
||||
CONF_PASSWORD,
|
||||
CONF_PLATFORM,
|
||||
CONF_PORT,
|
||||
CONF_REBOOT_TIMEOUT,
|
||||
CONF_SAFE_MODE,
|
||||
@@ -21,6 +25,19 @@ esphome = cg.esphome_ns.namespace("esphome")
|
||||
ESPHomeOTAComponent = esphome.class_("ESPHomeOTAComponent", OTAComponent)
|
||||
|
||||
|
||||
def ota_esphome_final_validate(config):
|
||||
fconf = fv.full_config.get()[CONF_OTA]
|
||||
used_ports = []
|
||||
for ota_conf in fconf:
|
||||
if ota_conf.get(CONF_PLATFORM) == CONF_ESPHOME:
|
||||
if (plat_port := ota_conf.get(CONF_PORT)) not in used_ports:
|
||||
used_ports.append(plat_port)
|
||||
else:
|
||||
raise cv.Invalid(
|
||||
f"Only one instance of the {CONF_ESPHOME} {CONF_OTA} {CONF_PLATFORM} is allowed per port. Note that this error may result from OTA specified in packages"
|
||||
)
|
||||
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
{
|
||||
@@ -50,6 +67,8 @@ CONFIG_SCHEMA = (
|
||||
.extend(cv.COMPONENT_SCHEMA)
|
||||
)
|
||||
|
||||
FINAL_VALIDATE_SCHEMA = ota_esphome_final_validate
|
||||
|
||||
|
||||
@coroutine_with_priority(52.0)
|
||||
async def to_code(config):
|
||||
|
||||
@@ -9,6 +9,10 @@ static const char *const TAG = "gpio.one_wire";
|
||||
|
||||
void GPIOOneWireBus::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up 1-wire bus...");
|
||||
this->t_pin_->setup();
|
||||
// clear bus with 480µs high, otherwise initial reset in search might fail
|
||||
this->t_pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP);
|
||||
delayMicroseconds(480);
|
||||
this->search();
|
||||
}
|
||||
|
||||
@@ -60,7 +64,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);
|
||||
@@ -90,13 +94,15 @@ bool HOT IRAM_ATTR GPIOOneWireBus::read_bit_() {
|
||||
|
||||
// measure from start value directly, to get best accurate timing no matter
|
||||
// how long pin_mode/delayMicroseconds took
|
||||
delayMicroseconds(12 - (micros() - start));
|
||||
uint32_t now = micros();
|
||||
if (now - start < 12)
|
||||
delayMicroseconds(12 - (now - start));
|
||||
|
||||
// sample bus to read bit from peer
|
||||
bool r = pin_.digital_read();
|
||||
|
||||
// read slot is at least 60µs; get as close to 60µs to spend less time with interrupts locked
|
||||
uint32_t now = micros();
|
||||
now = micros();
|
||||
if (now - start < 60)
|
||||
delayMicroseconds(60 - (now - start));
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ async def http_request_action_to_code(config, action_id, template_arg, args):
|
||||
trigger,
|
||||
[
|
||||
(cg.std_shared_ptr.template(HttpContainer), "response"),
|
||||
(cg.std_string, "body"),
|
||||
(cg.std_string_ref, "body"),
|
||||
],
|
||||
conf,
|
||||
)
|
||||
|
||||
@@ -43,10 +43,10 @@ class HttpContainer : public Parented<HttpRequestComponent> {
|
||||
bool secure_{false};
|
||||
};
|
||||
|
||||
class HttpRequestResponseTrigger : public Trigger<std::shared_ptr<HttpContainer>, std::string> {
|
||||
class HttpRequestResponseTrigger : public Trigger<std::shared_ptr<HttpContainer>, std::string &> {
|
||||
public:
|
||||
void process(std::shared_ptr<HttpContainer> container, std::string response_body) {
|
||||
this->trigger(std::move(container), std::move(response_body));
|
||||
void process(std::shared_ptr<HttpContainer> container, std::string &response_body) {
|
||||
this->trigger(std::move(container), response_body);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -149,11 +149,21 @@ template<typename... Ts> class HttpRequestSendAction : public Action<Ts...> {
|
||||
}
|
||||
response_body.reserve(read_index);
|
||||
response_body.assign((char *) buf, read_index);
|
||||
allocator.deallocate(buf, max_length);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto *trigger : this->response_triggers_) {
|
||||
trigger->process(container, response_body);
|
||||
if (this->response_triggers_.size() == 1) {
|
||||
// if there is only one trigger, no need to copy the response body
|
||||
this->response_triggers_[0]->process(container, response_body);
|
||||
} else {
|
||||
for (auto *trigger : this->response_triggers_) {
|
||||
// with multiple triggers, pass a copy of the response body to each
|
||||
// one so that modifications made in one trigger are not visible to
|
||||
// the others
|
||||
auto response_body_copy = std::string(response_body);
|
||||
trigger->process(container, response_body_copy);
|
||||
}
|
||||
}
|
||||
container->end();
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
|
||||
int write_left = body_len;
|
||||
int write_index = 0;
|
||||
const char *buf = body.c_str();
|
||||
while (body_len > 0) {
|
||||
while (write_left > 0) {
|
||||
int written = esp_http_client_write(client, buf + write_index, write_left);
|
||||
if (written < 0) {
|
||||
err = ESP_FAIL;
|
||||
|
||||
@@ -46,7 +46,7 @@ void WatchdogManager::set_timeout_(uint32_t timeout_ms) {
|
||||
};
|
||||
esp_task_wdt_reconfigure(&wdt_config);
|
||||
#else
|
||||
esp_task_wdt_init(timeout_ms, true);
|
||||
esp_task_wdt_init(timeout_ms / 1000, true);
|
||||
#endif // ESP_IDF_VERSION_MAJOR
|
||||
#endif // USE_ESP32
|
||||
|
||||
|
||||
@@ -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 --------------
|
||||
|
||||
@@ -293,4 +293,4 @@ async def to_code(config):
|
||||
if CONF_HUMIDITY_SETPOINT in config:
|
||||
sens = await sensor.new_sensor(config[CONF_HUMIDITY_SETPOINT])
|
||||
cg.add(var.set_humidity_setpoint_sensor(sens))
|
||||
cg.add_library("dudanov/MideaUART", "1.1.8")
|
||||
cg.add_library("dudanov/MideaUART", "1.1.9")
|
||||
|
||||
@@ -116,7 +116,8 @@ void ModbusController::on_modbus_read_registers(uint8_t function_code, uint16_t
|
||||
ESP_LOGD(TAG, "Matched register. Address: 0x%02X. Value type: %zu. Register count: %u. Value: %0.1f.",
|
||||
server_register->address, static_cast<uint8_t>(server_register->value_type),
|
||||
server_register->register_count, value);
|
||||
number_to_payload(sixteen_bit_response, value, server_register->value_type);
|
||||
std::vector<uint16_t> payload = float_to_payload(value, server_register->value_type);
|
||||
sixteen_bit_response.insert(sixteen_bit_response.end(), payload.cbegin(), payload.cend());
|
||||
current_address += server_register->register_count;
|
||||
found = true;
|
||||
break;
|
||||
|
||||
@@ -15,7 +15,7 @@ void ModbusTextSensor::parse_and_publish(const std::vector<uint8_t> &data) {
|
||||
std::ostringstream output;
|
||||
uint8_t items_left = this->response_bytes;
|
||||
uint8_t index = this->offset;
|
||||
char buffer[4];
|
||||
char buffer[5];
|
||||
while ((items_left > 0) && index < data.size()) {
|
||||
uint8_t b = data[index];
|
||||
switch (this->encode_) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -19,7 +19,12 @@ IPAddress = network_ns.class_("IPAddress")
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.SplitDefault(CONF_ENABLE_IPV6): cv.All(
|
||||
cv.SplitDefault(
|
||||
CONF_ENABLE_IPV6,
|
||||
esp8266=False,
|
||||
esp32=False,
|
||||
rp2040=False,
|
||||
): cv.All(
|
||||
cv.boolean, cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_RP2040])
|
||||
),
|
||||
cv.Optional(CONF_MIN_IPV6_ADDR_COUNT, default=0): cv.positive_int,
|
||||
@@ -28,18 +33,17 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
if CONF_ENABLE_IPV6 in config:
|
||||
cg.add_define("USE_NETWORK_IPV6", config[CONF_ENABLE_IPV6])
|
||||
cg.add_define(
|
||||
"USE_NETWORK_MIN_IPV6_ADDR_COUNT", config[CONF_MIN_IPV6_ADDR_COUNT]
|
||||
)
|
||||
if CORE.using_esp_idf:
|
||||
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", config[CONF_ENABLE_IPV6])
|
||||
add_idf_sdkconfig_option(
|
||||
"CONFIG_LWIP_IPV6_AUTOCONFIG", config[CONF_ENABLE_IPV6]
|
||||
if (enable_ipv6 := config.get(CONF_ENABLE_IPV6, None)) is not None:
|
||||
cg.add_define("USE_NETWORK_IPV6", enable_ipv6)
|
||||
if enable_ipv6:
|
||||
cg.add_define(
|
||||
"USE_NETWORK_MIN_IPV6_ADDR_COUNT", config[CONF_MIN_IPV6_ADDR_COUNT]
|
||||
)
|
||||
if CORE.using_esp_idf:
|
||||
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", enable_ipv6)
|
||||
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", enable_ipv6)
|
||||
else:
|
||||
if config[CONF_ENABLE_IPV6]:
|
||||
if enable_ipv6:
|
||||
cg.add_build_flag("-DCONFIG_LWIP_IPV6")
|
||||
cg.add_build_flag("-DCONFIG_LWIP_IPV6_AUTOCONFIG")
|
||||
if CORE.is_rp2040:
|
||||
|
||||
@@ -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
|
||||
@@ -56,21 +56,20 @@ CONFIG_SCHEMA = cv.All(
|
||||
|
||||
@coroutine_with_priority(50.0)
|
||||
async def to_code(config):
|
||||
if config[CONF_DISABLED]:
|
||||
return
|
||||
if not config[CONF_DISABLED]:
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
for conf in config.get(CONF_ON_SAFE_MODE, []):
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||
await automation.build_automation(trigger, [], conf)
|
||||
|
||||
for conf in config.get(CONF_ON_SAFE_MODE, []):
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||
await automation.build_automation(trigger, [], conf)
|
||||
condition = var.should_enter_safe_mode(
|
||||
config[CONF_NUM_ATTEMPTS],
|
||||
config[CONF_REBOOT_TIMEOUT],
|
||||
config[CONF_BOOT_IS_GOOD_AFTER],
|
||||
)
|
||||
cg.add(RawExpression(f"if ({condition}) return"))
|
||||
|
||||
condition = var.should_enter_safe_mode(
|
||||
config[CONF_NUM_ATTEMPTS],
|
||||
config[CONF_REBOOT_TIMEOUT],
|
||||
config[CONF_BOOT_IS_GOOD_AFTER],
|
||||
)
|
||||
cg.add(RawExpression(f"if ({condition}) return"))
|
||||
CORE.data[CONF_SAFE_MODE] = {}
|
||||
CORE.data[CONF_SAFE_MODE][KEY_PAST_SAFE_MODE] = True
|
||||
|
||||
@@ -4,10 +4,13 @@ import esphome.config_validation as cv
|
||||
import esphome.codegen as cg
|
||||
from esphome.const import (
|
||||
CONF_DEVICE_CLASS,
|
||||
CONF_ENTITY_CATEGORY,
|
||||
CONF_ID,
|
||||
CONF_MQTT_ID,
|
||||
CONF_WEB_SERVER_ID,
|
||||
DEVICE_CLASS_EMPTY,
|
||||
DEVICE_CLASS_FIRMWARE,
|
||||
ENTITY_CATEGORY_CONFIG,
|
||||
)
|
||||
from esphome.core import CORE, coroutine_with_priority
|
||||
from esphome.cpp_helpers import setup_entity
|
||||
@@ -24,6 +27,7 @@ PerformAction = update_ns.class_("PerformAction", automation.Action)
|
||||
IsAvailableCondition = update_ns.class_("IsAvailableCondition", automation.Condition)
|
||||
|
||||
DEVICE_CLASSES = [
|
||||
DEVICE_CLASS_EMPTY,
|
||||
DEVICE_CLASS_FIRMWARE,
|
||||
]
|
||||
|
||||
@@ -39,6 +43,9 @@ UPDATE_SCHEMA = (
|
||||
cv.Optional(CONF_ON_UPDATE_AVAILABLE): automation.validate_automation(
|
||||
single=True
|
||||
),
|
||||
cv.Optional(
|
||||
CONF_ENTITY_CATEGORY, default=ENTITY_CATEGORY_CONFIG
|
||||
): cv.entity_category,
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -62,7 +69,7 @@ async def setup_update_core_(var, config):
|
||||
await mqtt.register_mqtt_component(mqtt_, config)
|
||||
|
||||
if web_server_id_config := config.get(CONF_WEB_SERVER_ID):
|
||||
web_server_ = cg.get_variable(web_server_id_config)
|
||||
web_server_ = await cg.get_variable(web_server_id_config)
|
||||
web_server.add_entity_to_sorting_list(web_server_, var, config)
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,35 @@
|
||||
#include "update_entity.h"
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace update {
|
||||
|
||||
static const char *const TAG = "update";
|
||||
|
||||
void UpdateEntity::publish_state() {
|
||||
ESP_LOGD(TAG, "'%s' - Publishing:", this->name_.c_str());
|
||||
ESP_LOGD(TAG, " Current Version: %s", this->update_info_.current_version.c_str());
|
||||
|
||||
if (!this->update_info_.md5.empty()) {
|
||||
ESP_LOGD(TAG, " Latest Version: %s", this->update_info_.latest_version.c_str());
|
||||
}
|
||||
if (!this->update_info_.firmware_url.empty()) {
|
||||
ESP_LOGD(TAG, " Firmware URL: %s", this->update_info_.firmware_url.c_str());
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, " Title: %s", this->update_info_.title.c_str());
|
||||
if (!this->update_info_.summary.empty()) {
|
||||
ESP_LOGD(TAG, " Summary: %s", this->update_info_.summary.c_str());
|
||||
}
|
||||
if (!this->update_info_.release_url.empty()) {
|
||||
ESP_LOGD(TAG, " Release URL: %s", this->update_info_.release_url.c_str());
|
||||
}
|
||||
|
||||
if (this->update_info_.has_progress) {
|
||||
ESP_LOGD(TAG, " Progress: %.0f%%", this->update_info_.progress);
|
||||
}
|
||||
|
||||
this->has_state_ = true;
|
||||
this->state_callback_.call();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -58,17 +58,21 @@ def merge_config(full_old, full_new):
|
||||
ids = {
|
||||
v_id: i
|
||||
for i, v in enumerate(res)
|
||||
if (v_id := v.get(CONF_ID)) and isinstance(v_id, str)
|
||||
if isinstance(v, dict)
|
||||
and (v_id := v.get(CONF_ID))
|
||||
and isinstance(v_id, str)
|
||||
}
|
||||
extend_ids = {
|
||||
v_id.value: i
|
||||
for i, v in enumerate(res)
|
||||
if (v_id := v.get(CONF_ID)) and isinstance(v_id, Extend)
|
||||
if isinstance(v, dict)
|
||||
and (v_id := v.get(CONF_ID))
|
||||
and isinstance(v_id, Extend)
|
||||
}
|
||||
|
||||
ids_to_delete = []
|
||||
for v in new:
|
||||
if new_id := v.get(CONF_ID):
|
||||
if isinstance(v, dict) and (new_id := v.get(CONF_ID)):
|
||||
if isinstance(new_id, Extend):
|
||||
new_id = new_id.value
|
||||
if new_id in ids:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2024.6.0b1"
|
||||
__version__ = "2024.6.3"
|
||||
|
||||
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"
|
||||
|
||||
@@ -10,6 +10,7 @@ int_ = global_ns.namespace("int")
|
||||
std_ns = global_ns.namespace("std")
|
||||
std_shared_ptr = std_ns.class_("shared_ptr")
|
||||
std_string = std_ns.class_("string")
|
||||
std_string_ref = std_ns.namespace("string &")
|
||||
std_vector = std_ns.class_("vector")
|
||||
uint8 = global_ns.namespace("uint8_t")
|
||||
uint16 = global_ns.namespace("uint16_t")
|
||||
|
||||
@@ -64,7 +64,7 @@ lib_deps =
|
||||
freekode/TM1651@1.0.1 ; tm1651
|
||||
glmnet/Dsmr@0.7 ; dsmr
|
||||
rweather/Crypto@0.4.0 ; dsmr
|
||||
dudanov/MideaUART@1.1.8 ; midea
|
||||
dudanov/MideaUART@1.1.9 ; midea
|
||||
tonia/HeatpumpIR@1.0.23 ; heatpumpir
|
||||
build_flags =
|
||||
${common.build_flags}
|
||||
|
||||
@@ -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==20240620.0
|
||||
aioesphomeapi==24.3.0
|
||||
zeroconf==0.132.2
|
||||
python-magic==0.4.27
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
substitutions:
|
||||
network_enable_ipv6: "false"
|
||||
|
||||
wifi:
|
||||
ssid: MySSID
|
||||
password: password1
|
||||
|
||||
network:
|
||||
enable_ipv6: true
|
||||
enable_ipv6: ${network_enable_ipv6}
|
||||
|
||||
4
tests/components/network/test-ipv6.esp32-ard.yaml
Normal file
4
tests/components/network/test-ipv6.esp32-ard.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
substitutions:
|
||||
network_enable_ipv6: "true"
|
||||
|
||||
<<: !include common.yaml
|
||||
4
tests/components/network/test-ipv6.esp32-c3-ard.yaml
Normal file
4
tests/components/network/test-ipv6.esp32-c3-ard.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
substitutions:
|
||||
network_enable_ipv6: "true"
|
||||
|
||||
<<: !include common.yaml
|
||||
4
tests/components/network/test-ipv6.esp32-c3-idf.yaml
Normal file
4
tests/components/network/test-ipv6.esp32-c3-idf.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
substitutions:
|
||||
network_enable_ipv6: "true"
|
||||
|
||||
<<: !include common.yaml
|
||||
4
tests/components/network/test-ipv6.esp32-idf.yaml
Normal file
4
tests/components/network/test-ipv6.esp32-idf.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
substitutions:
|
||||
network_enable_ipv6: "true"
|
||||
|
||||
<<: !include common.yaml
|
||||
4
tests/components/network/test-ipv6.esp8266.yaml
Normal file
4
tests/components/network/test-ipv6.esp8266.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
substitutions:
|
||||
network_enable_ipv6: "true"
|
||||
|
||||
<<: !include common.yaml
|
||||
4
tests/components/network/test-ipv6.rp2040.yaml
Normal file
4
tests/components/network/test-ipv6.rp2040.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
substitutions:
|
||||
network_enable_ipv6: "true"
|
||||
|
||||
<<: !include common.yaml
|
||||
1
tests/components/network/test.host.yaml
Normal file
1
tests/components/network/test.host.yaml
Normal file
@@ -0,0 +1 @@
|
||||
network:
|
||||
@@ -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