Merge pull request #3692 from esphome/bump-2022.6.3

2022.6.3
This commit is contained in:
Jesse Hills 2022-08-08 11:48:35 +12:00 committed by GitHub
commit ab86ddcf02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 16 deletions

View file

@ -29,6 +29,7 @@ from esphome.const import (
DEVICE_CLASS_EMPTY,
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_BATTERY_CHARGING,
DEVICE_CLASS_CARBON_MONOXIDE,
DEVICE_CLASS_COLD,
DEVICE_CLASS_CONNECTIVITY,
DEVICE_CLASS_DOOR,
@ -63,6 +64,7 @@ DEVICE_CLASSES = [
DEVICE_CLASS_EMPTY,
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_BATTERY_CHARGING,
DEVICE_CLASS_CARBON_MONOXIDE,
DEVICE_CLASS_COLD,
DEVICE_CLASS_CONNECTIVITY,
DEVICE_CLASS_DOOR,

View file

@ -55,7 +55,7 @@ bool InkbirdIbstH1Mini::parse_device(const esp32_ble_tracker::ESPBTDevice &devic
ESP_LOGVV(TAG, "parse_device(): manufacturer data element length is expected to be of length 7");
return false;
}
if (mnf_data.data[6] != 8) {
if ((mnf_data.data[6] != 8) && (mnf_data.data[6] != 6)) {
ESP_LOGVV(TAG, "parse_device(): unexpected data");
return false;
}

View file

@ -108,8 +108,7 @@ void ModbusController::queue_command(const ModbusCommandItem &command) {
// check if this commmand is already qeued.
// not very effective but the queue is never really large
for (auto &item : command_queue_) {
if (item->register_address == command.register_address && item->register_count == command.register_count &&
item->register_type == command.register_type && item->function_code == command.function_code) {
if (item->is_equal(command)) {
ESP_LOGW(TAG, "Duplicate modbus command found: type=0x%x address=%u count=%u",
static_cast<uint8_t>(command.register_type), command.register_address, command.register_count);
// update the payload of the queued command
@ -489,6 +488,15 @@ bool ModbusCommandItem::send() {
return true;
}
bool ModbusCommandItem::is_equal(const ModbusCommandItem &other) {
// for custom commands we have to check for identical payloads, since
// address/count/type fields will be set to zero
return this->function_code == ModbusFunctionCode::CUSTOM
? this->payload == other.payload
: other.register_address == this->register_address && other.register_count == this->register_count &&
other.register_type == this->register_type && other.function_code == this->function_code;
}
void number_to_payload(std::vector<uint16_t> &data, int64_t value, SensorValueType value_type) {
switch (value_type) {
case SensorValueType::U_WORD:

View file

@ -395,6 +395,8 @@ class ModbusCommandItem {
ModbusController *modbusdevice, const std::vector<uint16_t> &values,
std::function<void(ModbusRegisterType register_type, uint16_t start_address, const std::vector<uint8_t> &data)>
&&handler = nullptr);
bool is_equal(const ModbusCommandItem &other);
};
/** Modbus controller class.

View file

@ -744,7 +744,8 @@ def rc6_binary_sensor(var, config):
var.set_data(
cg.StructInitializer(
RC6Data,
("device", config[CONF_DEVICE]),
("mode", 0),
("toggle", 0),
("address", config[CONF_ADDRESS]),
("command", config[CONF_COMMAND]),
)

View file

@ -353,7 +353,7 @@ void WebServer::handle_sensor_request(AsyncWebServerRequest *request, const UrlM
if (obj->get_object_id() != match.id)
continue;
std::string data = this->sensor_json(obj, obj->state, DETAIL_STATE);
request->send(200, "text/json", data.c_str());
request->send(200, "application/json", data.c_str());
return;
}
request->send(404);
@ -377,7 +377,7 @@ void WebServer::handle_text_sensor_request(AsyncWebServerRequest *request, const
if (obj->get_object_id() != match.id)
continue;
std::string data = this->text_sensor_json(obj, obj->state, DETAIL_STATE);
request->send(200, "text/json", data.c_str());
request->send(200, "application/json", data.c_str());
return;
}
request->send(404);
@ -406,7 +406,7 @@ void WebServer::handle_switch_request(AsyncWebServerRequest *request, const UrlM
if (request->method() == HTTP_GET) {
std::string data = this->switch_json(obj, obj->state, DETAIL_STATE);
request->send(200, "text/json", data.c_str());
request->send(200, "application/json", data.c_str());
} else if (match.method == "toggle") {
this->defer([obj]() { obj->toggle(); });
request->send(200);
@ -462,7 +462,7 @@ void WebServer::handle_binary_sensor_request(AsyncWebServerRequest *request, con
if (obj->get_object_id() != match.id)
continue;
std::string data = this->binary_sensor_json(obj, obj->state, DETAIL_STATE);
request->send(200, "text/json", data.c_str());
request->send(200, "application/json", data.c_str());
return;
}
request->send(404);
@ -490,7 +490,7 @@ void WebServer::handle_fan_request(AsyncWebServerRequest *request, const UrlMatc
if (request->method() == HTTP_GET) {
std::string data = this->fan_json(obj, DETAIL_STATE);
request->send(200, "text/json", data.c_str());
request->send(200, "application/json", data.c_str());
} else if (match.method == "toggle") {
this->defer([obj]() { obj->toggle().perform(); });
request->send(200);
@ -551,7 +551,7 @@ void WebServer::handle_light_request(AsyncWebServerRequest *request, const UrlMa
if (request->method() == HTTP_GET) {
std::string data = this->light_json(obj, DETAIL_STATE);
request->send(200, "text/json", data.c_str());
request->send(200, "application/json", data.c_str());
} else if (match.method == "toggle") {
this->defer([obj]() { obj->toggle().perform(); });
request->send(200);
@ -630,7 +630,7 @@ void WebServer::handle_cover_request(AsyncWebServerRequest *request, const UrlMa
if (request->method() == HTTP_GET) {
std::string data = this->cover_json(obj, DETAIL_STATE);
request->send(200, "text/json", data.c_str());
request->send(200, "application/json", data.c_str());
continue;
}
@ -687,7 +687,7 @@ void WebServer::handle_number_request(AsyncWebServerRequest *request, const UrlM
if (request->method() == HTTP_GET) {
std::string data = this->number_json(obj, obj->state, DETAIL_STATE);
request->send(200, "text/json", data.c_str());
request->send(200, "application/json", data.c_str());
return;
}
if (match.method != "set") {
@ -741,7 +741,7 @@ void WebServer::handle_select_request(AsyncWebServerRequest *request, const UrlM
if (request->method() == HTTP_GET) {
std::string data = this->select_json(obj, obj->state, DETAIL_STATE);
request->send(200, "text/json", data.c_str());
request->send(200, "application/json", data.c_str());
return;
}
@ -788,7 +788,7 @@ void WebServer::handle_climate_request(AsyncWebServerRequest *request, const Url
if (request->method() == HTTP_GET) {
std::string data = this->climate_json(obj, DETAIL_STATE);
request->send(200, "text/json", data.c_str());
request->send(200, "application/json", data.c_str());
return;
}
@ -926,7 +926,7 @@ void WebServer::handle_lock_request(AsyncWebServerRequest *request, const UrlMat
if (request->method() == HTTP_GET) {
std::string data = this->lock_json(obj, obj->state, DETAIL_STATE);
request->send(200, "text/json", data.c_str());
request->send(200, "application/json", data.c_str());
} else if (match.method == "lock") {
this->defer([obj]() { obj->lock(); });
request->send(200);

View file

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