ESPHome 2026.1.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 this->code_ = code;
15 return *this;
16}
17
22
27
32
37
42
47
52
57
60
62 if (this->state_.has_value()) {
63 auto state = *this->state_;
64 if (this->parent_->is_state_armed(state) && this->parent_->get_state() != ACP_STATE_DISARMED) {
65 ESP_LOGW(TAG, "Cannot arm when not disarmed");
66 this->state_.reset();
67 return;
68 }
70 ESP_LOGW(TAG, "Cannot trip alarm when disarmed");
71 this->state_.reset();
72 return;
73 }
74 if (state == ACP_STATE_DISARMED && !this->parent_->is_state_armed(this->parent_->get_state()) &&
75 this->parent_->get_state() != ACP_STATE_PENDING && this->parent_->get_state() != ACP_STATE_ARMING &&
76 this->parent_->get_state() != ACP_STATE_TRIGGERED) {
77 ESP_LOGW(TAG, "Cannot disarm when not armed");
78 this->state_.reset();
79 return;
80 }
82 ESP_LOGW(TAG, "Cannot arm home when not supported");
83 this->state_.reset();
84 return;
85 }
87 ESP_LOGW(TAG, "Cannot arm night when not supported");
88 this->state_.reset();
89 return;
90 }
91 }
92}
93
95 this->validate_();
96 if (this->state_) {
97 this->parent_->control(*this);
98 }
99}
100
101} // namespace esphome::alarm_control_panel
const optional< AlarmControlPanelState > & get_state() const
AlarmControlPanelCall & set_code(const std::string &code)
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:0