Compare commits
3 Commits
dev
...
zhlt01-hea
Author | SHA1 | Date | |
---|---|---|---|
|
c3b22083d9 | ||
|
578671ea94 | ||
|
d10300c330 |
@ -58,6 +58,7 @@ PROTOCOLS = {
|
||||
"sharp": Protocol.PROTOCOL_SHARP,
|
||||
"toshiba_daiseikai": Protocol.PROTOCOL_TOSHIBA_DAISEIKAI,
|
||||
"toshiba": Protocol.PROTOCOL_TOSHIBA,
|
||||
"zhlt01": Protocol.PROTOCOL_ZHLT01,
|
||||
}
|
||||
|
||||
CONF_HORIZONTAL_DEFAULT = "horizontal_default"
|
||||
|
@ -53,6 +53,7 @@ const std::map<Protocol, std::function<HeatpumpIR *()>> PROTOCOL_CONSTRUCTOR_MAP
|
||||
{PROTOCOL_SHARP, []() { return new SharpHeatpumpIR(); }}, // NOLINT
|
||||
{PROTOCOL_TOSHIBA_DAISEIKAI, []() { return new ToshibaDaiseikaiHeatpumpIR(); }}, // NOLINT
|
||||
{PROTOCOL_TOSHIBA, []() { return new ToshibaHeatpumpIR(); }}, // NOLINT
|
||||
{PROTOCOL_ZHLT01, []() { return new ZHLT01HeatpumpIR(); }}, // NOLINT
|
||||
};
|
||||
|
||||
void HeatpumpIRClimate::setup() {
|
||||
|
@ -53,6 +53,7 @@ enum Protocol {
|
||||
PROTOCOL_SHARP,
|
||||
PROTOCOL_TOSHIBA_DAISEIKAI,
|
||||
PROTOCOL_TOSHIBA,
|
||||
PROTOCOL_ZHLT01,
|
||||
};
|
||||
|
||||
// Simple enum to represent horizontal directios
|
||||
|
@ -108,8 +108,7 @@ void ModbusController::queue_command(const ModbusCommandItem &command) {
|
||||
// check if this command 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:
|
||||
|
@ -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.
|
||||
|
@ -749,6 +749,7 @@ CONF_WAND_ID = "wand_id"
|
||||
CONF_WARM_WHITE = "warm_white"
|
||||
CONF_WARM_WHITE_COLOR_TEMPERATURE = "warm_white_color_temperature"
|
||||
CONF_WATCHDOG_THRESHOLD = "watchdog_threshold"
|
||||
CONF_WEB_SERVER = "web_server"
|
||||
CONF_WEIGHT = "weight"
|
||||
CONF_WHILE = "while"
|
||||
CONF_WHITE = "white"
|
||||
|
@ -9,6 +9,7 @@ from esphome.const import (
|
||||
CONF_ESPHOME,
|
||||
CONF_USE_ADDRESS,
|
||||
CONF_ETHERNET,
|
||||
CONF_WEB_SERVER,
|
||||
CONF_WIFI,
|
||||
CONF_PORT,
|
||||
KEY_CORE,
|
||||
@ -512,7 +513,7 @@ class EsphomeCore:
|
||||
if self.config is None:
|
||||
raise ValueError("Config has not been loaded yet")
|
||||
|
||||
if "wifi" in self.config:
|
||||
if CONF_WIFI in self.config:
|
||||
return self.config[CONF_WIFI][CONF_USE_ADDRESS]
|
||||
|
||||
if CONF_ETHERNET in self.config:
|
||||
@ -525,9 +526,9 @@ class EsphomeCore:
|
||||
if self.config is None:
|
||||
raise ValueError("Config has not been loaded yet")
|
||||
|
||||
if "web_server" in self.config:
|
||||
if CONF_WEB_SERVER in self.config:
|
||||
try:
|
||||
return self.config["web_server"][CONF_PORT]
|
||||
return self.config[CONF_WEB_SERVER][CONF_PORT]
|
||||
except KeyError:
|
||||
return 80
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user