Merge pull request #2880 from esphome/bump-2021.12.0b3

2021.12.0b3
This commit is contained in:
Jesse Hills 2021-12-07 15:27:08 +13:00 committed by GitHub
commit 3c0c514e44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 67 additions and 31 deletions

View file

@ -91,7 +91,7 @@ void ADCSensor::dump_config() {
float ADCSensor::get_setup_priority() const { return setup_priority::DATA; } float ADCSensor::get_setup_priority() const { return setup_priority::DATA; }
void ADCSensor::update() { void ADCSensor::update() {
float value_v = this->sample(); 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); 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:
# wifi: ssid: !secret wifi_ssid
# ssid: !secret wifi_ssid password: !secret wifi_password
# 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}, "esphome": {"name_add_mac_suffix": False},
} }
p.write_text( p.write_text(
dump(config) + WIFI_MESSAGE, dump(config) + WIFI_CONFIG,
encoding="utf8", encoding="utf8",
) )

View file

@ -184,7 +184,9 @@ void EthernetComponent::start_connect_() {
} }
err = tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH); 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); err = tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_ETH, &info);
ESPHL_ERROR_CHECK(err, "DHCPC set IP info error"); 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; uint8_t gppu = pin < 8 ? mcp23x17_base::MCP23X17_GPPUA : mcp23x17_base::MCP23X17_GPPUB;
if (flags == gpio::FLAG_INPUT) { if (flags == gpio::FLAG_INPUT) {
this->update_reg(pin, true, iodir); this->update_reg(pin, true, iodir);
this->update_reg(pin, false, gppu);
} else if (flags == (gpio::FLAG_INPUT | gpio::FLAG_PULLUP)) { } else if (flags == (gpio::FLAG_INPUT | gpio::FLAG_PULLUP)) {
this->update_reg(pin, true, iodir); this->update_reg(pin, true, iodir);
this->update_reg(pin, true, gppu); this->update_reg(pin, true, gppu);

View file

@ -32,14 +32,11 @@ void SPS30Component::setup() {
return; return;
} }
uint16_t raw_firmware_version[4]; if (!this->read_data_(&raw_firmware_version_, 1)) {
if (!this->read_data_(raw_firmware_version, 4)) {
this->error_code_ = FIRMWARE_VERSION_READ_FAILED; this->error_code_ = FIRMWARE_VERSION_READ_FAILED;
this->mark_failed(); this->mark_failed();
return; return;
} }
ESP_LOGD(TAG, " Firmware version v%0d.%02d", (raw_firmware_version[0] >> 8),
uint16_t(raw_firmware_version[0] & 0xFF));
/// Serial number identification /// Serial number identification
if (!this->write_command_(SPS30_CMD_GET_SERIAL_NUMBER)) { if (!this->write_command_(SPS30_CMD_GET_SERIAL_NUMBER)) {
this->error_code_ = SERIAL_NUMBER_REQUEST_FAILED; 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)); this->serial_number_[i * 2 + 1] = uint16_t(uint16_t(raw_serial_number[i] & 0xFF));
} }
ESP_LOGD(TAG, " Serial Number: '%s'", this->serial_number_); ESP_LOGD(TAG, " Serial Number: '%s'", this->serial_number_);
this->status_clear_warning();
this->skipped_data_read_cycles_ = 0;
this->start_continuous_measurement_(); this->start_continuous_measurement_();
}); });
} }
@ -93,10 +92,17 @@ void SPS30Component::dump_config() {
} }
LOG_UPDATE_INTERVAL(this); LOG_UPDATE_INTERVAL(this);
ESP_LOGCONFIG(TAG, " Serial Number: '%s'", this->serial_number_); ESP_LOGCONFIG(TAG, " Serial Number: '%s'", this->serial_number_);
LOG_SENSOR(" ", "PM1.0", this->pm_1_0_sensor_); ESP_LOGCONFIG(TAG, " Firmware version v%0d.%0d", (raw_firmware_version_ >> 8),
LOG_SENSOR(" ", "PM2.5", this->pm_2_5_sensor_); uint16_t(raw_firmware_version_ & 0xFF));
LOG_SENSOR(" ", "PM4", this->pm_4_0_sensor_); LOG_SENSOR(" ", "PM1.0 Weight Concentration", this->pm_1_0_sensor_);
LOG_SENSOR(" ", "PM10", this->pm_10_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() { void SPS30Component::update() {
@ -123,8 +129,8 @@ void SPS30Component::update() {
return; return;
} }
uint16_t raw_read_status[1]; uint16_t raw_read_status;
if (!this->read_data_(raw_read_status, 1) || raw_read_status[0] == 0x00) { if (!this->read_data_(&raw_read_status, 1) || raw_read_status == 0x00) {
ESP_LOGD(TAG, "Sensor measurement not ready yet."); ESP_LOGD(TAG, "Sensor measurement not ready yet.");
this->skipped_data_read_cycles_++; this->skipped_data_read_cycles_++;
/// The following logic is required to address the cases when a sensor is quickly replaced before it's marked /// 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); bool read_data_(uint16_t *data, uint8_t len);
uint8_t sht_crc_(uint8_t data1, uint8_t data2); uint8_t sht_crc_(uint8_t data1, uint8_t data2);
char serial_number_[17] = {0}; /// Terminating NULL character char serial_number_[17] = {0}; /// Terminating NULL character
uint16_t raw_firmware_version_;
bool start_continuous_measurement_(); bool start_continuous_measurement_();
uint8_t skipped_data_read_cycles_ = 0; uint8_t skipped_data_read_cycles_ = 0;

View file

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

View file

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

View file

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

View file

@ -27,7 +27,7 @@ import tornado.process
import tornado.web import tornado.web
import tornado.websocket 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.helpers import mkdir_p, get_bool_env, run_system_command
from esphome.storage_json import ( from esphome.storage_json import (
EsphomeStorageJSON, EsphomeStorageJSON,
@ -836,6 +836,28 @@ class LogoutHandler(BaseHandler):
self.redirect("./login") 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(): def get_base_frontend_path():
if ENV_DEV not in os.environ: if ENV_DEV not in os.environ:
import esphome_dashboard 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}static/(.*)", StaticFileHandler, {"path": get_static_path()}),
(f"{rel}devices", ListDevicesHandler), (f"{rel}devices", ListDevicesHandler),
(f"{rel}import", ImportRequestHandler), (f"{rel}import", ImportRequestHandler),
(f"{rel}secret_keys", SecretKeysRequestHandler),
], ],
**app_settings, **app_settings,
) )

View file

@ -86,12 +86,11 @@ def wizard_file(**kwargs):
config += "\n\nwifi:\n" config += "\n\nwifi:\n"
if "ssid" in kwargs: if "ssid" in kwargs:
# pylint: disable=consider-using-f-string if kwargs["ssid"].startswith("!secret"):
config += """ ssid: "{ssid}" template = " ssid: {ssid}\n password: {psk}\n"
password: "{psk}" else:
""".format( template = """ ssid: "{ssid}"\n password: "{psk}"\n"""
**kwargs config += template.format(**kwargs)
)
else: else:
config += """ # ssid: "My SSID" config += """ # ssid: "My SSID"
# password: "mypassword" # password: "mypassword"

View file

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

View file

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