pi_portal.modules.integrations.gpio.components.contact_switch

ContactSwitch class.

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

GPIO input for a door contact switch.

Parameters:
  • pin_number (int) – The GPIO input number.

  • pin_name (str) – The name of this door 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.

hook_setup_input()[source]

Initialize the GPIO input.

Return type:

None

hook_update_state()[source]

Retrieve new state for 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.