pyg90alarm.entities.sensor

Provides interface to sensors of G90 alarm panel.

Classes

G90Sensor(*args, parent, subindex, ...)

Interacts with sensor on G90 alarm panel.

flag pyg90alarm.entities.sensor.G90SensorReservedFlags(value)

Bases: IntFlag

Reserved flags of the sensor.

Member Type:

int

Valid values are as follows:

CAN_READ = <G90SensorReservedFlags.CAN_READ: 16>
CAN_READ_EXT = <G90SensorReservedFlags.CAN_READ_EXT: 32>
CAN_WRITE = <G90SensorReservedFlags.CAN_WRITE: 1>

The Flag and its members also have the following methods:

conjugate()

Returns self, the complex conjugate of any int.

bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

real

the real part of a complex number

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

denominator

the denominator of a rational number in lowest terms

flag pyg90alarm.entities.sensor.G90SensorUserFlags(value)

Bases: IntFlag

User flags of the sensor.

Member Type:

int

Valid values are as follows:

ENABLED = <G90SensorUserFlags.ENABLED: 1>
ARM_DELAY = <G90SensorUserFlags.ARM_DELAY: 2>
DETECT_DOOR = <G90SensorUserFlags.DETECT_DOOR: 4>
DOOR_CHIME = <G90SensorUserFlags.DOOR_CHIME: 8>
INDEPENDENT_ZONE = <G90SensorUserFlags.INDEPENDENT_ZONE: 16>
ALERT_WHEN_AWAY_AND_HOME = <G90SensorUserFlags.ALERT_WHEN_AWAY_AND_HOME: 32>
ALERT_WHEN_AWAY = <G90SensorUserFlags.ALERT_WHEN_AWAY: 64>
SUPPORTS_UPDATING_SUBTYPE = <G90SensorUserFlags.SUPPORTS_UPDATING_SUBTYPE: 512>

The Flag and its members also have the following methods:

conjugate()

Returns self, the complex conjugate of any int.

bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

real

the real part of a complex number

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

denominator

the denominator of a rational number in lowest terms

enum pyg90alarm.entities.sensor.G90SensorAlertModes(value)

Bases: IntEnum

Dedicated alert modes for the sensors (subset of user flags).

Member Type:

int

Valid values are as follows:

ALERT_ALWAYS = <G90SensorAlertModes.ALERT_ALWAYS: 0>
ALERT_WHEN_AWAY = <G90SensorAlertModes.ALERT_WHEN_AWAY: 1>
ALERT_WHEN_AWAY_AND_HOME = <G90SensorAlertModes.ALERT_WHEN_AWAY_AND_HOME: 2>

The Enum and its members also have the following methods:

conjugate()

Returns self, the complex conjugate of any int.

bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

real

the real part of a complex number

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

denominator

the denominator of a rational number in lowest terms

class pyg90alarm.entities.sensor.G90Sensor(*args, parent, subindex, proto_idx, **kwargs)

Bases: G90BaseEntity

Interacts with sensor on G90 alarm panel.

Parameters:
  • args (Any) – Pass-through positional arguments for for interpreting protocol fields

  • parent (G90Alarm) – Instance of G90Alarm the sensor is associated with

  • subindex (int) – Index of the sensor within multi-channel devices (those having multiple nodes)

  • proto_idx (int) – Index of the sensor within list of sensors as retrieved from the alarm panel

  • kwargs (Any) – Pass-through keyword arguments for for interpreting protocol fields

property definition: G90PeripheralDefinition | None

Returns the definition for the sensor.

Returns:

Sensor definition

update(obj)

Updates sensor from another instance.

Parameters:

obj (G90Sensor) – Sensor instance to update from

Return type:

None

property name: str

Sensor name, accounting for multi-channel entities (single protocol entity results in multiple G90Sensor instances).

Returns:

Sensor name

property state_callback: G90CallbackList[Callable[[bool], None] | Callable[[bool], Coroutine[None, None, None]]]

Callback that is invoked when the sensor changes its state.

Returns:

Sensor state callback

See also

G90Alarm.sensor_callback for compatiblity notes

property low_battery_callback: G90CallbackList[Callable[[], None] | Callable[[], Coroutine[None, None, None]]]

Callback that is invoked when the sensor reports on low battery condition.

Returns:

Sensor’s low battery callback

See also

G90Alarm.sensor_callback for compatiblity notes

property door_open_when_arming_callback: G90CallbackList[Callable[[], None] | Callable[[], Coroutine[None, None, None]]]

Callback that is invoked when the sensor reports on open door condition when arming.

Returns:

Sensor’s door open when arming callback

See also

G90Alarm.sensor_callback for compatiblity notes

property tamper_callback: G90CallbackList[Callable[[], None] | Callable[[], Coroutine[None, None, None]]]

Callback that is invoked when the sensor reports being tampered.

Returns:

Sensor’s tamper callback

See also

G90Alarm.sensor_callback for compatiblity notes

property occupancy: bool

Occupancy (occupied/not occupied, or triggered/not triggered) for the sensor.

Returns:

Sensor occupancy

property protocol: G90PeripheralProtocols

Protocol type of the sensor.

Returns:

Protocol type

property type: G90PeripheralTypes

Type of the sensor.

Returns:

Sensor type

property subtype: int

Sub-type of the sensor.

Returns:

Sensor sub-type

property reserved: G90SensorReservedFlags

Reserved flags (read/write mode) for the sensor.

Returns:

Reserved flags

property user_flag: G90SensorUserFlags

User flags for the sensor, retained for compatibility - please use :attr:user_flags instead.

Returns:

User flags

property user_flags: G90SensorUserFlags

User flags for the sensor (disabled/enabled, arming type etc).

Returns:

User flags

property node_count: int

Number of nodes (channels) for the sensor.

Returns:

Number of nodes

property parent: G90Alarm

Parent instance of alarm panel class the sensor is associated with.

Returns:

Parent instance

property index: int

Index (internal position) of the sensor in the alarm panel.

Returns:

Internal sensor position

property subindex: int

Index of the sensor within multi-node device.

Returns:

Index of sensor in multi-node device.

property proto_idx: int

Index of the sensor within list of sensors as retrieved from the alarm panel.

Returns:

Index of sensor in list of sensors.

property type_name: str | None

Type of the sensor.

Returns:

Type

property supports_updates: bool

Indicates if the sensor supports updates.

Returns:

Support for updates

property supports_enable_disable: bool

Indicates if disabling/enabling the sensor is supported.

Returns:

Support for enabling/disabling the sensor

property protocol_data: G90SensorIncomingData

Protocol data of the sensor.

Returns:

Protocol data

property is_wireless: bool

Indicates if the sensor is wireless.

property is_low_battery: bool

Indicates if the sensor is reporting low battery.

The condition is cleared when the sensor reports activity (i.e. is no longer low on battery as it is able to report the activity).

property is_tampered: bool

Indicates if the sensor has been tampered.

The condition is cleared when panel is armed/disarmed next time.

property is_door_open_when_arming: bool

Indicates if the sensor reports on open door when arming.

The condition is cleared when panel is armed/disarmed next time.

async set_user_flag(value)

Sets user flags of the sensor, retained for compatibility - please use :meth:set_user_flags instead.

Return type:

None

async set_user_flags(value)

Sets user flags of the sensor.

Parameters:

value (G90SensorUserFlags) – User flags to set, values other than G90SensorUserFlags.USER_SETTABLE will be ignored and preserved from existing sensor flags.

Return type:

None

async set_name(value)

Sets sensor name on the panel.

For multi-node entities the name is shared by all nodes on the panel; node suffixes are derived locally when the name is read.

Parameters:

value (str) – Name to set.

Return type:

None

get_flag(flag)

Gets the user flag for the sensor.

Parameters:

flag (G90SensorUserFlags) – User flag to get

Return type:

bool

Returns:

User flag value

async set_flag(flag, value)

Sets the user flag for the sensor.

Parameters:
Return type:

None

property enabled: bool

Indicates if the sensor is enabled, using :meth:get_user_flag instead is preferred.

Returns:

If sensor is enabled

async set_enabled(value)

Sets the sensor enabled/disabled, using :meth:set_user_flag instead is preferred.

Parameters:

value (bool) – New the sensor should be enabled

Return type:

None

property alert_mode: G90SensorAlertModes

Alert mode for the sensor.

Returns:

Alert mode

async set_alert_mode(value)

Sets the sensor alert mode.

Return type:

None

property extra_data: Any

Extra data for the sensor, that can be used to store caller-specific information and will be carried by the sensor instance.

property is_unavailable: bool

Indicates if the sensor is unavailable (e.g. has been removed).

async delete()

Deletes the sensor from the alarm panel.

Return type:

None