ESPHome 2025.12.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 <map>
5
9
11
12#ifdef USE_BINARY_SENSOR
14#endif
15
16namespace esphome {
17namespace template_ {
18
19#ifdef USE_BINARY_SENSOR
27
34
35#endif
36
41
45
46struct SensorInfo {
47 uint16_t flags;
49 uint8_t store_index;
50};
51
53 public:
55 void dump_config() override;
56 void setup() override;
57 void loop() override;
58 uint32_t get_supported_features() const override;
59 bool get_requires_code() const override { return !this->codes_.empty(); }
60 bool get_requires_code_to_arm() const override { return this->requires_code_to_arm_; }
61 bool get_all_sensors_ready() { return this->sensors_ready_; };
62 void set_restore_mode(TemplateAlarmControlPanelRestoreMode restore_mode) { this->restore_mode_ = restore_mode; }
64
65#ifdef USE_BINARY_SENSOR
72 void add_sensor(binary_sensor::BinarySensor *sensor, uint16_t flags = 0,
74#endif
75
80 void add_code(const std::string &code) { this->codes_.push_back(code); }
81
86 void set_requires_code_to_arm(bool code_to_arm) { this->requires_code_to_arm_ = code_to_arm; }
87
92 void set_arming_away_time(uint32_t time) { this->arming_away_time_ = time; }
93
98 void set_arming_home_time(uint32_t time) { this->arming_home_time_ = time; }
99
104 void set_arming_night_time(uint32_t time) { this->arming_night_time_ = time; }
105
110 void set_pending_time(uint32_t time) { this->pending_time_ = time; }
111
116 void set_trigger_time(uint32_t time) { this->trigger_time_ = time; }
117
118 void set_supports_arm_home(bool supports_arm_home) { supports_arm_home_ = supports_arm_home; }
119
120 void set_supports_arm_night(bool supports_arm_night) { supports_arm_night_ = supports_arm_night; }
121
122 protected:
124#ifdef USE_BINARY_SENSOR
125 // This maps a binary sensor to its alarm specific info
126 std::map<binary_sensor::BinarySensor *, SensorInfo> sensor_map_;
127 // a list of automatically bypassed sensors
128 std::vector<uint8_t> bypassed_sensor_indicies_;
129#endif
131
132 // the arming away delay
134 // the arming home delay
135 uint32_t arming_home_time_{0};
136 // the arming night delay
138 // the trigger delay
140 // the time in trigger
142 // a list of codes
143 std::vector<std::string> codes_;
144 // Per sensor data store
145 std::vector<SensorDataStore> sensor_data_;
146 // requires a code to arm
148 bool supports_arm_home_ = false;
150 bool sensors_ready_ = false;
151 uint8_t next_store_index_ = 0;
152 // check if the code is valid
154
156};
157
158} // namespace template_
159} // namespace esphome
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
std::map< binary_sensor::BinarySensor *, SensorInfo > sensor_map_
void set_arming_home_time(uint32_t time)
set the delay before arming home
void control(const alarm_control_panel::AlarmControlPanelCall &call) override
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
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
void IRAM_ATTR HOT delay(uint32_t ms)
Definition core.cpp:31