ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
alarm_control_panel_call.cpp
Go to the documentation of this file.
2
4
5#include "esphome/core/log.h"
6
8
9static const char *const TAG = "alarm_control_panel";
10
12
14 if (code != nullptr) {
15 return this->set_code(code, strlen(code));
16 }
17 return *this;
18}
19
21 if (code != nullptr) {
22 this->code_ = std::string(code, len);
23 }
24 return *this;
25}
26
31
36
41
46
51
56
61
66
69
71 if (this->state_.has_value()) {
72 auto state = *this->state_;
73 if (this->parent_->is_state_armed(state) && this->parent_->get_state() != ACP_STATE_DISARMED) {
74 ESP_LOGW(TAG, "Cannot arm when not disarmed");
75 this->state_.reset();
76 return;
77 }
79 ESP_LOGW(TAG, "Cannot trip alarm when disarmed");
80 this->state_.reset();
81 return;
82 }
83 if (state == ACP_STATE_DISARMED && !this->parent_->is_state_armed(this->parent_->get_state()) &&
84 this->parent_->get_state() != ACP_STATE_PENDING && this->parent_->get_state() != ACP_STATE_ARMING &&
85 this->parent_->get_state() != ACP_STATE_TRIGGERED) {
86 ESP_LOGW(TAG, "Cannot disarm when not armed");
87 this->state_.reset();
88 return;
89 }
91 ESP_LOGW(TAG, "Cannot arm home when not supported");
92 this->state_.reset();
93 return;
94 }
96 ESP_LOGW(TAG, "Cannot arm night when not supported");
97 this->state_.reset();
98 return;
99 }
100 }
101}
102
104 this->validate_();
105 if (this->state_) {
106 this->parent_->control(*this);
107 }
108}
109
110} // namespace esphome::alarm_control_panel
const optional< AlarmControlPanelState > & get_state() const
bool is_state_armed(AlarmControlPanelState state)
virtual uint32_t get_supported_features() const =0
A numeric representation of the supported features as per HomeAssistant.
AlarmControlPanelState get_state() const
Get the state.
virtual void control(const AlarmControlPanelCall &call)=0
bool has_value() const
Definition optional.h:92
bool state
Definition fan.h:2
std::string size_t len
Definition helpers.h:817