mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/dev' into integration
This commit is contained in:
		| @@ -4,7 +4,13 @@ from esphome import pins | |||||||
| import esphome.codegen as cg | import esphome.codegen as cg | ||||||
| from esphome.components import binary_sensor | from esphome.components import binary_sensor | ||||||
| import esphome.config_validation as cv | import esphome.config_validation as cv | ||||||
| from esphome.const import CONF_ID, CONF_NAME, CONF_NUMBER, CONF_PIN | from esphome.const import ( | ||||||
|  |     CONF_ALLOW_OTHER_USES, | ||||||
|  |     CONF_ID, | ||||||
|  |     CONF_NAME, | ||||||
|  |     CONF_NUMBER, | ||||||
|  |     CONF_PIN, | ||||||
|  | ) | ||||||
| from esphome.core import CORE | from esphome.core import CORE | ||||||
|  |  | ||||||
| from .. import gpio_ns | from .. import gpio_ns | ||||||
| @@ -76,6 +82,18 @@ async def to_code(config): | |||||||
|         ) |         ) | ||||||
|         use_interrupt = False |         use_interrupt = False | ||||||
|  |  | ||||||
|  |     # Check if pin is shared with other components (allow_other_uses) | ||||||
|  |     # When a pin is shared, interrupts can interfere with other components | ||||||
|  |     # (e.g., duty_cycle sensor) that need to monitor the pin's state changes | ||||||
|  |     if use_interrupt and config[CONF_PIN].get(CONF_ALLOW_OTHER_USES, False): | ||||||
|  |         _LOGGER.info( | ||||||
|  |             "GPIO binary_sensor '%s': Disabling interrupts because pin %s is shared with other components. " | ||||||
|  |             "The sensor will use polling mode for compatibility with other pin uses.", | ||||||
|  |             config.get(CONF_NAME, config[CONF_ID]), | ||||||
|  |             config[CONF_PIN][CONF_NUMBER], | ||||||
|  |         ) | ||||||
|  |         use_interrupt = False | ||||||
|  |  | ||||||
|     cg.add(var.set_use_interrupt(use_interrupt)) |     cg.add(var.set_use_interrupt(use_interrupt)) | ||||||
|     if use_interrupt: |     if use_interrupt: | ||||||
|         cg.add(var.set_interrupt_type(config[CONF_INTERRUPT_TYPE])) |         cg.add(var.set_interrupt_type(config[CONF_INTERRUPT_TYPE])) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user