7 #ifdef USE_ALARM_CONTROL_PANEL 12 static const char *
const TAG =
"mqtt.alarm_control_panel";
17 : alarm_control_panel_(alarm_control_panel) {}
22 if (strcasecmp(payload.c_str(),
"ARM_AWAY") == 0) {
24 }
else if (strcasecmp(payload.c_str(),
"ARM_HOME") == 0) {
26 }
else if (strcasecmp(payload.c_str(),
"ARM_NIGHT") == 0) {
28 }
else if (strcasecmp(payload.c_str(),
"ARM_VACATION") == 0) {
30 }
else if (strcasecmp(payload.c_str(),
"ARM_CUSTOM_BYPASS") == 0) {
31 call.arm_custom_bypass();
32 }
else if (strcasecmp(payload.c_str(),
"DISARM") == 0) {
34 }
else if (strcasecmp(payload.c_str(),
"PENDING") == 0) {
36 }
else if (strcasecmp(payload.c_str(),
"TRIGGERED") == 0) {
39 ESP_LOGW(TAG,
"'%s': Received unknown command payload %s", this->
friendly_name().c_str(), payload.c_str());
47 LOG_MQTT_COMPONENT(
true,
true)
57 supported_features.add(
"arm_away");
60 supported_features.add(
"arm_home");
63 supported_features.add(
"arm_night");
66 supported_features.add(
"arm_vacation");
69 supported_features.add(
"arm_custom_bypass");
72 supported_features.add(
"trigger");
89 state_s =
"armed_home";
92 state_s =
"armed_away";
95 state_s =
"armed_night";
98 state_s =
"armed_vacation";
101 state_s =
"armed_custom_bypass";
110 state_s =
"disarming";
113 state_s =
"triggered";
AlarmControlPanelState get_state() const
Get the state.
const EntityBase * get_entity() const override
bool send_initial_state() override
alarm_control_panel::AlarmControlPanel * alarm_control_panel_
virtual bool get_requires_code() const =0
Returns if the alarm_control_panel has a code.
MQTTAlarmControlPanelComponent(alarm_control_panel::AlarmControlPanel *alarm_control_panel)
AlarmControlPanelCall make_call()
Make a AlarmControlPanelCall.
bool publish(const std::string &topic, const std::string &payload)
Send a MQTT message.
std::string component_type() const override
constexpr const char *const MQTT_CODE_ARM_REQUIRED
constexpr const char *const MQTT_CODE_DISARM_REQUIRED
void subscribe(const std::string &topic, mqtt_callback_t callback, uint8_t qos=0)
Subscribe to a MQTT topic.
void dump_config() override
void add_on_state_callback(std::function< void()> &&callback)
Add a callback for when the state of the alarm_control_panel changes.
Simple Helper struct used for Home Assistant MQTT send_discovery().
constexpr const char * c_str() const
constexpr const char *const MQTT_SUPPORTED_FEATURES
virtual std::string friendly_name() const
Get the friendly name of this MQTT component.
Implementation of SPI Controller mode.
std::string get_state_topic_() const
Get the MQTT topic that new states will be shared to.
virtual uint32_t get_supported_features() const =0
A numeric representation of the supported features as per HomeAssistant.
std::string get_command_topic_() const
Get the MQTT topic for listening to commands.
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
const StringRef & get_name() const
virtual bool get_requires_code_to_arm() const =0
Returns if the alarm_control_panel requires a code to arm.