ESPHome 2025.12.3
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 <vector>
5
10
12
13#ifdef USE_BINARY_SENSOR
15#endif
16
17namespace esphome::template_ {
18
19#ifdef USE_BINARY_SENSOR
27
34
35#endif
36
41
42#ifdef USE_BINARY_SENSOR
46
47struct SensorInfo {
48 uint16_t flags;
50 uint8_t store_index;
51};
52
57#endif
58
60 public:
62 void dump_config() override;
63 void setup() override;
64 void loop() override;
65 uint32_t get_supported_features() const override;
66 bool get_requires_code() const override { return !this->codes_.empty(); }
67 bool get_requires_code_to_arm() const override { return this->requires_code_to_arm_; }
68 bool get_all_sensors_ready() { return this->sensors_ready_; };
69 void set_restore_mode(TemplateAlarmControlPanelRestoreMode restore_mode) { this->restore_mode_ = restore_mode; }
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, uint16_t flags = 0,
87#endif
88
93 void add_code(const std::string &code) { this->codes_.push_back(code); }
94
99 void set_requires_code_to_arm(bool code_to_arm) { this->requires_code_to_arm_ = code_to_arm; }
100
105 void set_arming_away_time(uint32_t time) { this->arming_away_time_ = time; }
106
111 void set_arming_home_time(uint32_t time) { this->arming_home_time_ = time; }
112
117 void set_arming_night_time(uint32_t time) { this->arming_night_time_ = time; }
118
123 void set_pending_time(uint32_t time) { this->pending_time_ = time; }
124
129 void set_trigger_time(uint32_t time) { this->trigger_time_ = time; }
130
131 void set_supports_arm_home(bool supports_arm_home) { supports_arm_home_ = supports_arm_home; }
132
133 void set_supports_arm_night(bool supports_arm_night) { supports_arm_night_ = supports_arm_night; }
134
135 protected:
137#ifdef USE_BINARY_SENSOR
138 // List of binary sensors with their alarm-specific info
140 // a list of automatically bypassed sensors
141 std::vector<uint8_t> bypassed_sensor_indicies_;
142 // Per sensor data store
143 std::vector<SensorDataStore> sensor_data_;
144 uint8_t next_store_index_ = 0;
145#endif
147
148 // the arming away delay
150 // the arming home delay
151 uint32_t arming_home_time_{0};
152 // the arming night delay
154 // the trigger delay
156 // the time in trigger
158 // a list of codes
159 std::vector<std::string> codes_;
160 // requires a code to arm
162 bool supports_arm_home_ = false;
164 bool sensors_ready_ = false;
165 // check if the code is valid
167
169};
170
171} // namespace esphome::template_
Fixed-capacity vector - allocates once at runtime, never reallocates This avoids std::vector template...
Definition helpers.h:184
Base class for all binary_sensor-type classes.
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 add_sensor(binary_sensor::BinarySensor *sensor, uint16_t flags=0, AlarmSensorType type=ALARM_SENSOR_TYPE_DELAYED)
Add a binary_sensor to the alarm_panel.
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
void add_code(const std::string &code)
add a code
void set_arming_home_time(uint32_t time)
set the delay before arming home
void control(const alarm_control_panel::AlarmControlPanelCall &call) override
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:0
void IRAM_ATTR HOT delay(uint32_t ms)
Definition core.cpp:31