ESPHome 2025.5.0
Loading...
Searching...
No Matches
alarm_control_panel.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4
7
10#include "esphome/core/log.h"
11
12namespace esphome {
13namespace alarm_control_panel {
14
16 // Matches Home Assistant values
23};
24
26 public:
31
37
42 void add_on_state_callback(std::function<void()> &&callback);
43
48 void add_on_triggered_callback(std::function<void()> &&callback);
49
54 void add_on_arming_callback(std::function<void()> &&callback);
55
60 void add_on_pending_callback(std::function<void()> &&callback);
61
66 void add_on_armed_home_callback(std::function<void()> &&callback);
67
72 void add_on_armed_night_callback(std::function<void()> &&callback);
73
78 void add_on_armed_away_callback(std::function<void()> &&callback);
79
84 void add_on_disarmed_callback(std::function<void()> &&callback);
85
90 void add_on_cleared_callback(std::function<void()> &&callback);
91
96 void add_on_chime_callback(std::function<void()> &&callback);
97
102 void add_on_ready_callback(std::function<void()> &&callback);
103
107 virtual uint32_t get_supported_features() const = 0;
108
112 virtual bool get_requires_code() const = 0;
113
117 virtual bool get_requires_code_to_arm() const = 0;
118
124
130
136
142
148
154
159
160 // is the state one of the armed states
162
163 protected:
165 // in order to store last panel state in flash
167 // current state
169 // the desired (or previous) state
171 // last time the state was updated
172 uint32_t last_update_;
173 // the call control function
174 virtual void control(const AlarmControlPanelCall &call) = 0;
175 // state callback
177 // trigger callback
179 // arming callback
181 // pending callback
183 // armed_home callback
185 // armed_night callback
187 // armed_away callback
189 // disarmed callback
191 // clear callback
193 // chime callback
195 // ready callback
197};
198
199} // namespace alarm_control_panel
200} // namespace esphome
void add_on_triggered_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel chanes to triggered.
void add_on_state_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel changes.
bool is_state_armed(AlarmControlPanelState state)
void add_on_pending_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel changes to pending.
void add_on_armed_night_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel changes to armed_night.
void add_on_armed_home_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel changes to armed_home.
void arm_vacation(optional< std::string > code=nullopt)
arm the alarm in vacation mode
virtual uint32_t get_supported_features() const =0
A numeric representation of the supported features as per HomeAssistant.
void arm_home(optional< std::string > code=nullopt)
arm the alarm in home mode
void arm_away(optional< std::string > code=nullopt)
arm the alarm in away mode
AlarmControlPanelState get_state() const
Get the state.
void arm_night(optional< std::string > code=nullopt)
arm the alarm in night mode
virtual bool get_requires_code_to_arm() const =0
Returns if the alarm_control_panel requires a code to arm.
void add_on_armed_away_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel changes to armed_away.
void arm_custom_bypass(optional< std::string > code=nullopt)
arm the alarm in custom bypass mode
virtual bool get_requires_code() const =0
Returns if the alarm_control_panel has a code.
void publish_state(AlarmControlPanelState state)
Set the state of the alarm_control_panel.
void disarm(optional< std::string > code=nullopt)
disarm the alarm
void add_on_ready_callback(std::function< void()> &&callback)
Add a callback for when a ready state changes.
void add_on_cleared_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel clears from triggered.
void add_on_disarmed_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel changes to disarmed.
void add_on_chime_callback(std::function< void()> &&callback)
Add a callback for when a chime zone goes from closed to open.
void add_on_arming_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel chanes to arming.
AlarmControlPanelCall make_call()
Make a AlarmControlPanelCall.
virtual void control(const AlarmControlPanelCall &call)=0
bool state
Definition fan.h:0
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
const nullopt_t nullopt((nullopt_t::init()))