ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
template_alarm_control_panel.h
Go to the documentation of this file.
1#pragma once
2
3#include <cinttypes>
4#include <cstring>
5#include <vector>
6
11
13
14#ifdef USE_BINARY_SENSOR
16#endif
17
18namespace esphome::template_ {
19
20#ifdef USE_BINARY_SENSOR
28
35
36#endif
37
42
43#ifdef USE_BINARY_SENSOR
50
55#endif
56
58 public:
60 void dump_config() override;
61 void setup() override;
62 void loop() override;
63 uint32_t get_supported_features() const override;
64 bool get_requires_code() const override { return !this->codes_.empty(); }
65 bool get_requires_code_to_arm() const override { return this->requires_code_to_arm_; }
66 bool get_all_sensors_ready() { return this->sensors_ready_; };
67 void set_restore_mode(TemplateAlarmControlPanelRestoreMode restore_mode) { this->restore_mode_ = restore_mode; }
68 // Remove before 2026.10.0
69 ESPDEPRECATED("bypass_before_arming() is deprecated and will be removed in 2026.10.0", "2026.4.0")
70 void bypass_before_arming() { this->auto_bypass_sensors_(); }
71
72#ifdef USE_BINARY_SENSOR
77 void init_sensors(size_t capacity) { this->sensors_.init(capacity); }
78
85 void add_sensor(binary_sensor::BinarySensor *sensor, uint8_t flags = 0,
87#endif
88
93 void set_codes(std::initializer_list<const char *> codes) { this->codes_ = codes; }
94
95 // Deleted overload to catch incorrect std::string usage at compile time
96 void set_codes(std::initializer_list<std::string> codes) = delete;
97
102 void set_requires_code_to_arm(bool code_to_arm) { this->requires_code_to_arm_ = code_to_arm; }
103
109
115
121
126 void set_pending_time(uint32_t time) { this->pending_time_ = time; }
127
132 void set_trigger_time(uint32_t time) { this->trigger_time_ = time; }
133
134 void set_supports_arm_home(bool supports_arm_home) { supports_arm_home_ = supports_arm_home; }
135
136 void set_supports_arm_night(bool supports_arm_night) { supports_arm_night_ = supports_arm_night; }
137
138 protected:
140#ifdef USE_BINARY_SENSOR
141 // List of binary sensors with their alarm-specific info
143#endif
145
146 // the arming away delay
148 // the arming home delay
150 // the arming night delay
152 // the trigger delay
154 // the time in trigger
156 // a list of codes (const char* pointers to string literals in flash)
158 // requires a code to arm
160 bool supports_arm_home_ = false;
162 bool sensors_ready_ = false;
163 // check if the code is valid
164 bool is_code_valid_(optional<std::string> code);
165
166 void arm_(optional<std::string> code, alarm_control_panel::AlarmControlPanelState state, uint32_t delay);
169};
170
171} // namespace esphome::template_
Fixed-capacity vector - allocates once at runtime, never reallocates This avoids std::vector template...
Definition helpers.h:522
bool empty() const
Definition helpers.h:680
Base class for all binary_sensor-type classes.
void set_codes(std::initializer_list< const char * > codes)
Set the codes (from initializer list).
void set_restore_mode(TemplateAlarmControlPanelRestoreMode restore_mode)
void set_trigger_time(uint32_t time)
set the delay before resetting after triggered
void arm_(optional< std::string > code, alarm_control_panel::AlarmControlPanelState state, uint32_t delay)
void set_arming_night_time(uint32_t time)
set the delay before arming night
void set_pending_time(uint32_t time)
set the delay before triggering
ESPDEPRECATED("bypass_before_arming() is deprecated and will be removed in 2026.10.0", "2026.4.0") void bypass_before_arming()
void set_arming_home_time(uint32_t time)
set the delay before arming home
void add_sensor(binary_sensor::BinarySensor *sensor, uint8_t flags=0, AlarmSensorType type=ALARM_SENSOR_TYPE_DELAYED)
Add a binary_sensor to the alarm_panel.
void control(const alarm_control_panel::AlarmControlPanelCall &call) override
void set_codes(std::initializer_list< std::string > codes)=delete
void init_sensors(size_t capacity)
Initialize the sensors vector with the specified capacity.
void set_arming_away_time(uint32_t time)
set the delay before arming away
void set_requires_code_to_arm(bool code_to_arm)
set requires a code to arm
uint16_t type
uint16_t flags
bool state
Definition fan.h:2
void HOT delay(uint32_t ms)
Definition core.cpp:28
uint16_t uint16_t & capacity
Definition helpers.cpp:25
static void uint32_t