Skip to content

Commit 66365db

Browse files
bdracojesserockz
authored andcommitted
[gpio] Update binary sensor docs for allow_other_uses interrupt handling (#5137)
* [gpio] Update binary sensor docs for allow_other_uses interrupt handling * Update components/binary_sensor/gpio.rst
1 parent 3bdbadb commit 66365db

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

components/binary_sensor/gpio.rst

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,22 @@ efficient state change detection with minimal CPU usage.
3939
name: "Legacy Sensor"
4040
use_interrupt: false # Use polling instead of interrupts
4141
42+
# Example with shared pin (automatic polling mode)
43+
binary_sensor:
44+
- platform: gpio
45+
pin:
46+
number: GPIO15
47+
allow_other_uses: true # Pin is shared with other components
48+
name: "Pump Status"
49+
# Interrupts will be automatically disabled for compatibility
50+
4251
Configuration variables:
4352
------------------------
4453

4554
- **pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The pin to monitor.
4655
- **use_interrupt** (*Optional*, boolean): Use hardware interrupts instead of polling for better
47-
performance and lower CPU usage. Defaults to ``true`` for most platforms, but defaults to ``false``
48-
for LibreTiny-based platforms (BK72xx, RTL87xx, LN882x) due to hardware limitations. Only supported
56+
performance and lower CPU usage. Defaults to ``true`` for most platforms, but defaults to ``false``
57+
for LibreTiny-based platforms (BK72xx, RTL87xx, LN882x) due to hardware limitations. Only supported
4958
on internal GPIO pins.
5059
- **interrupt_type** (*Optional*, string): The type of interrupt to use. One of:
5160

@@ -78,13 +87,20 @@ The GPIO binary sensor supports two modes of operation:
7887

7988
.. note::
8089

81-
Interrupt mode is only available on internal GPIO pins. External GPIO
90+
Interrupt mode is only available on internal GPIO pins. External GPIO
8291
expanders (like PCF8574) will automatically fall back to polling mode.
8392

84-
LibreTiny-based platforms (BK72xx, RTL87xx, LN882x) default to polling mode
85-
due to hardware limitations with edge interrupts. You can explicitly enable
93+
LibreTiny-based platforms (BK72xx, RTL87xx, LN882x) default to polling mode
94+
due to hardware limitations with edge interrupts. You can explicitly enable
8695
interrupt mode if needed, but it may not work reliably on all pins.
8796

97+
.. note::
98+
99+
When a pin is configured with ``allow_other_uses: true`` (for sharing with
100+
other components), interrupts are automatically disabled to prevent conflicts.
101+
This ensures compatibility with components like ``duty_cycle`` sensors that
102+
need to monitor pin state changes. The sensor will use polling mode instead.
103+
88104
Activating internal pullups
89105
---------------------------
90106

0 commit comments

Comments
 (0)