mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
midea: New power_toggle action. Auto-use remote transmitter. (#3496)
This commit is contained in:
parent
d9d2edeb08
commit
7092f7663e
4 changed files with 38 additions and 9 deletions
|
@ -56,6 +56,11 @@ template<typename... Ts> class PowerOffAction : public MideaActionBase<Ts...> {
|
|||
void play(Ts... x) override { this->parent_->do_power_off(); }
|
||||
};
|
||||
|
||||
template<typename... Ts> class PowerToggleAction : public MideaActionBase<Ts...> {
|
||||
public:
|
||||
void play(Ts... x) override { this->parent_->do_power_toggle(); }
|
||||
};
|
||||
|
||||
} // namespace ac
|
||||
} // namespace midea
|
||||
} // namespace esphome
|
||||
|
|
|
@ -39,6 +39,7 @@ class AirConditioner : public ApplianceBase<dudanov::midea::ac::AirConditioner>,
|
|||
void do_beeper_off() { this->set_beeper_feedback(false); }
|
||||
void do_power_on() { this->base_.setPowerState(true); }
|
||||
void do_power_off() { this->base_.setPowerState(false); }
|
||||
void do_power_toggle() { this->base_.setPowerState(this->mode == ClimateMode::CLIMATE_MODE_OFF); }
|
||||
void set_supported_modes(const std::set<ClimateMode> &modes) { this->supported_modes_ = modes; }
|
||||
void set_supported_swing_modes(const std::set<ClimateSwingMode> &modes) { this->supported_swing_modes_ = modes; }
|
||||
void set_supported_presets(const std::set<ClimatePreset> &presets) { this->supported_presets_ = presets; }
|
||||
|
|
|
@ -113,7 +113,7 @@ CONFIG_SCHEMA = cv.All(
|
|||
cv.Optional(CONF_PERIOD, default="1s"): cv.time_period,
|
||||
cv.Optional(CONF_TIMEOUT, default="2s"): cv.time_period,
|
||||
cv.Optional(CONF_NUM_ATTEMPTS, default=3): cv.int_range(min=1, max=5),
|
||||
cv.Optional(CONF_TRANSMITTER_ID): cv.use_id(
|
||||
cv.OnlyWith(CONF_TRANSMITTER_ID, "remote_transmitter"): cv.use_id(
|
||||
remote_transmitter.RemoteTransmitterComponent
|
||||
),
|
||||
cv.Optional(CONF_BEEPER, default=False): cv.boolean,
|
||||
|
@ -163,6 +163,7 @@ BeeperOnAction = midea_ac_ns.class_("BeeperOnAction", automation.Action)
|
|||
BeeperOffAction = midea_ac_ns.class_("BeeperOffAction", automation.Action)
|
||||
PowerOnAction = midea_ac_ns.class_("PowerOnAction", automation.Action)
|
||||
PowerOffAction = midea_ac_ns.class_("PowerOffAction", automation.Action)
|
||||
PowerToggleAction = midea_ac_ns.class_("PowerToggleAction", automation.Action)
|
||||
|
||||
MIDEA_ACTION_BASE_SCHEMA = cv.Schema(
|
||||
{
|
||||
|
@ -249,6 +250,16 @@ async def power_off_to_code(var, config, args):
|
|||
pass
|
||||
|
||||
|
||||
# Power Toggle action
|
||||
@register_action(
|
||||
"power_toggle",
|
||||
PowerToggleAction,
|
||||
cv.Schema({}),
|
||||
)
|
||||
async def power_inv_to_code(var, config, args):
|
||||
pass
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
|
|
|
@ -1901,14 +1901,6 @@ script:
|
|||
preset: SLEEP
|
||||
|
||||
switch:
|
||||
- platform: template
|
||||
name: MIDEA_AC_TOGGLE_LIGHT
|
||||
turn_on_action:
|
||||
midea_ac.display_toggle:
|
||||
- platform: template
|
||||
name: MIDEA_AC_SWING_STEP
|
||||
turn_on_action:
|
||||
midea_ac.swing_step:
|
||||
- platform: template
|
||||
name: MIDEA_AC_BEEPER_CONTROL
|
||||
optimistic: true
|
||||
|
@ -2834,3 +2826,23 @@ button:
|
|||
id: scd40
|
||||
- scd4x.factory_reset:
|
||||
id: scd40
|
||||
- platform: template
|
||||
name: Midea Display Toggle
|
||||
on_press:
|
||||
midea_ac.display_toggle:
|
||||
- platform: template
|
||||
name: Midea Swing Step
|
||||
on_press:
|
||||
midea_ac.swing_step:
|
||||
- platform: template
|
||||
name: Midea Power On
|
||||
on_press:
|
||||
midea_ac.power_on:
|
||||
- platform: template
|
||||
name: Midea Power Off
|
||||
on_press:
|
||||
midea_ac.power_off:
|
||||
- platform: template
|
||||
name: Midea Power Inverse
|
||||
on_press:
|
||||
midea_ac.power_toggle:
|
||||
|
|
Loading…
Reference in a new issue