pi_portal.modules.integrations.gpio.components.bases.sensor_base.GPIOSensorBase
- class pi_portal.modules.integrations.gpio.components.bases.sensor_base.GPIOSensorBase(pin_number: int, pin_name: str, initial_state: TypeState)[source]
Bases:
GPIOInputBase[TypeState],ABC,Generic[TypeState,TypeHardware]GPIO sensor base representation.
- Parameters:
pin_number – The GPIO input number.
pin_name – The name of this input in alerts and logs.
initial_state – The value to initially set the state to.
- 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
- abstract hook_setup_hardware() TypeHardware[source]
Override to return the hardware sensor that can be used during polling.
- Returns:
A pollable hardware interface.
- Return type:
TypeHardware
- hook_setup_input() None
Override to initialize the GPIO input. This is optional.
- abstract hook_update_state() TypeState
Override to return the current state of the GPIO Input.
- Returns:
The new GPIO state value.
- Return type:
TypeState
- 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.