1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-03 16:41:50 +00:00

Compare commits

..

18 Commits

Author SHA1 Message Date
Jesse Hills
e5c9e87fad Merge pull request #2890 from esphome/bump-2021.12.0b4
2021.12.0b4
2021-12-10 09:50:29 +13:00
Jesse Hills
f3d9d707b6 Bump version to 2021.12.0b4 2021-12-08 12:58:14 +13:00
Jesse Hills
090e10730c Bump esphome-dashboard to 20211208.0 (#2887) 2021-12-08 12:58:14 +13:00
Jesse Hills
fbc84861c7 Use new platform component config blocks for wizard (#2885) 2021-12-08 12:58:14 +13:00
Carlos Garcia Saura
e763469af8 Feed watchdog while setting up OTA (#2876) 2021-12-08 12:58:14 +13:00
Jesse Hills
3c0c514e44 Merge pull request #2880 from esphome/bump-2021.12.0b3
2021.12.0b3
2021-12-07 15:27:08 +13:00
Jesse Hills
ed5e2dd332 Bump version to 2021.12.0b3 2021-12-07 07:47:48 +13:00
Jesse Hills
09b7c6f550 Bump esphome-dashboard to 20211207.0 (#2877) 2021-12-07 07:47:48 +13:00
Oxan van Leeuwen
df315a1f51 Feed watchdog when no component loops (#2857) 2021-12-07 07:47:48 +13:00
Jesse Hills
7ee4bb621c Allow wizard to specify secrets (#2875) 2021-12-07 07:47:48 +13:00
Jesse Hills
24874f4c3c Adopt using wifi secrets that should exist at this point (#2874) 2021-12-07 07:47:48 +13:00
Jesse Hills
c128880033 Add endpoint to fetch secrets keys (#2873) 2021-12-07 07:47:48 +13:00
Massimiliano Ravelli
a66e94a0b0 Ignore already stopped dhcp for ethernet (#2862)
Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2021-12-07 07:47:48 +13:00
Oxan van Leeuwen
56870ed4a8 Fix MCP23x17 not disabling pullup after config change (#2855) 2021-12-07 07:47:48 +13:00
Martin
3ac720df47 SPS30 : fix i2c read size (#2866) 2021-12-07 07:47:48 +13:00
Carlos Garcia Saura
1bc757ad06 ADC: Turn verbose the debugging "got voltage" (#2863) 2021-12-07 07:47:48 +13:00
Martin
f72abc6f3d tlc59208f : fix compilation error (#2867) 2021-12-07 07:47:48 +13:00
Jesse Hills
5ac88de985 Bump esphome-dashboard to 20211206.0 (#2870) 2021-12-07 07:47:48 +13:00
15 changed files with 98 additions and 37 deletions

View File

@@ -91,7 +91,7 @@ void ADCSensor::dump_config() {
float ADCSensor::get_setup_priority() const { return setup_priority::DATA; }
void ADCSensor::update() {
float value_v = this->sample();
ESP_LOGD(TAG, "'%s': Got voltage=%.4fV", this->get_name().c_str(), value_v);
ESP_LOGV(TAG, "'%s': Got voltage=%.4fV", this->get_name().c_str(), value_v);
this->publish_state(value_v);
}

View File

@@ -29,12 +29,11 @@ CONFIG_SCHEMA = cv.Schema(
}
)
WIFI_MESSAGE = """
WIFI_CONFIG = """
# Do not forget to add your own wifi configuration before installing this configuration
# wifi:
# ssid: !secret wifi_ssid
# password: !secret wifi_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
"""
@@ -55,6 +54,6 @@ def import_config(path: str, name: str, project_name: str, import_url: str) -> N
"esphome": {"name_add_mac_suffix": False},
}
p.write_text(
dump(config) + WIFI_MESSAGE,
dump(config) + WIFI_CONFIG,
encoding="utf8",
)

View File

@@ -184,7 +184,9 @@ void EthernetComponent::start_connect_() {
}
err = tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH);
ESPHL_ERROR_CHECK(err, "DHCPC stop error");
if (err != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED) {
ESPHL_ERROR_CHECK(err, "DHCPC stop error");
}
err = tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_ETH, &info);
ESPHL_ERROR_CHECK(err, "DHCPC set IP info error");

View File

@@ -24,6 +24,7 @@ void MCP23X17Base::pin_mode(uint8_t pin, gpio::Flags flags) {
uint8_t gppu = pin < 8 ? mcp23x17_base::MCP23X17_GPPUA : mcp23x17_base::MCP23X17_GPPUB;
if (flags == gpio::FLAG_INPUT) {
this->update_reg(pin, true, iodir);
this->update_reg(pin, false, gppu);
} else if (flags == (gpio::FLAG_INPUT | gpio::FLAG_PULLUP)) {
this->update_reg(pin, true, iodir);
this->update_reg(pin, true, gppu);

View File

@@ -372,6 +372,7 @@ bool OTAComponent::readall_(uint8_t *buf, size_t len) {
ssize_t read = this->client_->read(buf + at, len - at);
if (read == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
App.feed_wdt();
delay(1);
continue;
}
@@ -383,6 +384,7 @@ bool OTAComponent::readall_(uint8_t *buf, size_t len) {
} else {
at += read;
}
App.feed_wdt();
delay(1);
}
@@ -401,6 +403,7 @@ bool OTAComponent::writeall_(const uint8_t *buf, size_t len) {
ssize_t written = this->client_->write(buf + at, len - at);
if (written == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
App.feed_wdt();
delay(1);
continue;
}
@@ -409,6 +412,7 @@ bool OTAComponent::writeall_(const uint8_t *buf, size_t len) {
} else {
at += written;
}
App.feed_wdt();
delay(1);
}
return true;

View File

@@ -32,14 +32,11 @@ void SPS30Component::setup() {
return;
}
uint16_t raw_firmware_version[4];
if (!this->read_data_(raw_firmware_version, 4)) {
if (!this->read_data_(&raw_firmware_version_, 1)) {
this->error_code_ = FIRMWARE_VERSION_READ_FAILED;
this->mark_failed();
return;
}
ESP_LOGD(TAG, " Firmware version v%0d.%02d", (raw_firmware_version[0] >> 8),
uint16_t(raw_firmware_version[0] & 0xFF));
/// Serial number identification
if (!this->write_command_(SPS30_CMD_GET_SERIAL_NUMBER)) {
this->error_code_ = SERIAL_NUMBER_REQUEST_FAILED;
@@ -59,6 +56,8 @@ void SPS30Component::setup() {
this->serial_number_[i * 2 + 1] = uint16_t(uint16_t(raw_serial_number[i] & 0xFF));
}
ESP_LOGD(TAG, " Serial Number: '%s'", this->serial_number_);
this->status_clear_warning();
this->skipped_data_read_cycles_ = 0;
this->start_continuous_measurement_();
});
}
@@ -93,10 +92,17 @@ void SPS30Component::dump_config() {
}
LOG_UPDATE_INTERVAL(this);
ESP_LOGCONFIG(TAG, " Serial Number: '%s'", this->serial_number_);
LOG_SENSOR(" ", "PM1.0", this->pm_1_0_sensor_);
LOG_SENSOR(" ", "PM2.5", this->pm_2_5_sensor_);
LOG_SENSOR(" ", "PM4", this->pm_4_0_sensor_);
LOG_SENSOR(" ", "PM10", this->pm_10_0_sensor_);
ESP_LOGCONFIG(TAG, " Firmware version v%0d.%0d", (raw_firmware_version_ >> 8),
uint16_t(raw_firmware_version_ & 0xFF));
LOG_SENSOR(" ", "PM1.0 Weight Concentration", this->pm_1_0_sensor_);
LOG_SENSOR(" ", "PM2.5 Weight Concentration", this->pm_2_5_sensor_);
LOG_SENSOR(" ", "PM4 Weight Concentration", this->pm_4_0_sensor_);
LOG_SENSOR(" ", "PM10 Weight Concentration", this->pm_10_0_sensor_);
LOG_SENSOR(" ", "PM1.0 Number Concentration", this->pmc_1_0_sensor_);
LOG_SENSOR(" ", "PM2.5 Number Concentration", this->pmc_2_5_sensor_);
LOG_SENSOR(" ", "PM4 Number Concentration", this->pmc_4_0_sensor_);
LOG_SENSOR(" ", "PM10 Number Concentration", this->pmc_10_0_sensor_);
LOG_SENSOR(" ", "PM typical size", this->pm_size_sensor_);
}
void SPS30Component::update() {
@@ -123,8 +129,8 @@ void SPS30Component::update() {
return;
}
uint16_t raw_read_status[1];
if (!this->read_data_(raw_read_status, 1) || raw_read_status[0] == 0x00) {
uint16_t raw_read_status;
if (!this->read_data_(&raw_read_status, 1) || raw_read_status == 0x00) {
ESP_LOGD(TAG, "Sensor measurement not ready yet.");
this->skipped_data_read_cycles_++;
/// The following logic is required to address the cases when a sensor is quickly replaced before it's marked

View File

@@ -33,6 +33,7 @@ class SPS30Component : public PollingComponent, public i2c::I2CDevice {
bool read_data_(uint16_t *data, uint8_t len);
uint8_t sht_crc_(uint8_t data1, uint8_t data2);
char serial_number_[17] = {0}; /// Terminating NULL character
uint16_t raw_firmware_version_;
bool start_continuous_measurement_();
uint8_t skipped_data_read_cycles_ = 0;

View File

@@ -1,6 +1,7 @@
#include "tlc59208f_output.h"
#include "esphome/core/log.h"
#include "esphome/core/helpers.h"
#include "esphome/core/hal.h"
namespace esphome {
namespace tlc59208f {

View File

@@ -1,6 +1,6 @@
"""Constants used by esphome."""
__version__ = "2021.12.0b2"
__version__ = "2021.12.0b4"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"

View File

@@ -37,6 +37,7 @@ void Application::setup() {
component->call();
this->scheduler.process_to_add();
this->feed_wdt();
if (component->can_proceed())
continue;
@@ -46,14 +47,15 @@ void Application::setup() {
do {
uint32_t new_app_state = STATUS_LED_WARNING;
this->scheduler.call();
this->feed_wdt();
for (uint32_t j = 0; j <= i; j++) {
this->components_[j]->call();
new_app_state |= this->components_[j]->get_component_state();
this->app_state_ |= new_app_state;
this->feed_wdt();
}
this->app_state_ = new_app_state;
yield();
this->feed_wdt();
} while (!component->can_proceed());
}
@@ -65,6 +67,7 @@ void Application::loop() {
uint32_t new_app_state = 0;
this->scheduler.call();
this->feed_wdt();
for (Component *component : this->looping_components_) {
{
WarnIfComponentBlockingGuard guard{component};

View File

@@ -27,7 +27,7 @@ import tornado.process
import tornado.web
import tornado.websocket
from esphome import const, platformio_api, util
from esphome import const, platformio_api, util, yaml_util
from esphome.helpers import mkdir_p, get_bool_env, run_system_command
from esphome.storage_json import (
EsphomeStorageJSON,
@@ -836,6 +836,28 @@ class LogoutHandler(BaseHandler):
self.redirect("./login")
class SecretKeysRequestHandler(BaseHandler):
@authenticated
def get(self):
filename = None
for secret_filename in const.SECRETS_FILES:
relative_filename = settings.rel_path(secret_filename)
if os.path.isfile(relative_filename):
filename = relative_filename
break
if filename is None:
self.send_error(404)
return
secret_keys = list(yaml_util.load_yaml(filename, clear_secrets=False))
self.set_header("content-type", "application/json")
self.write(json.dumps(secret_keys))
def get_base_frontend_path():
if ENV_DEV not in os.environ:
import esphome_dashboard
@@ -939,6 +961,7 @@ def make_app(debug=get_bool_env(ENV_DEV)):
(f"{rel}static/(.*)", StaticFileHandler, {"path": get_static_path()}),
(f"{rel}devices", ListDevicesHandler),
(f"{rel}import", ImportRequestHandler),
(f"{rel}secret_keys", SecretKeysRequestHandler),
],
**app_settings,
)

View File

@@ -45,9 +45,9 @@ OTA_BIG = r""" ____ _______
BASE_CONFIG = """esphome:
name: {name}
platform: {platform}
board: {board}
"""
LOGGER_API_CONFIG = """
# Enable logging
logger:
@@ -55,6 +55,18 @@ logger:
api:
"""
ESP8266_CONFIG = """
esp8266:
board: {board}
"""
ESP32_CONFIG = """
esp32:
board: {board}
framework:
type: arduino
"""
def sanitize_double_quotes(value):
return value.replace("\\", "\\\\").replace('"', '\\"')
@@ -71,6 +83,14 @@ def wizard_file(**kwargs):
config = BASE_CONFIG.format(**kwargs)
config += (
ESP8266_CONFIG.format(**kwargs)
if kwargs["platform"] == "ESP8266"
else ESP32_CONFIG.format(**kwargs)
)
config += LOGGER_API_CONFIG
# Configure API
if "password" in kwargs:
config += f" password: \"{kwargs['password']}\"\n"
@@ -86,12 +106,11 @@ def wizard_file(**kwargs):
config += "\n\nwifi:\n"
if "ssid" in kwargs:
# pylint: disable=consider-using-f-string
config += """ ssid: "{ssid}"
password: "{psk}"
""".format(
**kwargs
)
if kwargs["ssid"].startswith("!secret"):
template = " ssid: {ssid}\n password: {psk}\n"
else:
template = """ ssid: "{ssid}"\n password: "{psk}"\n"""
config += template.format(**kwargs)
else:
config += """ # ssid: "My SSID"
# password: "mypassword"

View File

@@ -329,9 +329,10 @@ ESPHomeLoader.add_constructor("!lambda", ESPHomeLoader.construct_lambda)
ESPHomeLoader.add_constructor("!force", ESPHomeLoader.construct_force)
def load_yaml(fname):
_SECRET_VALUES.clear()
_SECRET_CACHE.clear()
def load_yaml(fname, clear_secrets=True):
if clear_secrets:
_SECRET_VALUES.clear()
_SECRET_CACHE.clear()
return _load_yaml_internal(fname)

View File

@@ -9,7 +9,7 @@ pyserial==3.5
platformio==5.2.2 # When updating platformio, also update Dockerfile
esptool==3.2
click==8.0.3
esphome-dashboard==20211201.0
esphome-dashboard==20211208.0
aioesphomeapi==10.6.0
zeroconf==0.36.13

View File

@@ -11,7 +11,7 @@ def default_config():
return {
"name": "test-name",
"platform": "test_platform",
"board": "test_board",
"board": "esp01_1m",
"ssid": "test_ssid",
"psk": "test_psk",
"password": "",
@@ -105,6 +105,7 @@ def test_wizard_write_sets_platform(default_config, tmp_path, monkeypatch):
If the platform is not explicitly set, use "ESP8266" if the board is one of the ESP8266 boards
"""
# Given
del default_config["platform"]
monkeypatch.setattr(wz, "write_file", MagicMock())
# When
@@ -112,7 +113,7 @@ def test_wizard_write_sets_platform(default_config, tmp_path, monkeypatch):
# Then
generated_config = wz.write_file.call_args.args[1]
assert f"platform: {default_config['platform']}" in generated_config
assert "esp8266:" in generated_config
def test_wizard_write_defaults_platform_from_board_esp8266(
@@ -132,7 +133,7 @@ def test_wizard_write_defaults_platform_from_board_esp8266(
# Then
generated_config = wz.write_file.call_args.args[1]
assert "platform: ESP8266" in generated_config
assert "esp8266:" in generated_config
def test_wizard_write_defaults_platform_from_board_esp32(
@@ -152,7 +153,7 @@ def test_wizard_write_defaults_platform_from_board_esp32(
# Then
generated_config = wz.write_file.call_args.args[1]
assert "platform: ESP32" in generated_config
assert "esp32:" in generated_config
def test_safe_print_step_prints_step_number_and_description(monkeypatch):