pi_portal.modules.integrations.gpio.components.bases.sensor
GPIOSensorBase class.
- class pi_portal.modules.integrations.gpio.components.bases.sensor.GPIOSensorBase(pin_number, pin_name, initial_state)[source]
GPIO sensor base representation.
- Parameters:
pin_number (
int) – The GPIO input number.pin_name (
str) – The name of this input in alerts and logs.initial_state (
Any) – The value to initially set the state to.
- has_changed()
Query the state to see if it has changed since the last poll.
- Return type:
bool- Returns:
A boolean indicating if the state has changed.
- abstract hook_setup_hardware()[source]
Override to return the hardware sensor that can be used during polling.
- Return type:
Any- Returns:
A pollable hardware interface.
- hook_setup_input()
Override to initialize the GPIO input. This is optional.
- Return type:
None- Returns:
The new GPIO state value.
- abstract hook_update_state()
Override to return the current state of the GPIO Input.
- Return type:
Any- Returns:
The new GPIO state value.
- poll()
Update the state of the GPIO input.
- Return type:
None
- property sensor_type: str
Returns the name of the input type. The default behaviour is to return the implementation’s class name.
- Returns:
The inputs name.