mirror of
https://github.com/esphome/esphome.git
synced 2024-12-19 16:07:47 +01:00
commit
ab86ddcf02
@ -29,6 +29,7 @@ from esphome.const import (
|
|||||||
DEVICE_CLASS_EMPTY,
|
DEVICE_CLASS_EMPTY,
|
||||||
DEVICE_CLASS_BATTERY,
|
DEVICE_CLASS_BATTERY,
|
||||||
DEVICE_CLASS_BATTERY_CHARGING,
|
DEVICE_CLASS_BATTERY_CHARGING,
|
||||||
|
DEVICE_CLASS_CARBON_MONOXIDE,
|
||||||
DEVICE_CLASS_COLD,
|
DEVICE_CLASS_COLD,
|
||||||
DEVICE_CLASS_CONNECTIVITY,
|
DEVICE_CLASS_CONNECTIVITY,
|
||||||
DEVICE_CLASS_DOOR,
|
DEVICE_CLASS_DOOR,
|
||||||
@ -63,6 +64,7 @@ DEVICE_CLASSES = [
|
|||||||
DEVICE_CLASS_EMPTY,
|
DEVICE_CLASS_EMPTY,
|
||||||
DEVICE_CLASS_BATTERY,
|
DEVICE_CLASS_BATTERY,
|
||||||
DEVICE_CLASS_BATTERY_CHARGING,
|
DEVICE_CLASS_BATTERY_CHARGING,
|
||||||
|
DEVICE_CLASS_CARBON_MONOXIDE,
|
||||||
DEVICE_CLASS_COLD,
|
DEVICE_CLASS_COLD,
|
||||||
DEVICE_CLASS_CONNECTIVITY,
|
DEVICE_CLASS_CONNECTIVITY,
|
||||||
DEVICE_CLASS_DOOR,
|
DEVICE_CLASS_DOOR,
|
||||||
|
@ -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");
|
ESP_LOGVV(TAG, "parse_device(): manufacturer data element length is expected to be of length 7");
|
||||||
return false;
|
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");
|
ESP_LOGVV(TAG, "parse_device(): unexpected data");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,7 @@ void ModbusController::queue_command(const ModbusCommandItem &command) {
|
|||||||
// check if this commmand is already qeued.
|
// check if this commmand is already qeued.
|
||||||
// not very effective but the queue is never really large
|
// not very effective but the queue is never really large
|
||||||
for (auto &item : command_queue_) {
|
for (auto &item : command_queue_) {
|
||||||
if (item->register_address == command.register_address && item->register_count == command.register_count &&
|
if (item->is_equal(command)) {
|
||||||
item->register_type == command.register_type && item->function_code == command.function_code) {
|
|
||||||
ESP_LOGW(TAG, "Duplicate modbus command found: type=0x%x address=%u count=%u",
|
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);
|
static_cast<uint8_t>(command.register_type), command.register_address, command.register_count);
|
||||||
// update the payload of the queued command
|
// update the payload of the queued command
|
||||||
@ -489,6 +488,15 @@ bool ModbusCommandItem::send() {
|
|||||||
return true;
|
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) {
|
void number_to_payload(std::vector<uint16_t> &data, int64_t value, SensorValueType value_type) {
|
||||||
switch (value_type) {
|
switch (value_type) {
|
||||||
case SensorValueType::U_WORD:
|
case SensorValueType::U_WORD:
|
||||||
|
@ -395,6 +395,8 @@ class ModbusCommandItem {
|
|||||||
ModbusController *modbusdevice, const std::vector<uint16_t> &values,
|
ModbusController *modbusdevice, const std::vector<uint16_t> &values,
|
||||||
std::function<void(ModbusRegisterType register_type, uint16_t start_address, const std::vector<uint8_t> &data)>
|
std::function<void(ModbusRegisterType register_type, uint16_t start_address, const std::vector<uint8_t> &data)>
|
||||||
&&handler = nullptr);
|
&&handler = nullptr);
|
||||||
|
|
||||||
|
bool is_equal(const ModbusCommandItem &other);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Modbus controller class.
|
/** Modbus controller class.
|
||||||
|
@ -744,7 +744,8 @@ def rc6_binary_sensor(var, config):
|
|||||||
var.set_data(
|
var.set_data(
|
||||||
cg.StructInitializer(
|
cg.StructInitializer(
|
||||||
RC6Data,
|
RC6Data,
|
||||||
("device", config[CONF_DEVICE]),
|
("mode", 0),
|
||||||
|
("toggle", 0),
|
||||||
("address", config[CONF_ADDRESS]),
|
("address", config[CONF_ADDRESS]),
|
||||||
("command", config[CONF_COMMAND]),
|
("command", config[CONF_COMMAND]),
|
||||||
)
|
)
|
||||||
|
@ -353,7 +353,7 @@ void WebServer::handle_sensor_request(AsyncWebServerRequest *request, const UrlM
|
|||||||
if (obj->get_object_id() != match.id)
|
if (obj->get_object_id() != match.id)
|
||||||
continue;
|
continue;
|
||||||
std::string data = this->sensor_json(obj, obj->state, DETAIL_STATE);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
request->send(404);
|
request->send(404);
|
||||||
@ -377,7 +377,7 @@ void WebServer::handle_text_sensor_request(AsyncWebServerRequest *request, const
|
|||||||
if (obj->get_object_id() != match.id)
|
if (obj->get_object_id() != match.id)
|
||||||
continue;
|
continue;
|
||||||
std::string data = this->text_sensor_json(obj, obj->state, DETAIL_STATE);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
request->send(404);
|
request->send(404);
|
||||||
@ -406,7 +406,7 @@ void WebServer::handle_switch_request(AsyncWebServerRequest *request, const UrlM
|
|||||||
|
|
||||||
if (request->method() == HTTP_GET) {
|
if (request->method() == HTTP_GET) {
|
||||||
std::string data = this->switch_json(obj, obj->state, DETAIL_STATE);
|
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") {
|
} else if (match.method == "toggle") {
|
||||||
this->defer([obj]() { obj->toggle(); });
|
this->defer([obj]() { obj->toggle(); });
|
||||||
request->send(200);
|
request->send(200);
|
||||||
@ -462,7 +462,7 @@ void WebServer::handle_binary_sensor_request(AsyncWebServerRequest *request, con
|
|||||||
if (obj->get_object_id() != match.id)
|
if (obj->get_object_id() != match.id)
|
||||||
continue;
|
continue;
|
||||||
std::string data = this->binary_sensor_json(obj, obj->state, DETAIL_STATE);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
request->send(404);
|
request->send(404);
|
||||||
@ -490,7 +490,7 @@ void WebServer::handle_fan_request(AsyncWebServerRequest *request, const UrlMatc
|
|||||||
|
|
||||||
if (request->method() == HTTP_GET) {
|
if (request->method() == HTTP_GET) {
|
||||||
std::string data = this->fan_json(obj, DETAIL_STATE);
|
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") {
|
} else if (match.method == "toggle") {
|
||||||
this->defer([obj]() { obj->toggle().perform(); });
|
this->defer([obj]() { obj->toggle().perform(); });
|
||||||
request->send(200);
|
request->send(200);
|
||||||
@ -551,7 +551,7 @@ void WebServer::handle_light_request(AsyncWebServerRequest *request, const UrlMa
|
|||||||
|
|
||||||
if (request->method() == HTTP_GET) {
|
if (request->method() == HTTP_GET) {
|
||||||
std::string data = this->light_json(obj, DETAIL_STATE);
|
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") {
|
} else if (match.method == "toggle") {
|
||||||
this->defer([obj]() { obj->toggle().perform(); });
|
this->defer([obj]() { obj->toggle().perform(); });
|
||||||
request->send(200);
|
request->send(200);
|
||||||
@ -630,7 +630,7 @@ void WebServer::handle_cover_request(AsyncWebServerRequest *request, const UrlMa
|
|||||||
|
|
||||||
if (request->method() == HTTP_GET) {
|
if (request->method() == HTTP_GET) {
|
||||||
std::string data = this->cover_json(obj, DETAIL_STATE);
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,7 +687,7 @@ void WebServer::handle_number_request(AsyncWebServerRequest *request, const UrlM
|
|||||||
|
|
||||||
if (request->method() == HTTP_GET) {
|
if (request->method() == HTTP_GET) {
|
||||||
std::string data = this->number_json(obj, obj->state, DETAIL_STATE);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (match.method != "set") {
|
if (match.method != "set") {
|
||||||
@ -741,7 +741,7 @@ void WebServer::handle_select_request(AsyncWebServerRequest *request, const UrlM
|
|||||||
|
|
||||||
if (request->method() == HTTP_GET) {
|
if (request->method() == HTTP_GET) {
|
||||||
std::string data = this->select_json(obj, obj->state, DETAIL_STATE);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,7 +788,7 @@ void WebServer::handle_climate_request(AsyncWebServerRequest *request, const Url
|
|||||||
|
|
||||||
if (request->method() == HTTP_GET) {
|
if (request->method() == HTTP_GET) {
|
||||||
std::string data = this->climate_json(obj, DETAIL_STATE);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -926,7 +926,7 @@ void WebServer::handle_lock_request(AsyncWebServerRequest *request, const UrlMat
|
|||||||
|
|
||||||
if (request->method() == HTTP_GET) {
|
if (request->method() == HTTP_GET) {
|
||||||
std::string data = this->lock_json(obj, obj->state, DETAIL_STATE);
|
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") {
|
} else if (match.method == "lock") {
|
||||||
this->defer([obj]() { obj->lock(); });
|
this->defer([obj]() { obj->lock(); });
|
||||||
request->send(200);
|
request->send(200);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2022.6.2"
|
__version__ = "2022.6.3"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user