Merge pull request #2634 from esphome/bump-2021.10.3

2021.10.3
This commit is contained in:
Jesse Hills 2021-10-27 11:21:08 +13:00 committed by GitHub
commit d2ebfd2833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 61 additions and 74 deletions

View File

@ -226,6 +226,8 @@ def upload_using_esptool(config, port):
mcu,
"write_flash",
"-z",
"--flash_size",
"detect",
]
for img in flash_images:
cmd += [img.offset, img.path]

View File

@ -75,14 +75,14 @@ CONFIG_SCHEMA = cv.Schema(
UNIT_KILOVOLT_AMPS_REACTIVE_HOURS,
ICON_EMPTY,
3,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_EMPTY,
STATE_CLASS_NONE,
),
cv.Optional("total_exported_energy"): sensor.sensor_schema(
UNIT_KILOVOLT_AMPS_REACTIVE_HOURS,
ICON_EMPTY,
3,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_EMPTY,
STATE_CLASS_NONE,
),
cv.Optional("power_delivered"): sensor.sensor_schema(
@ -166,42 +166,42 @@ CONFIG_SCHEMA = cv.Schema(
UNIT_KILOVOLT_AMPS_REACTIVE,
ICON_EMPTY,
3,
DEVICE_CLASS_POWER,
DEVICE_CLASS_EMPTY,
STATE_CLASS_MEASUREMENT,
),
cv.Optional("reactive_power_delivered_l2"): sensor.sensor_schema(
UNIT_KILOVOLT_AMPS_REACTIVE,
ICON_EMPTY,
3,
DEVICE_CLASS_POWER,
DEVICE_CLASS_EMPTY,
STATE_CLASS_MEASUREMENT,
),
cv.Optional("reactive_power_delivered_l3"): sensor.sensor_schema(
UNIT_KILOVOLT_AMPS_REACTIVE,
ICON_EMPTY,
3,
DEVICE_CLASS_POWER,
DEVICE_CLASS_EMPTY,
STATE_CLASS_MEASUREMENT,
),
cv.Optional("reactive_power_returned_l1"): sensor.sensor_schema(
UNIT_KILOVOLT_AMPS_REACTIVE,
ICON_EMPTY,
3,
DEVICE_CLASS_POWER,
DEVICE_CLASS_EMPTY,
STATE_CLASS_MEASUREMENT,
),
cv.Optional("reactive_power_returned_l2"): sensor.sensor_schema(
UNIT_KILOVOLT_AMPS_REACTIVE,
ICON_EMPTY,
3,
DEVICE_CLASS_POWER,
DEVICE_CLASS_EMPTY,
STATE_CLASS_MEASUREMENT,
),
cv.Optional("reactive_power_returned_l3"): sensor.sensor_schema(
UNIT_KILOVOLT_AMPS_REACTIVE,
ICON_EMPTY,
3,
DEVICE_CLASS_POWER,
DEVICE_CLASS_EMPTY,
STATE_CLASS_MEASUREMENT,
),
cv.Optional("voltage_l1"): sensor.sensor_schema(

View File

@ -63,7 +63,7 @@ RECOMMENDED_ARDUINO_FRAMEWORK_VERSION = cv.Version(2, 7, 4)
# The platformio/espressif8266 version to use for arduino 2 framework versions
# - https://github.com/platformio/platform-espressif8266/releases
# - https://api.registry.platformio.org/v3/packages/platformio/platform/espressif8266
ARDUINO_2_PLATFORM_VERSION = cv.Version(2, 6, 2)
ARDUINO_2_PLATFORM_VERSION = cv.Version(2, 6, 3)
# for arduino 3 framework versions
ARDUINO_3_PLATFORM_VERSION = cv.Version(3, 2, 0)

View File

@ -93,13 +93,12 @@ PV_SENSORS = {
CONF_VOLTAGE_SAMPLED_BY_SECONDARY_CPU: sensor.sensor_schema(
unit_of_measurement=UNIT_VOLT,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
device_class=DEVICE_CLASS_VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT,
),
CONF_INSULATION_OF_P_TO_GROUND: sensor.sensor_schema(
unit_of_measurement=UNIT_KOHM,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
}
@ -135,7 +134,6 @@ CONFIG_SCHEMA = (
cv.Optional(CONF_REACTIVE_POWER): sensor.sensor_schema(
unit_of_measurement=UNIT_VOLT_AMPS_REACTIVE,
accuracy_decimals=2,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
cv.Optional(CONF_ENERGY_PRODUCTION_DAY): sensor.sensor_schema(

View File

@ -61,6 +61,21 @@ SENSOR_VALUE_TYPE = {
"FP32_R": SensorValueType.FP32_R,
}
TYPE_REGISTER_MAP = {
"RAW": 1,
"U_WORD": 1,
"S_WORD": 1,
"U_DWORD": 2,
"U_DWORD_R": 2,
"S_DWORD": 2,
"S_DWORD_R": 2,
"U_QWORD": 4,
"U_QWORDU_R": 4,
"S_QWORD": 4,
"U_QWORD_R": 4,
"FP32": 2,
"FP32_R": 2,
}
MULTI_CONF = True

View File

@ -17,6 +17,7 @@ from .. import (
ModbusController,
SENSOR_VALUE_TYPE,
SensorItem,
TYPE_REGISTER_MAP,
)
@ -39,22 +40,6 @@ ModbusNumber = modbus_controller_ns.class_(
"ModbusNumber", cg.Component, number.Number, SensorItem
)
TYPE_REGISTER_MAP = {
"RAW": 1,
"U_WORD": 1,
"S_WORD": 1,
"U_DWORD": 2,
"U_DWORD_R": 2,
"S_DWORD": 2,
"S_DWORD_R": 2,
"U_QWORD": 4,
"U_QWORDU_R": 4,
"S_QWORD": 4,
"U_QWORD_R": 4,
"FP32": 2,
"FP32_R": 2,
}
def validate_min_max(config):
if config[CONF_MAX_VALUE] <= config[CONF_MIN_VALUE]:

View File

@ -13,11 +13,13 @@ from .. import (
SensorItem,
modbus_controller_ns,
ModbusController,
TYPE_REGISTER_MAP,
)
from ..const import (
CONF_BYTE_OFFSET,
CONF_MODBUS_CONTROLLER_ID,
CONF_REGISTER_COUNT,
CONF_VALUE_TYPE,
CONF_WRITE_LAMBDA,
)
@ -40,6 +42,7 @@ CONFIG_SCHEMA = cv.All(
cv.Optional(CONF_OFFSET, default=0): cv.positive_int,
cv.Optional(CONF_BYTE_OFFSET): cv.positive_int,
cv.Optional(CONF_VALUE_TYPE, default="U_WORD"): cv.enum(SENSOR_VALUE_TYPE),
cv.Optional(CONF_REGISTER_COUNT, default=0): cv.positive_int,
cv.Optional(CONF_WRITE_LAMBDA): cv.returning_lambda,
cv.Optional(CONF_MULTIPLY, default=1.0): cv.float_,
}
@ -54,8 +57,16 @@ async def to_code(config):
# A CONF_BYTE_OFFSET setting overrides CONF_OFFSET
if CONF_BYTE_OFFSET in config:
byte_offset = config[CONF_BYTE_OFFSET]
value_type = config[CONF_VALUE_TYPE]
reg_count = config[CONF_REGISTER_COUNT]
if reg_count == 0:
reg_count = TYPE_REGISTER_MAP[value_type]
var = cg.new_Pvariable(
config[CONF_ID], config[CONF_ADDRESS], byte_offset, config[CONF_VALUE_TYPE]
config[CONF_ID],
config[CONF_ADDRESS],
byte_offset,
value_type,
reg_count,
)
await output.register_output(var, config)
cg.add(var.set_write_multiply(config[CONF_MULTIPLY]))

View File

@ -11,12 +11,13 @@ using value_to_data_t = std::function<float>(float);
class ModbusOutput : public output::FloatOutput, public Component, public SensorItem {
public:
ModbusOutput(uint16_t start_address, uint8_t offset, SensorValueType value_type)
ModbusOutput(uint16_t start_address, uint8_t offset, SensorValueType value_type, int register_count)
: output::FloatOutput(), Component() {
this->register_type = ModbusRegisterType::HOLDING;
this->start_address = start_address;
this->offset = offset;
this->bitmask = bitmask;
this->register_count = register_count;
this->sensor_value_type = value_type;
this->skip_updates = 0;
this->start_address += offset;

View File

@ -9,6 +9,7 @@ from .. import (
ModbusController,
MODBUS_REGISTER_TYPE,
SENSOR_VALUE_TYPE,
TYPE_REGISTER_MAP,
)
from ..const import (
CONF_BITMASK,
@ -29,23 +30,6 @@ ModbusSensor = modbus_controller_ns.class_(
"ModbusSensor", cg.Component, sensor.Sensor, SensorItem
)
TYPE_REGISTER_MAP = {
"RAW": 1,
"U_WORD": 1,
"S_WORD": 1,
"U_DWORD": 2,
"U_DWORD_R": 2,
"S_DWORD": 2,
"S_DWORD_R": 2,
"U_QWORD": 4,
"U_QWORDU_R": 4,
"S_QWORD": 4,
"U_QWORD_R": 4,
"FP32": 2,
"FP32_R": 2,
}
CONFIG_SCHEMA = cv.All(
sensor.SENSOR_SCHEMA.extend(
{

View File

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

View File

@ -89,7 +89,7 @@ TYPES = {
UNIT_AMPERE, ICON_EMPTY, 1, DEVICE_CLASS_CURRENT
),
CONF_AC_OUTPUT_RATING_APPARENT_POWER: sensor.sensor_schema(
UNIT_VOLT_AMPS, ICON_EMPTY, 1, DEVICE_CLASS_POWER
UNIT_VOLT_AMPS, ICON_EMPTY, 1, DEVICE_CLASS_EMPTY
),
CONF_AC_OUTPUT_RATING_ACTIVE_POWER: sensor.sensor_schema(
UNIT_WATT, ICON_EMPTY, 1, DEVICE_CLASS_POWER
@ -159,7 +159,7 @@ TYPES = {
UNIT_HERTZ, ICON_CURRENT_AC, 1, DEVICE_CLASS_EMPTY
),
CONF_AC_OUTPUT_APPARENT_POWER: sensor.sensor_schema(
UNIT_VOLT_AMPS, ICON_EMPTY, 1, DEVICE_CLASS_POWER
UNIT_VOLT_AMPS, ICON_EMPTY, 1, DEVICE_CLASS_EMPTY
),
CONF_AC_OUTPUT_ACTIVE_POWER: sensor.sensor_schema(
UNIT_WATT, ICON_EMPTY, 1, DEVICE_CLASS_POWER

View File

@ -64,13 +64,11 @@ PHASE_SENSORS = {
CONF_APPARENT_POWER: sensor.sensor_schema(
unit_of_measurement=UNIT_VOLT_AMPS,
accuracy_decimals=2,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
CONF_REACTIVE_POWER: sensor.sensor_schema(
unit_of_measurement=UNIT_VOLT_AMPS_REACTIVE,
accuracy_decimals=2,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
CONF_POWER_FACTOR: sensor.sensor_schema(
@ -115,13 +113,11 @@ CONFIG_SCHEMA = (
cv.Optional(CONF_IMPORT_REACTIVE_ENERGY): sensor.sensor_schema(
unit_of_measurement=UNIT_KILOVOLT_AMPS_REACTIVE_HOURS,
accuracy_decimals=2,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
cv.Optional(CONF_EXPORT_REACTIVE_ENERGY): sensor.sensor_schema(
unit_of_measurement=UNIT_KILOVOLT_AMPS_REACTIVE_HOURS,
accuracy_decimals=2,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
}

View File

@ -71,25 +71,21 @@ SENSORS = {
CONF_TOTAL_REACTIVE_ENERGY: sensor.sensor_schema(
unit_of_measurement=UNIT_KILOVOLT_AMPS_REACTIVE_HOURS,
accuracy_decimals=2,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
CONF_IMPORT_REACTIVE_ENERGY: sensor.sensor_schema(
unit_of_measurement=UNIT_KILOVOLT_AMPS_REACTIVE_HOURS,
accuracy_decimals=2,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
CONF_EXPORT_REACTIVE_ENERGY: sensor.sensor_schema(
unit_of_measurement=UNIT_KILOVOLT_AMPS_REACTIVE_HOURS,
accuracy_decimals=2,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
CONF_APPARENT_ENERGY: sensor.sensor_schema(
unit_of_measurement=UNIT_KILOVOLT_AMPS_HOURS,
accuracy_decimals=2,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
CONF_ACTIVE_POWER: sensor.sensor_schema(
@ -101,13 +97,11 @@ SENSORS = {
CONF_REACTIVE_POWER: sensor.sensor_schema(
unit_of_measurement=UNIT_VOLT_AMPS_REACTIVE,
accuracy_decimals=3,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
CONF_APPARENT_POWER: sensor.sensor_schema(
unit_of_measurement=UNIT_VOLT_AMPS,
accuracy_decimals=3,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
CONF_VOLTAGE: sensor.sensor_schema(
@ -142,13 +136,11 @@ SENSORS = {
CONF_MAXIMUM_DEMAND_REACTIVE_POWER: sensor.sensor_schema(
unit_of_measurement=UNIT_VOLT_AMPS_REACTIVE,
accuracy_decimals=3,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
CONF_MAXIMUM_DEMAND_APPARENT_POWER: sensor.sensor_schema(
unit_of_measurement=UNIT_VOLT_AMPS,
accuracy_decimals=3,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
}

View File

@ -90,6 +90,6 @@ async def to_code(config):
async def select_set_to_code(config, action_id, template_arg, args):
paren = await cg.get_variable(config[CONF_ID])
var = cg.new_Pvariable(action_id, template_arg, paren)
template_ = await cg.templatable(config[CONF_OPTION], args, str)
template_ = await cg.templatable(config[CONF_OPTION], args, cg.std_string)
cg.add(var.set_option(template_))
return var

View File

@ -60,7 +60,7 @@ SN74HC595_PIN_SCHEMA = cv.All(
{
cv.GenerateID(): cv.declare_id(SN74HC595GPIOPin),
cv.Required(CONF_SN74HC595): cv.use_id(SN74HC595Component),
cv.Required(CONF_NUMBER): cv.int_range(min=0, max=7),
cv.Required(CONF_NUMBER): cv.int_range(min=0, max=31),
cv.Optional(CONF_MODE, default={}): cv.All(
{
cv.Optional(CONF_OUTPUT, default=True): cv.All(

View File

@ -9,6 +9,6 @@ void TeleInfoSensor::publish_val(const std::string &val) {
auto newval = parse_float(val);
publish_state(*newval);
}
void TeleInfoSensor::dump_config() { LOG_SENSOR(" ", tag.c_str(), this); }
void TeleInfoSensor::dump_config() { LOG_SENSOR(" ", "Teleinfo Sensor", this); }
} // namespace teleinfo
} // namespace esphome

View File

@ -141,21 +141,22 @@ void TeleInfo::loop() {
field_len = get_field(tag_, buf_finger, grp_end, separator_, MAX_TAG_SIZE);
if (!field_len || field_len >= MAX_TAG_SIZE) {
ESP_LOGE(TAG, "Invalid tag.");
break;
continue;
}
/* Advance buf_finger to after the tag and the separator. */
buf_finger += field_len + 1;
/*
* If there is two separators and the tag is not equal to "DATE",
* it means there is a timestamp to read first.
* If there is two separators and the tag is not equal to "DATE" or
* historical mode is not in use (separator_ != 0x20), it means there is a
* timestamp to read first.
*/
if (std::count(buf_finger, grp_end, separator_) == 2 && strcmp(tag_, "DATE") != 0) {
if (std::count(buf_finger, grp_end, separator_) == 2 && strcmp(tag_, "DATE") != 0 && separator_ != 0x20) {
field_len = get_field(timestamp_, buf_finger, grp_end, separator_, MAX_TIMESTAMP_SIZE);
if (!field_len || field_len >= MAX_TIMESTAMP_SIZE) {
ESP_LOGE(TAG, "Invalid Timestamp");
break;
ESP_LOGE(TAG, "Invalid timestamp for tag %s", timestamp_);
continue;
}
/* Advance buf_finger to after the first data and the separator. */
@ -164,8 +165,8 @@ void TeleInfo::loop() {
field_len = get_field(val_, buf_finger, grp_end, separator_, MAX_VAL_SIZE);
if (!field_len || field_len >= MAX_VAL_SIZE) {
ESP_LOGE(TAG, "Invalid Value");
break;
ESP_LOGE(TAG, "Invalid value for tag %s", tag_);
continue;
}
/* Advance buf_finger to end of group */

View File

@ -6,6 +6,6 @@ namespace teleinfo {
static const char *const TAG = "teleinfo_text_sensor";
TeleInfoTextSensor::TeleInfoTextSensor(const char *tag) { this->tag = std::string(tag); }
void TeleInfoTextSensor::publish_val(const std::string &val) { publish_state(val); }
void TeleInfoTextSensor::dump_config() { LOG_TEXT_SENSOR(" ", tag.c_str(), this); }
void TeleInfoTextSensor::dump_config() { LOG_TEXT_SENSOR(" ", "Teleinfo Text Sensor", this); }
} // namespace teleinfo
} // namespace esphome

View File

@ -1,6 +1,6 @@
"""Constants used by esphome."""
__version__ = "2021.10.2"
__version__ = "2021.10.3"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"

View File

@ -214,6 +214,7 @@ def include_file(path, basename):
ARDUINO_GLUE_CODE = """\
#define yield() esphome::yield()
#define millis() esphome::millis()
#define micros() esphome::micros()
#define delay(x) esphome::delay(x)
#define delayMicroseconds(x) esphome::delayMicroseconds(x)
"""