pi_portal.modules.integrations.gpio.components.contact_switch.ContactSwitch

class pi_portal.modules.integrations.gpio.components.contact_switch.ContactSwitch(pin_number: int, pin_name: str)[source]

Bases: GPIOInputBase[Optional[bool]]

GPIO input for a contact switch.

__init__(pin_number: int, pin_name: str) None[source]
has_changed() bool

Query the state to see if it has changed since the last poll.

Returns:

A boolean indicating if the state has changed.

Return type:

bool

hook_setup_input() None[source]

Initialize the GPIO input.

hook_update_state() bool[source]

Retrieve new state for the GPIO input.

Returns:

The new GPIO state value.

Return type:

bool

poll() None

Update the state of the GPIO input.

property sensor_type: str

Returns the name of the input type. The default behaviour is to return the implementation’s class name.

Returns:

The input’s name.