2023-11-05 19:49:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "esphome/components/cover/cover.h"
|
|
|
|
#include "esphome/core/automation.h"
|
|
|
|
#include "esphome/core/component.h"
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
namespace ratgdo {
|
|
|
|
|
|
|
|
class CoverOpeningTrigger : public Trigger<> {
|
|
|
|
public:
|
|
|
|
CoverOpeningTrigger(cover::Cover* a_cover)
|
|
|
|
{
|
|
|
|
a_cover->add_on_state_callback([this, a_cover]() {
|
|
|
|
if (a_cover->current_operation == cover::COVER_OPERATION_OPENING) {
|
|
|
|
this->trigger();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CoverClosingTrigger : public Trigger<> {
|
|
|
|
public:
|
|
|
|
CoverClosingTrigger(cover::Cover* a_cover)
|
|
|
|
{
|
|
|
|
a_cover->add_on_state_callback([this, a_cover]() {
|
|
|
|
if (a_cover->current_operation == cover::COVER_OPERATION_CLOSING) {
|
|
|
|
this->trigger();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-07-11 20:45:08 +00:00
|
|
|
class CoverStateTrigger : public Trigger<> {
|
|
|
|
public:
|
|
|
|
CoverStateTrigger(cover::Cover* a_cover)
|
|
|
|
{
|
|
|
|
a_cover->add_on_state_callback([this, a_cover]() {
|
|
|
|
this->trigger();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-11-05 19:49:59 +00:00
|
|
|
} // namespace ratgdo
|
|
|
|
} // namespace esphome
|