ESPHome 2025.6.0
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;
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
71 void add_sensor(binary_sensor::BinarySensor *sensor, uint16_t flags = 0,
73#endif
74
79 void add_code(const std::string &code) { this->codes_.push_back(code); }
80
85 void set_requires_code_to_arm(bool code_to_arm) { this->requires_code_to_arm_ = code_to_arm; }
86
91 void set_arming_away_time(uint32_t time) { this->arming_away_time_ = time; }
92
97 void set_arming_home_time(uint32_t time) { this->arming_home_time_ = time; }
98
103 void set_arming_night_time(uint32_t time) { this->arming_night_time_ = time; }
104
109 void set_pending_time(uint32_t time) { this->pending_time_ = time; }
110
115 void set_trigger_time(uint32_t time) { this->trigger_time_ = time; }
116
117 void set_supports_arm_home(bool supports_arm_home) { supports_arm_home_ = supports_arm_home; }
118
119 void set_supports_arm_night(bool supports_arm_night) { supports_arm_night_ = supports_arm_night; }
120
121 protected:
123#ifdef USE_BINARY_SENSOR
124 // This maps a binary sensor to its type and attribute bits
125 std::map<binary_sensor::BinarySensor *, SensorInfo> sensor_map_;
126 // a list of automatically bypassed sensors
127 std::vector<uint8_t> bypassed_sensor_indicies_;
128#endif
130
131 // the arming away delay
133 // the arming home delay
134 uint32_t arming_home_time_{0};
135 // the arming night delay
137 // the trigger delay
139 // the time in trigger
141 // a list of codes
142 std::vector<std::string> codes_;
143 // Per sensor data store
144 std::vector<SensorDataStore> sensor_data_;
145 // requires a code to arm
147 bool supports_arm_home_ = false;
149 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
uint8_t type
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:29