ESPHome  2024.4.1
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 
12 namespace esphome {
13 namespace alarm_control_panel {
14 
15 enum AlarmControlPanelFeature : uint8_t {
16  // Matches Home Assistant values
20  ACP_FEAT_TRIGGER = 1 << 3,
23 };
24 
25 class AlarmControlPanel : public EntityBase {
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 
153  void disarm(optional<std::string> code = nullopt);
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
AlarmControlPanelState get_state() const
Get the state.
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_cleared_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel clears from triggered.
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 arm_vacation(optional< std::string > code=nullopt)
arm the alarm in vacation mode
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 add_on_disarmed_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel changes to disarmed. ...
void arm_night(optional< std::string > code=nullopt)
arm the alarm in night mode
virtual bool get_requires_code() const =0
Returns if the alarm_control_panel has a code.
bool is_state_armed(AlarmControlPanelState state)
void publish_state(AlarmControlPanelState state)
Set the state of the alarm_control_panel.
AlarmControlPanelCall make_call()
Make a AlarmControlPanelCall.
void add_on_chime_callback(std::function< void()> &&callback)
Add a callback for when a chime zone goes from closed to open.
void disarm(optional< std::string > code=nullopt)
disarm the alarm
void arm_home(optional< std::string > code=nullopt)
arm the alarm in home mode
const nullopt_t nullopt((nullopt_t::init()))
void arm_custom_bypass(optional< std::string > code=nullopt)
arm the alarm in custom bypass mode
virtual void control(const AlarmControlPanelCall &call)=0
void add_on_state_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel changes.
void arm_away(optional< std::string > code=nullopt)
arm the alarm in away mode
void add_on_pending_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel changes to pending.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
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.
virtual uint32_t get_supported_features() const =0
A numeric representation of the supported features as per HomeAssistant.
void add_on_ready_callback(std::function< void()> &&callback)
Add a callback for when a ready state changes.
void add_on_arming_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel chanes to arming.
bool state
Definition: fan.h:34
virtual bool get_requires_code_to_arm() const =0
Returns if the alarm_control_panel requires a code to arm.