mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	Fix BYPASS_AUTO feature to work with or without an arming delay (#9051)
This commit is contained in:
		| @@ -110,15 +110,7 @@ void TemplateAlarmControlPanel::loop() { | ||||
|       delay = this->arming_night_time_; | ||||
|     } | ||||
|     if ((millis() - this->last_update_) > delay) { | ||||
| #ifdef USE_BINARY_SENSOR | ||||
|       for (auto sensor_info : this->sensor_map_) { | ||||
|         // Check for sensors left on and set to bypass automatically and remove them from monitoring | ||||
|         if ((sensor_info.second.flags & BINARY_SENSOR_MODE_BYPASS_AUTO) && (sensor_info.first->state)) { | ||||
|           ESP_LOGW(TAG, "%s is left on and will be automatically bypassed", sensor_info.first->get_name().c_str()); | ||||
|           this->bypassed_sensor_indicies_.push_back(sensor_info.second.store_index); | ||||
|         } | ||||
|       } | ||||
| #endif | ||||
|       this->bypass_before_arming(); | ||||
|       this->publish_state(this->desired_state_); | ||||
|     } | ||||
|     return; | ||||
| @@ -259,10 +251,23 @@ void TemplateAlarmControlPanel::arm_(optional<std::string> code, alarm_control_p | ||||
|   if (delay > 0) { | ||||
|     this->publish_state(ACP_STATE_ARMING); | ||||
|   } else { | ||||
|     this->bypass_before_arming(); | ||||
|     this->publish_state(state); | ||||
|   } | ||||
| } | ||||
|  | ||||
| void TemplateAlarmControlPanel::bypass_before_arming() { | ||||
| #ifdef USE_BINARY_SENSOR | ||||
|   for (auto sensor_info : this->sensor_map_) { | ||||
|     // Check for sensors left on and set to bypass automatically and remove them from monitoring | ||||
|     if ((sensor_info.second.flags & BINARY_SENSOR_MODE_BYPASS_AUTO) && (sensor_info.first->state)) { | ||||
|       ESP_LOGW(TAG, "'%s' is left on and will be automatically bypassed", sensor_info.first->get_name().c_str()); | ||||
|       this->bypassed_sensor_indicies_.push_back(sensor_info.second.store_index); | ||||
|     } | ||||
|   } | ||||
| #endif | ||||
| } | ||||
|  | ||||
| void TemplateAlarmControlPanel::control(const AlarmControlPanelCall &call) { | ||||
|   if (call.get_state()) { | ||||
|     if (call.get_state() == ACP_STATE_ARMED_AWAY) { | ||||
|   | ||||
| @@ -60,6 +60,7 @@ class TemplateAlarmControlPanel : public alarm_control_panel::AlarmControlPanel, | ||||
|   bool get_requires_code_to_arm() const override { return this->requires_code_to_arm_; } | ||||
|   bool get_all_sensors_ready() { return this->sensors_ready_; }; | ||||
|   void set_restore_mode(TemplateAlarmControlPanelRestoreMode restore_mode) { this->restore_mode_ = restore_mode; } | ||||
|   void bypass_before_arming(); | ||||
|  | ||||
| #ifdef USE_BINARY_SENSOR | ||||
|   /** Add a binary_sensor to the alarm_panel. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user