ESPHome 2025.5.0
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
7namespace esphome {
8namespace alarm_control_panel {
9
10static const char *const TAG = "alarm_control_panel";
11
13
15 this->code_ = code;
16 return *this;
17}
18
23
28
33
38
43
48
53
58
61
63 if (this->state_.has_value()) {
64 auto state = *this->state_;
65 if (this->parent_->is_state_armed(state) && this->parent_->get_state() != ACP_STATE_DISARMED) {
66 ESP_LOGW(TAG, "Cannot arm when not disarmed");
67 this->state_.reset();
68 return;
69 }
71 ESP_LOGW(TAG, "Cannot trip alarm when disarmed");
72 this->state_.reset();
73 return;
74 }
75 if (state == ACP_STATE_DISARMED && !this->parent_->is_state_armed(this->parent_->get_state()) &&
76 this->parent_->get_state() != ACP_STATE_PENDING && this->parent_->get_state() != ACP_STATE_ARMING &&
77 this->parent_->get_state() != ACP_STATE_TRIGGERED) {
78 ESP_LOGW(TAG, "Cannot disarm when not armed");
79 this->state_.reset();
80 return;
81 }
83 ESP_LOGW(TAG, "Cannot arm home when not supported");
84 this->state_.reset();
85 return;
86 }
88 ESP_LOGW(TAG, "Cannot arm night when not supported");
89 this->state_.reset();
90 return;
91 }
92 }
93}
94
96 this->validate_();
97 if (this->state_) {
98 this->parent_->control(*this);
99 }
100}
101
102} // namespace alarm_control_panel
103} // namespace esphome
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:87
bool state
Definition fan.h:0
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7