diff --git a/esphome/components/template/alarm_control_panel/__init__.py b/esphome/components/template/alarm_control_panel/__init__.py index 3555f2fafd..646ee220d0 100644 --- a/esphome/components/template/alarm_control_panel/__init__.py +++ b/esphome/components/template/alarm_control_panel/__init__.py @@ -58,6 +58,7 @@ ALARM_SENSOR_TYPES = { "DELAYED": AlarmSensorType.ALARM_SENSOR_TYPE_DELAYED, "INSTANT": AlarmSensorType.ALARM_SENSOR_TYPE_INSTANT, "DELAYED_FOLLOWER": AlarmSensorType.ALARM_SENSOR_TYPE_DELAYED_FOLLOWER, + "INSTANT_ALWAYS": AlarmSensorType.ALARM_SENSOR_TYPE_INSTANT_ALWAYS, } diff --git a/esphome/components/template/alarm_control_panel/template_alarm_control_panel.cpp b/esphome/components/template/alarm_control_panel/template_alarm_control_panel.cpp index 99843417fa..894962e522 100644 --- a/esphome/components/template/alarm_control_panel/template_alarm_control_panel.cpp +++ b/esphome/components/template/alarm_control_panel/template_alarm_control_panel.cpp @@ -58,6 +58,9 @@ void TemplateAlarmControlPanel::dump_config() { case ALARM_SENSOR_TYPE_DELAYED_FOLLOWER: sensor_type = "delayed_follower"; break; + case ALARM_SENSOR_TYPE_INSTANT_ALWAYS: + sensor_type = "instant_always"; + break; case ALARM_SENSOR_TYPE_DELAYED: default: sensor_type = "delayed"; @@ -119,19 +122,19 @@ void TemplateAlarmControlPanel::loop() { #ifdef USE_BINARY_SENSOR // Test all of the sensors in the list regardless of the alarm panel state - for (auto sensor_info : this->sensor_map_) { - // Check for chime zones - if ((sensor_info.second.flags & BINARY_SENSOR_MODE_CHIME)) { - // Look for the transition from closed to open - if ((!this->sensor_data_[sensor_info.second.store_index].last_chime_state) && (sensor_info.first->state)) { - // Must be disarmed to chime + for (auto sensor_info : this->sensor_map_) { + // Check for chime zones + if ((sensor_info.second.flags & BINARY_SENSOR_MODE_CHIME)) { + // Look for the transition from closed to open + if ((!this->sensor_data_[sensor_info.second.store_index].last_chime_state) && (sensor_info.first->state)) { + // Must be disarmed to chime if (this->current_state_ == ACP_STATE_DISARMED) { this->chime_callback_.call(); } } - // Record the sensor state change - this->sensor_data_[sensor_info.second.store_index].last_chime_state = sensor_info.first->state; - } + // Record the sensor state change + this->sensor_data_[sensor_info.second.store_index].last_chime_state = sensor_info.first->state; + } // Check for triggered sensors if (sensor_info.first->state) { // Sensor triggered? // Skip if bypass armed home @@ -145,24 +148,25 @@ void TemplateAlarmControlPanel::loop() { continue; } - // If sensor type is of type instant - if (sensor_info.second.type == ALARM_SENSOR_TYPE_INSTANT) { - instant_sensor_not_ready = true; - break; - } - // If sensor type is of type interior follower - if (sensor_info.second.type == ALARM_SENSOR_TYPE_DELAYED_FOLLOWER) { - // Look to see if we are in the pending state - if (this->current_state_ == ACP_STATE_PENDING) { - delayed_sensor_not_ready = true; - } else { + switch(sensor_info.second.type) { + case ALARM_SENSOR_TYPE_INSTANT: instant_sensor_not_ready = true; - } - } - // If sensor type is of type delayed - if (sensor_info.second.type == ALARM_SENSOR_TYPE_DELAYED) { - delayed_sensor_not_ready = true; - break; + break; + case ALARM_SENSOR_TYPE_INSTANT_ALWAYS: + instant_sensor_not_ready = true; + future_state = ACP_STATE_TRIGGERED; + break; + case ALARM_SENSOR_TYPE_DELAYED_FOLLOWER: + // Look to see if we are in the pending state + if (this->current_state_ == ACP_STATE_PENDING) { + delayed_sensor_not_ready = true; + } else { + instant_sensor_not_ready = true; + } + break; + case ALARM_SENSOR_TYPE_DELAYED: + default: + delayed_sensor_not_ready = true; } } } diff --git a/esphome/components/template/alarm_control_panel/template_alarm_control_panel.h b/esphome/components/template/alarm_control_panel/template_alarm_control_panel.h index 9ae69a0422..b29a48dfd7 100644 --- a/esphome/components/template/alarm_control_panel/template_alarm_control_panel.h +++ b/esphome/components/template/alarm_control_panel/template_alarm_control_panel.h @@ -27,7 +27,8 @@ enum BinarySensorFlags : uint16_t { enum AlarmSensorType : uint16_t { ALARM_SENSOR_TYPE_DELAYED = 0, ALARM_SENSOR_TYPE_INSTANT, - ALARM_SENSOR_TYPE_DELAYED_FOLLOWER + ALARM_SENSOR_TYPE_DELAYED_FOLLOWER, + ALARM_SENSOR_TYPE_INSTANT_ALWAYS, }; #endif