mirror of
https://github.com/esphome/esphome.git
synced 2024-11-30 10:44:13 +01:00
fix midea: undo approved PR#4053 (#5233)
This commit is contained in:
parent
be6f95d43e
commit
3717e34bba
3 changed files with 14 additions and 26 deletions
|
@ -1488,11 +1488,9 @@ MideaData, MideaBinarySensor, MideaTrigger, MideaAction, MideaDumper = declare_p
|
||||||
MideaAction = ns.class_("MideaAction", RemoteTransmitterActionBase)
|
MideaAction = ns.class_("MideaAction", RemoteTransmitterActionBase)
|
||||||
MIDEA_SCHEMA = cv.Schema(
|
MIDEA_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Required(CONF_CODE): cv.templatable(
|
cv.Required(CONF_CODE): cv.All(
|
||||||
cv.All(
|
|
||||||
[cv.Any(cv.hex_uint8_t, cv.uint8_t)],
|
[cv.Any(cv.hex_uint8_t, cv.uint8_t)],
|
||||||
cv.Length(min=5, max=5),
|
cv.Length(min=5, max=5),
|
||||||
)
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -1519,12 +1517,10 @@ def midea_dumper(var, config):
|
||||||
MIDEA_SCHEMA,
|
MIDEA_SCHEMA,
|
||||||
)
|
)
|
||||||
async def midea_action(var, config, args):
|
async def midea_action(var, config, args):
|
||||||
code_ = config[CONF_CODE]
|
template_ = await cg.templatable(
|
||||||
if cg.is_template(code_):
|
config[CONF_CODE], args, cg.std_vector.template(cg.uint8)
|
||||||
template_ = await cg.templatable(code_, args, cg.std_vector.template(cg.uint8))
|
)
|
||||||
cg.add(var.set_code_template(template_))
|
cg.add(var.set_code(template_))
|
||||||
else:
|
|
||||||
cg.add(var.set_code_static(code_))
|
|
||||||
|
|
||||||
|
|
||||||
# AEHA
|
# AEHA
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "remote_base.h"
|
#include "remote_base.h"
|
||||||
#include <array>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace remote_base {
|
namespace remote_base {
|
||||||
|
@ -84,23 +84,13 @@ using MideaDumper = RemoteReceiverDumper<MideaProtocol, MideaData>;
|
||||||
|
|
||||||
template<typename... Ts> class MideaAction : public RemoteTransmitterActionBase<Ts...> {
|
template<typename... Ts> class MideaAction : public RemoteTransmitterActionBase<Ts...> {
|
||||||
TEMPLATABLE_VALUE(std::vector<uint8_t>, code)
|
TEMPLATABLE_VALUE(std::vector<uint8_t>, code)
|
||||||
void set_code_static(std::vector<uint8_t> code) { code_static_ = std::move(code); }
|
void set_code(std::initializer_list<uint8_t> code) { this->code_ = code; }
|
||||||
void set_code_template(std::function<std::vector<uint8_t>(Ts...)> func) { this->code_func_ = func; }
|
|
||||||
|
|
||||||
void encode(RemoteTransmitData *dst, Ts... x) override {
|
void encode(RemoteTransmitData *dst, Ts... x) override {
|
||||||
MideaData data;
|
MideaData data(this->code_.value(x...));
|
||||||
if (!this->code_static_.empty()) {
|
|
||||||
data = MideaData(this->code_static_);
|
|
||||||
} else {
|
|
||||||
data = MideaData(this->code_func_(x...));
|
|
||||||
}
|
|
||||||
data.finalize();
|
data.finalize();
|
||||||
MideaProtocol().encode(dst, data);
|
MideaProtocol().encode(dst, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
|
||||||
std::function<std::vector<uint8_t>(Ts...)> code_func_{};
|
|
||||||
std::vector<uint8_t> code_static_{};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace remote_base
|
} // namespace remote_base
|
||||||
|
|
|
@ -2333,6 +2333,8 @@ switch:
|
||||||
second: !lambda "return 0xB21F98;"
|
second: !lambda "return 0xB21F98;"
|
||||||
- remote_transmitter.transmit_midea:
|
- remote_transmitter.transmit_midea:
|
||||||
code: [0xA2, 0x08, 0xFF, 0xFF, 0xFF]
|
code: [0xA2, 0x08, 0xFF, 0xFF, 0xFF]
|
||||||
|
- remote_transmitter.transmit_midea:
|
||||||
|
code: !lambda "return {0xA2, 0x08, 0xFF, 0xFF, 0xFF};"
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: "MCP23S08 Pin #0"
|
name: "MCP23S08 Pin #0"
|
||||||
pin:
|
pin:
|
||||||
|
|
Loading…
Reference in a new issue