mirror of
https://github.com/esphome/esphome.git
synced 2025-11-05 01:21:50 +00:00
Compare commits
195 Commits
ble-server
...
2021.12.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b89d0a9a73 | ||
|
|
4bb779d9a5 | ||
|
|
386a5b6362 | ||
|
|
e32a999cd0 | ||
|
|
bfbc6a4bad | ||
|
|
8c9e0e552d | ||
|
|
8aaf9fd83f | ||
|
|
08057720b8 | ||
|
|
bfaa648837 | ||
|
|
d504daef91 | ||
|
|
b8d3ef2f49 | ||
|
|
3bf6320030 | ||
|
|
708b928c73 | ||
|
|
649366ff44 | ||
|
|
e5c9e87fad | ||
|
|
f3d9d707b6 | ||
|
|
090e10730c | ||
|
|
fbc84861c7 | ||
|
|
e763469af8 | ||
|
|
3c0c514e44 | ||
|
|
ed5e2dd332 | ||
|
|
09b7c6f550 | ||
|
|
df315a1f51 | ||
|
|
7ee4bb621c | ||
|
|
24874f4c3c | ||
|
|
c128880033 | ||
|
|
a66e94a0b0 | ||
|
|
56870ed4a8 | ||
|
|
3ac720df47 | ||
|
|
1bc757ad06 | ||
|
|
f72abc6f3d | ||
|
|
5ac88de985 | ||
|
|
0826b367d6 | ||
|
|
329bf861d6 | ||
|
|
9dcd3d18a0 | ||
|
|
db66cd88b6 | ||
|
|
86c205fe43 | ||
|
|
c6414138c7 | ||
|
|
36b355eb82 | ||
|
|
7be9291b13 | ||
|
|
ea9e75039b | ||
|
|
a5fb036011 | ||
|
|
e55506f9db | ||
|
|
50ec1d0445 | ||
|
|
3d5e1d8d91 | ||
|
|
db2128a344 | ||
|
|
21db43db06 | ||
|
|
5009b3029f | ||
|
|
57a029189c | ||
|
|
0cb715bb76 | ||
|
|
7d03823afd | ||
|
|
8e1c9f5042 | ||
|
|
980b7cda8f | ||
|
|
3a72dd5cb6 | ||
|
|
3178243811 | ||
|
|
d30e2f2a4f | ||
|
|
6226dae05c | ||
|
|
9c6a475a6e | ||
|
|
8294d10d5b | ||
|
|
67558bec47 | ||
|
|
84873d4074 | ||
|
|
58a0b28a39 | ||
|
|
b37d3a66cc | ||
|
|
7e495a5e27 | ||
|
|
c41547fd4a | ||
|
|
0d47d41c85 | ||
|
|
41a3a17456 | ||
|
|
cbbafbcca2 | ||
|
|
c75566b374 | ||
|
|
7279f1fcc1 | ||
|
|
d7432f7c10 | ||
|
|
b0a0a153f3 | ||
|
|
024632dbd0 | ||
|
|
0a545a28b9 | ||
|
|
0f2df59998 | ||
|
|
29a7d32f77 | ||
|
|
687a7e9b2f | ||
|
|
09e8782318 | ||
|
|
f2aea02210 | ||
|
|
194f922312 | ||
|
|
fea3c48098 | ||
|
|
c2f57baec2 | ||
|
|
f4a140e126 | ||
|
|
ab506b09fe | ||
|
|
87e1cdeedb | ||
|
|
81a36146ef | ||
|
|
7fa4a68a27 | ||
|
|
f1c5e2ef81 | ||
|
|
b526155cce | ||
|
|
62c3f301e7 | ||
|
|
38cb988809 | ||
|
|
b976ac54c8 | ||
|
|
78026e766f | ||
|
|
b4cd8d21a5 | ||
|
|
7552893311 | ||
|
|
21c896d8f8 | ||
|
|
4b7fe202ec | ||
|
|
9f4519210f | ||
|
|
b0506afa5b | ||
|
|
8cbb379898 | ||
|
|
b226215593 | ||
|
|
19970729a9 | ||
|
|
d2ebfd2833 | ||
|
|
bd782fc828 | ||
|
|
23560e608c | ||
|
|
f1377b560e | ||
|
|
72108684ea | ||
|
|
c6adaaea97 | ||
|
|
91999a38ca | ||
|
|
b34eed125d | ||
|
|
2abe09529a | ||
|
|
9aaaf4dd4b | ||
|
|
cbfbcf7f1b | ||
|
|
c7651dc40d | ||
|
|
eda1c471ad | ||
|
|
c7ef18fbc4 | ||
|
|
901ec918b1 | ||
|
|
6bdae55ee1 | ||
|
|
dfb96e4b7f | ||
|
|
ff2c316b18 | ||
|
|
5be52f71f9 | ||
|
|
42873dd37c | ||
|
|
f93e7d4e3a | ||
|
|
bbcd523967 | ||
|
|
68cbe58d00 | ||
|
|
115bca98f1 | ||
|
|
ed0b34b2fe | ||
|
|
ab34401421 | ||
|
|
eed0c18d65 | ||
|
|
e5a38ce748 | ||
|
|
7d9d9fcf36 | ||
|
|
f0aba6ceb2 | ||
|
|
ab07ee57c6 | ||
|
|
eae3d72a4d | ||
|
|
7b8d826704 | ||
|
|
e7baa42e63 | ||
|
|
2f32833a22 | ||
|
|
f6935a4b4b | ||
|
|
332c9e891b | ||
|
|
b91ee4847f | ||
|
|
625463d871 | ||
|
|
6433a01e07 | ||
|
|
56cc31e8e7 | ||
|
|
3af297aa76 | ||
|
|
996ec59d28 | ||
|
|
95593eeeab | ||
|
|
dad244fb7a | ||
|
|
adb5d27d95 | ||
|
|
8456a8cecb | ||
|
|
b9f66373c1 | ||
|
|
9ac365feef | ||
|
|
43bbd58a44 | ||
|
|
7feffa64f3 | ||
|
|
ea0977abb4 | ||
|
|
4c83dc7c28 | ||
|
|
e10ab1da78 | ||
|
|
1b0e60374b | ||
|
|
3a760fbb44 | ||
|
|
6ef57a2973 | ||
|
|
3e9c7f2e9f | ||
|
|
430598b7a1 | ||
|
|
91611b09b4 | ||
|
|
ecd115851f | ||
|
|
4a1e50fed1 | ||
|
|
d6d037047b | ||
|
|
b5734c2b20 | ||
|
|
723fb7eaac | ||
|
|
63a9acaa19 | ||
|
|
0524f8c677 | ||
|
|
70b62f272e | ||
|
|
f0089b7940 | ||
|
|
4b44280d53 | ||
|
|
f045382d20 | ||
|
|
db3fa1ade7 | ||
|
|
f83950fd75 | ||
|
|
4dd1bf920d | ||
|
|
98755f3621 | ||
|
|
c3a8a044b9 | ||
|
|
15b5ea43a7 | ||
|
|
ec683fc227 | ||
|
|
d4e65eb82a | ||
|
|
10c6601b0a | ||
|
|
73940bc1bd | ||
|
|
9b7fb829f9 | ||
|
|
c51d8c9021 | ||
|
|
d8a6dfe5ce | ||
|
|
5f7cef0b06 | ||
|
|
48ff2ffc68 | ||
|
|
b3b9ccd314 | ||
|
|
e63c7b483b | ||
|
|
f57980b069 | ||
|
|
7006aa0d2a | ||
|
|
8051c1ca99 | ||
|
|
a779592414 | ||
|
|
112215848d |
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ async def to_code(config):
|
|||||||
pos = 0
|
pos = 0
|
||||||
for frameIndex in range(frames):
|
for frameIndex in range(frames):
|
||||||
image.seek(frameIndex)
|
image.seek(frameIndex)
|
||||||
|
if CONF_RESIZE in config:
|
||||||
|
image.thumbnail(config[CONF_RESIZE])
|
||||||
frame = image.convert("RGB")
|
frame = image.convert("RGB")
|
||||||
if CONF_RESIZE in config:
|
if CONF_RESIZE in config:
|
||||||
frame = frame.resize([width, height])
|
frame = frame.resize([width, height])
|
||||||
|
|||||||
@@ -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",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -10,5 +10,6 @@ CONF_REGISTER_COUNT = "register_count"
|
|||||||
CONF_REGISTER_TYPE = "register_type"
|
CONF_REGISTER_TYPE = "register_type"
|
||||||
CONF_RESPONSE_SIZE = "response_size"
|
CONF_RESPONSE_SIZE = "response_size"
|
||||||
CONF_SKIP_UPDATES = "skip_updates"
|
CONF_SKIP_UPDATES = "skip_updates"
|
||||||
|
CONF_USE_WRITE_MULTIPLE = "use_write_multiple"
|
||||||
CONF_VALUE_TYPE = "value_type"
|
CONF_VALUE_TYPE = "value_type"
|
||||||
CONF_WRITE_LAMBDA = "write_lambda"
|
CONF_WRITE_LAMBDA = "write_lambda"
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ from ..const import (
|
|||||||
CONF_FORCE_NEW_RANGE,
|
CONF_FORCE_NEW_RANGE,
|
||||||
CONF_MODBUS_CONTROLLER_ID,
|
CONF_MODBUS_CONTROLLER_ID,
|
||||||
CONF_SKIP_UPDATES,
|
CONF_SKIP_UPDATES,
|
||||||
|
CONF_USE_WRITE_MULTIPLE,
|
||||||
CONF_VALUE_TYPE,
|
CONF_VALUE_TYPE,
|
||||||
CONF_WRITE_LAMBDA,
|
CONF_WRITE_LAMBDA,
|
||||||
)
|
)
|
||||||
@@ -69,6 +70,7 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
cv.Optional(CONF_MIN_VALUE, default=-16777215.0): cv.float_,
|
cv.Optional(CONF_MIN_VALUE, default=-16777215.0): cv.float_,
|
||||||
cv.Optional(CONF_STEP, default=1): cv.positive_float,
|
cv.Optional(CONF_STEP, default=1): cv.positive_float,
|
||||||
cv.Optional(CONF_MULTIPLY, default=1.0): cv.float_,
|
cv.Optional(CONF_MULTIPLY, default=1.0): cv.float_,
|
||||||
|
cv.Optional(CONF_USE_WRITE_MULTIPLE, default=False): cv.boolean,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.extend(cv.polling_component_schema("60s")),
|
.extend(cv.polling_component_schema("60s")),
|
||||||
@@ -105,6 +107,7 @@ async def to_code(config):
|
|||||||
cg.add(var.set_parent(parent))
|
cg.add(var.set_parent(parent))
|
||||||
cg.add(parent.add_sensor_item(var))
|
cg.add(parent.add_sensor_item(var))
|
||||||
await add_modbus_base_properties(var, config, ModbusNumber)
|
await add_modbus_base_properties(var, config, ModbusNumber)
|
||||||
|
cg.add(var.set_use_write_mutiple(config[CONF_USE_WRITE_MULTIPLE]))
|
||||||
if CONF_WRITE_LAMBDA in config:
|
if CONF_WRITE_LAMBDA in config:
|
||||||
template_ = await cg.process_lambda(
|
template_ = await cg.process_lambda(
|
||||||
config[CONF_WRITE_LAMBDA],
|
config[CONF_WRITE_LAMBDA],
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ void ModbusNumber::parse_and_publish(const std::vector<uint8_t> &data) {
|
|||||||
|
|
||||||
void ModbusNumber::control(float value) {
|
void ModbusNumber::control(float value) {
|
||||||
std::vector<uint16_t> data;
|
std::vector<uint16_t> data;
|
||||||
|
float write_value = value;
|
||||||
// Is there are lambda configured?
|
// Is there are lambda configured?
|
||||||
if (this->write_transform_func_.has_value()) {
|
if (this->write_transform_func_.has_value()) {
|
||||||
// data is passed by reference
|
// data is passed by reference
|
||||||
@@ -35,28 +36,32 @@ void ModbusNumber::control(float value) {
|
|||||||
auto val = (*this->write_transform_func_)(this, value, data);
|
auto val = (*this->write_transform_func_)(this, value, data);
|
||||||
if (val.has_value()) {
|
if (val.has_value()) {
|
||||||
ESP_LOGV(TAG, "Value overwritten by lambda");
|
ESP_LOGV(TAG, "Value overwritten by lambda");
|
||||||
value = val.value();
|
write_value = val.value();
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGV(TAG, "Communication handled by lambda - exiting control");
|
ESP_LOGV(TAG, "Communication handled by lambda - exiting control");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
value = multiply_by_ * value;
|
write_value = multiply_by_ * write_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// lambda didn't set payload
|
// lambda didn't set payload
|
||||||
if (data.empty()) {
|
if (data.empty()) {
|
||||||
data = float_to_payload(value, this->sensor_value_type);
|
data = float_to_payload(write_value, this->sensor_value_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG,
|
ESP_LOGD(TAG,
|
||||||
"Updating register: connected Sensor=%s start address=0x%X register count=%d new value=%.02f (val=%.02f)",
|
"Updating register: connected Sensor=%s start address=0x%X register count=%d new value=%.02f (val=%.02f)",
|
||||||
this->get_name().c_str(), this->start_address, this->register_count, value, value);
|
this->get_name().c_str(), this->start_address, this->register_count, write_value, write_value);
|
||||||
|
|
||||||
// Create and send the write command
|
// Create and send the write command
|
||||||
auto write_cmd = ModbusCommandItem::create_write_multiple_command(parent_, this->start_address + this->offset,
|
ModbusCommandItem write_cmd;
|
||||||
this->register_count, data);
|
if (this->register_count == 1 && !this->use_write_multiple_) {
|
||||||
|
write_cmd = ModbusCommandItem::create_write_single_command(parent_, this->start_address + this->offset, data[0]);
|
||||||
|
} else {
|
||||||
|
write_cmd = ModbusCommandItem::create_write_multiple_command(parent_, this->start_address + this->offset,
|
||||||
|
this->register_count, data);
|
||||||
|
}
|
||||||
// publish new value
|
// publish new value
|
||||||
write_cmd.on_data_func = [this, write_cmd, value](ModbusRegisterType register_type, uint16_t start_address,
|
write_cmd.on_data_func = [this, write_cmd, value](ModbusRegisterType register_type, uint16_t start_address,
|
||||||
const std::vector<uint8_t> &data) {
|
const std::vector<uint8_t> &data) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class ModbusNumber : public number::Number, public Component, public SensorItem
|
|||||||
using write_transform_func_t = std::function<optional<float>(ModbusNumber *, float, std::vector<uint16_t> &)>;
|
using write_transform_func_t = std::function<optional<float>(ModbusNumber *, float, std::vector<uint16_t> &)>;
|
||||||
void set_template(transform_func_t &&f) { this->transform_func_ = f; }
|
void set_template(transform_func_t &&f) { this->transform_func_ = f; }
|
||||||
void set_write_template(write_transform_func_t &&f) { this->write_transform_func_ = f; }
|
void set_write_template(write_transform_func_t &&f) { this->write_transform_func_ = f; }
|
||||||
|
void set_use_write_mutiple(bool use_write_multiple) { this->use_write_multiple_ = use_write_multiple; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void control(float value) override;
|
void control(float value) override;
|
||||||
@@ -42,6 +43,7 @@ class ModbusNumber : public number::Number, public Component, public SensorItem
|
|||||||
optional<write_transform_func_t> write_transform_func_;
|
optional<write_transform_func_t> write_transform_func_;
|
||||||
ModbusController *parent_;
|
ModbusController *parent_;
|
||||||
float multiply_by_{1.0};
|
float multiply_by_{1.0};
|
||||||
|
bool use_write_multiple_{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace modbus_controller
|
} // namespace modbus_controller
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from .. import (
|
|||||||
|
|
||||||
from ..const import (
|
from ..const import (
|
||||||
CONF_MODBUS_CONTROLLER_ID,
|
CONF_MODBUS_CONTROLLER_ID,
|
||||||
|
CONF_USE_WRITE_MULTIPLE,
|
||||||
CONF_VALUE_TYPE,
|
CONF_VALUE_TYPE,
|
||||||
CONF_WRITE_LAMBDA,
|
CONF_WRITE_LAMBDA,
|
||||||
)
|
)
|
||||||
@@ -36,6 +37,7 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
cv.GenerateID(): cv.declare_id(ModbusOutput),
|
cv.GenerateID(): cv.declare_id(ModbusOutput),
|
||||||
cv.Optional(CONF_WRITE_LAMBDA): cv.returning_lambda,
|
cv.Optional(CONF_WRITE_LAMBDA): cv.returning_lambda,
|
||||||
cv.Optional(CONF_MULTIPLY, default=1.0): cv.float_,
|
cv.Optional(CONF_MULTIPLY, default=1.0): cv.float_,
|
||||||
|
cv.Optional(CONF_USE_WRITE_MULTIPLE, default=False): cv.boolean,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
validate_modbus_register,
|
validate_modbus_register,
|
||||||
@@ -54,6 +56,7 @@ async def to_code(config):
|
|||||||
await output.register_output(var, config)
|
await output.register_output(var, config)
|
||||||
cg.add(var.set_write_multiply(config[CONF_MULTIPLY]))
|
cg.add(var.set_write_multiply(config[CONF_MULTIPLY]))
|
||||||
parent = await cg.get_variable(config[CONF_MODBUS_CONTROLLER_ID])
|
parent = await cg.get_variable(config[CONF_MODBUS_CONTROLLER_ID])
|
||||||
|
cg.add(var.set_use_write_mutiple(config[CONF_USE_WRITE_MULTIPLE]))
|
||||||
cg.add(var.set_parent(parent))
|
cg.add(var.set_parent(parent))
|
||||||
if CONF_WRITE_LAMBDA in config:
|
if CONF_WRITE_LAMBDA in config:
|
||||||
template_ = await cg.process_lambda(
|
template_ = await cg.process_lambda(
|
||||||
|
|||||||
@@ -40,8 +40,14 @@ void ModbusOutput::write_state(float value) {
|
|||||||
this->start_address, this->register_count, value, original_value);
|
this->start_address, this->register_count, value, original_value);
|
||||||
|
|
||||||
// Create and send the write command
|
// Create and send the write command
|
||||||
auto write_cmd =
|
// Create and send the write command
|
||||||
ModbusCommandItem::create_write_multiple_command(parent_, this->start_address, this->register_count, data);
|
ModbusCommandItem write_cmd;
|
||||||
|
if (this->register_count == 1 && !this->use_write_multiple_) {
|
||||||
|
write_cmd = ModbusCommandItem::create_write_single_command(parent_, this->start_address + this->offset, data[0]);
|
||||||
|
} else {
|
||||||
|
write_cmd = ModbusCommandItem::create_write_multiple_command(parent_, this->start_address + this->offset,
|
||||||
|
this->register_count, data);
|
||||||
|
}
|
||||||
parent_->queue_command(write_cmd);
|
parent_->queue_command(write_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class ModbusOutput : public output::FloatOutput, public Component, public Sensor
|
|||||||
|
|
||||||
using write_transform_func_t = std::function<optional<float>(ModbusOutput *, float, std::vector<uint16_t> &)>;
|
using write_transform_func_t = std::function<optional<float>(ModbusOutput *, float, std::vector<uint16_t> &)>;
|
||||||
void set_write_template(write_transform_func_t &&f) { this->write_transform_func_ = f; }
|
void set_write_template(write_transform_func_t &&f) { this->write_transform_func_ = f; }
|
||||||
|
void set_use_write_mutiple(bool use_write_multiple) { this->use_write_multiple_ = use_write_multiple; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void write_state(float value) override;
|
void write_state(float value) override;
|
||||||
@@ -40,6 +41,7 @@ class ModbusOutput : public output::FloatOutput, public Component, public Sensor
|
|||||||
|
|
||||||
ModbusController *parent_;
|
ModbusController *parent_;
|
||||||
float multiply_by_{1.0};
|
float multiply_by_{1.0};
|
||||||
|
bool use_write_multiple_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace modbus_controller
|
} // namespace modbus_controller
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ from ..const import (
|
|||||||
CONF_FORCE_NEW_RANGE,
|
CONF_FORCE_NEW_RANGE,
|
||||||
CONF_MODBUS_CONTROLLER_ID,
|
CONF_MODBUS_CONTROLLER_ID,
|
||||||
CONF_REGISTER_TYPE,
|
CONF_REGISTER_TYPE,
|
||||||
|
CONF_USE_WRITE_MULTIPLE,
|
||||||
CONF_WRITE_LAMBDA,
|
CONF_WRITE_LAMBDA,
|
||||||
)
|
)
|
||||||
|
|
||||||
CONF_USE_WRITE_MULTIPLE = "use_write_multiple"
|
|
||||||
DEPENDENCIES = ["modbus_controller"]
|
DEPENDENCIES = ["modbus_controller"]
|
||||||
CODEOWNERS = ["@martgras"]
|
CODEOWNERS = ["@martgras"]
|
||||||
|
|
||||||
|
|||||||
@@ -277,6 +277,7 @@ void OTAComponent::handle_() {
|
|||||||
ssize_t read = this->client_->read(buf, requested);
|
ssize_t read = this->client_->read(buf, requested);
|
||||||
if (read == -1) {
|
if (read == -1) {
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
|
App.feed_wdt();
|
||||||
delay(1);
|
delay(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -305,8 +306,9 @@ void OTAComponent::handle_() {
|
|||||||
#ifdef USE_OTA_STATE_CALLBACK
|
#ifdef USE_OTA_STATE_CALLBACK
|
||||||
this->state_callback_.call(OTA_IN_PROGRESS, percentage, 0);
|
this->state_callback_.call(OTA_IN_PROGRESS, percentage, 0);
|
||||||
#endif
|
#endif
|
||||||
// slow down OTA update to avoid getting killed by task watchdog (task_wdt)
|
// feed watchdog and give other tasks a chance to run
|
||||||
delay(10);
|
App.feed_wdt();
|
||||||
|
yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,6 +372,7 @@ bool OTAComponent::readall_(uint8_t *buf, size_t len) {
|
|||||||
ssize_t read = this->client_->read(buf + at, len - at);
|
ssize_t read = this->client_->read(buf + at, len - at);
|
||||||
if (read == -1) {
|
if (read == -1) {
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
|
App.feed_wdt();
|
||||||
delay(1);
|
delay(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -381,6 +384,7 @@ bool OTAComponent::readall_(uint8_t *buf, size_t len) {
|
|||||||
} else {
|
} else {
|
||||||
at += read;
|
at += read;
|
||||||
}
|
}
|
||||||
|
App.feed_wdt();
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,6 +403,7 @@ bool OTAComponent::writeall_(const uint8_t *buf, size_t len) {
|
|||||||
ssize_t written = this->client_->write(buf + at, len - at);
|
ssize_t written = this->client_->write(buf + at, len - at);
|
||||||
if (written == -1) {
|
if (written == -1) {
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
|
App.feed_wdt();
|
||||||
delay(1);
|
delay(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -407,6 +412,7 @@ bool OTAComponent::writeall_(const uint8_t *buf, size_t len) {
|
|||||||
} else {
|
} else {
|
||||||
at += written;
|
at += written;
|
||||||
}
|
}
|
||||||
|
App.feed_wdt();
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ void TextSensor::add_on_raw_state_callback(std::function<void(std::string)> call
|
|||||||
std::string TextSensor::get_state() const { return this->state; }
|
std::string TextSensor::get_state() const { return this->state; }
|
||||||
std::string TextSensor::get_raw_state() const { return this->raw_state; }
|
std::string TextSensor::get_raw_state() const { return this->raw_state; }
|
||||||
void TextSensor::internal_send_state_to_frontend(const std::string &state) {
|
void TextSensor::internal_send_state_to_frontend(const std::string &state) {
|
||||||
this->state = this->raw_state;
|
this->state = state;
|
||||||
this->has_state_ = true;
|
this->has_state_ = true;
|
||||||
ESP_LOGD(TAG, "'%s': Sending state '%s'", this->name_.c_str(), state.c_str());
|
ESP_LOGD(TAG, "'%s': Sending state '%s'", this->name_.c_str(), state.c_str());
|
||||||
this->callback_.call(state);
|
this->callback_.call(state);
|
||||||
|
|||||||
@@ -431,7 +431,8 @@ async def to_code(config):
|
|||||||
|
|
||||||
heat_cool_mode_available = CONF_HEAT_ACTION in config and CONF_COOL_ACTION in config
|
heat_cool_mode_available = CONF_HEAT_ACTION in config and CONF_COOL_ACTION in config
|
||||||
two_points_available = CONF_HEAT_ACTION in config and (
|
two_points_available = CONF_HEAT_ACTION in config and (
|
||||||
CONF_COOL_ACTION in config or CONF_FAN_ONLY_ACTION in config
|
CONF_COOL_ACTION in config
|
||||||
|
or (config[CONF_FAN_ONLY_COOLING] and CONF_FAN_ONLY_ACTION in config)
|
||||||
)
|
)
|
||||||
|
|
||||||
sens = await cg.get_variable(config[CONF_SENSOR])
|
sens = await cg.get_variable(config[CONF_SENSOR])
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -390,8 +390,6 @@ void WebServer::handle_switch_request(AsyncWebServerRequest *request, const UrlM
|
|||||||
#ifdef USE_BUTTON
|
#ifdef USE_BUTTON
|
||||||
void WebServer::handle_button_request(AsyncWebServerRequest *request, const UrlMatch &match) {
|
void WebServer::handle_button_request(AsyncWebServerRequest *request, const UrlMatch &match) {
|
||||||
for (button::Button *obj : App.get_buttons()) {
|
for (button::Button *obj : App.get_buttons()) {
|
||||||
if (obj->is_internal())
|
|
||||||
continue;
|
|
||||||
if (obj->get_object_id() != match.id)
|
if (obj->get_object_id() != match.id)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2021.12.0-dev"
|
__version__ = "2021.12.1"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
|
|
||||||
|
|||||||
@@ -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};
|
||||||
|
|||||||
@@ -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,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ OTA_BIG = r""" ____ _______
|
|||||||
|
|
||||||
BASE_CONFIG = """esphome:
|
BASE_CONFIG = """esphome:
|
||||||
name: {name}
|
name: {name}
|
||||||
platform: {platform}
|
"""
|
||||||
board: {board}
|
|
||||||
|
|
||||||
|
LOGGER_API_CONFIG = """
|
||||||
# Enable logging
|
# Enable logging
|
||||||
logger:
|
logger:
|
||||||
|
|
||||||
@@ -55,6 +55,18 @@ logger:
|
|||||||
api:
|
api:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ESP8266_CONFIG = """
|
||||||
|
esp8266:
|
||||||
|
board: {board}
|
||||||
|
"""
|
||||||
|
|
||||||
|
ESP32_CONFIG = """
|
||||||
|
esp32:
|
||||||
|
board: {board}
|
||||||
|
framework:
|
||||||
|
type: arduino
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
def sanitize_double_quotes(value):
|
def sanitize_double_quotes(value):
|
||||||
return value.replace("\\", "\\\\").replace('"', '\\"')
|
return value.replace("\\", "\\\\").replace('"', '\\"')
|
||||||
@@ -71,6 +83,14 @@ def wizard_file(**kwargs):
|
|||||||
|
|
||||||
config = BASE_CONFIG.format(**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
|
# Configure API
|
||||||
if "password" in kwargs:
|
if "password" in kwargs:
|
||||||
config += f" password: \"{kwargs['password']}\"\n"
|
config += f" password: \"{kwargs['password']}\"\n"
|
||||||
@@ -86,12 +106,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"
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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==20211211.0
|
||||||
aioesphomeapi==10.6.0
|
aioesphomeapi==10.6.0
|
||||||
zeroconf==0.36.13
|
zeroconf==0.36.13
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ def default_config():
|
|||||||
return {
|
return {
|
||||||
"name": "test-name",
|
"name": "test-name",
|
||||||
"platform": "test_platform",
|
"platform": "test_platform",
|
||||||
"board": "test_board",
|
"board": "esp01_1m",
|
||||||
"ssid": "test_ssid",
|
"ssid": "test_ssid",
|
||||||
"psk": "test_psk",
|
"psk": "test_psk",
|
||||||
"password": "",
|
"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
|
If the platform is not explicitly set, use "ESP8266" if the board is one of the ESP8266 boards
|
||||||
"""
|
"""
|
||||||
# Given
|
# Given
|
||||||
|
del default_config["platform"]
|
||||||
monkeypatch.setattr(wz, "write_file", MagicMock())
|
monkeypatch.setattr(wz, "write_file", MagicMock())
|
||||||
|
|
||||||
# When
|
# When
|
||||||
@@ -112,7 +113,7 @@ def test_wizard_write_sets_platform(default_config, tmp_path, monkeypatch):
|
|||||||
|
|
||||||
# Then
|
# Then
|
||||||
generated_config = wz.write_file.call_args.args[1]
|
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(
|
def test_wizard_write_defaults_platform_from_board_esp8266(
|
||||||
@@ -132,7 +133,7 @@ def test_wizard_write_defaults_platform_from_board_esp8266(
|
|||||||
|
|
||||||
# Then
|
# Then
|
||||||
generated_config = wz.write_file.call_args.args[1]
|
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(
|
def test_wizard_write_defaults_platform_from_board_esp32(
|
||||||
@@ -152,7 +153,7 @@ def test_wizard_write_defaults_platform_from_board_esp32(
|
|||||||
|
|
||||||
# Then
|
# Then
|
||||||
generated_config = wz.write_file.call_args.args[1]
|
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):
|
def test_safe_print_step_prints_step_number_and_description(monkeypatch):
|
||||||
|
|||||||
Reference in New Issue
Block a user