ESPHome 2026.11.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_ != nullptr; }
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
69#ifdef USE_BINARY_SENSOR
74 void init_sensors(size_t capacity) { this->sensors_.init(capacity); }
75
82 void add_sensor(binary_sensor::BinarySensor *sensor, uint8_t flags = 0,
84#endif
85
90 void set_codes(const char *const *codes) { this->codes_ = codes; }
91
96 void set_requires_code_to_arm(bool code_to_arm) { this->requires_code_to_arm_ = code_to_arm; }
97
103
109
115
120 void set_pending_time(uint32_t time) { this->pending_time_ = time; }
121
126 void set_trigger_time(uint32_t time) { this->trigger_time_ = time; }
127
128 void set_supports_arm_home(bool supports_arm_home) { supports_arm_home_ = supports_arm_home; }
129
130 void set_supports_arm_night(bool supports_arm_night) { supports_arm_night_ = supports_arm_night; }
131
132 protected:
134#ifdef USE_BINARY_SENSOR
135 // List of binary sensors with their alarm-specific info
137#endif
139
140 // the arming away delay
142 // the arming home delay
144 // the arming night delay
146 // the trigger delay
148 // the time in trigger
150 // nullptr-terminated table of codes, shared in flash
151 const char *const *codes_{nullptr};
152 // requires a code to arm
154 bool supports_arm_home_ = false;
156 bool sensors_ready_ = false;
157 // check if the code is valid
158 bool is_code_valid_(optional<std::string> code);
159
160 void arm_(optional<std::string> code, alarm_control_panel::AlarmControlPanelState state, uint32_t delay);
163};
164
165} // namespace esphome::template_
Fixed-capacity vector - sized once through init() or try_init(); push_back never reallocates This avo...
Definition helpers.h:624
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 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 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(const char *const *codes)
Set the codes.
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 flags
uint8_t type
bool state
Definition fan.h:2
void HOT delay(uint32_t ms)
Definition hal.cpp:85
uint16_t uint16_t & capacity
Definition helpers.cpp:34
static void uint32_t