Closed hen6e closed 2 months ago
You are aiming to keep the gpio's state even over a system reboot?
Currently it's not keeping state over a system reboot. At reboot al gpio's return to off
for what I've seen, and at initialization the gpio
state is read from the board, therefore should always be off
. Only way to keep the state over a reboot is to initialize from a stored state from hass, Is something I could look into to add, offcourse, could be a useful feature indeed ..
In my board, there are two gpios with external pull-up resistors. After reboot, the pin is tied to high due to the resistor even though gpio is not driven by raspberry at this period.
Shortly, I would like to know if switch element can show real IO status rather than the driven status?
I think I found something. Initialization requires either active
or inactive
as output_value
, defaulting to inactive
, so for every initialization all of the gpio
's are always initialized with inactive
. I might have found a workaround getting the gpio
before initialization and using that value as input .. aiming for an update next weekend if this works
This seems to be a workaround, but I think it is better to regularly check IO status by reading. In this method IO status will reflect its real logic level If this IO is changed by other software or external excitations.
Thanks.
J de Neef @.***> 于2024年8月21日周三 15:45写道:
I think I found something. Initialization requires either active or inactive as output_value, defaulting to inactive, so for every initialization all of the gpio's are always initialized with inactive. I might have found a workaround getting the gpio before initialization and using that value as input .. aiming for an update next weekend if this works
— Reply to this email directly, view it on GitHub https://github.com/jdeneef/ha_gpiod/issues/13#issuecomment-2301366802, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZKTWPSWOFR2PULYWZ6BQ3ZSRAPZAVCNFSM6AAAAABMXQLS42VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBRGM3DMOBQGI . You are receiving this because you authored the thread.Message ID: @.***>
not sure if I understand correctly, are you switching via rpi gpio
or do you want the gpio
to reflect the status as from an external source (eg external switch)? If the latter, that's what the binary_sensor
is for, that sensor is listening for edge_events
, and reading the status at edge changes (eg high->low or low->high).
I added logic to read the initial state of a gpio at start in 1.2.5 pre-release. GPIO
states and switches should survive homeassistant restarts now. Should also fix reboots if gpio is externally powered/triggered. Please test.
Note that there is 1 potential issue , for eg floating issues reading the initial state can return active
, en thereby set the switch to active
potentially triggering a connected device. Setting bias: PULL_DOWN
for inactive switch fixed it for me
Hi Developer,
I config a GPIO in Raspberry CM4 as switch, this switch can correctly control GPIO's high or low states. But it can not display correct status after system reboot. For example: If GPIO is high after reboot, the switch componment still show off even though I do not set invert_logic or active_low.
Thanks.