pyg90alarm.definitions.base
Base entities for peripheral definitions.
Functions
|
Decorator to ensure that peripheral definitions are unique by name and type/subtype/protocol. |
Classes
|
Holds peripheral definition data. |
Base class for peripheral definitions. |
- enum pyg90alarm.definitions.base.G90PeripheralProtocols(value)
Bases:
IntEnumProtocol types for the peripherals.
- Member Type:
Valid values are as follows:
- RF_1527 = <G90PeripheralProtocols.RF_1527: 0>
- RF_2262 = <G90PeripheralProtocols.RF_2262: 1>
- RF_PRIVATE = <G90PeripheralProtocols.RF_PRIVATE: 2>
- RF_SLIDER = <G90PeripheralProtocols.RF_SLIDER: 3>
- CORD = <G90PeripheralProtocols.CORD: 5>
- WIFI = <G90PeripheralProtocols.WIFI: 4>
- USB = <G90PeripheralProtocols.USB: 6>
The
Enumand 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.definitions.base.G90PeripheralTypes(value)
Bases:
IntEnumPeripheral types.
- Member Type:
Valid values are as follows:
- DOOR = <G90PeripheralTypes.DOOR: 1>
- GLASS = <G90PeripheralTypes.GLASS: 2>
- GAS = <G90PeripheralTypes.GAS: 3>
- SMOKE = <G90PeripheralTypes.SMOKE: 4>
- SOS = <G90PeripheralTypes.SOS: 5>
- VIB = <G90PeripheralTypes.VIB: 6>
- WATER = <G90PeripheralTypes.WATER: 7>
- INFRARED = <G90PeripheralTypes.INFRARED: 8>
- IN_BEAM = <G90PeripheralTypes.IN_BEAM: 9>
- REMOTE = <G90PeripheralTypes.REMOTE: 10>
- RFID = <G90PeripheralTypes.RFID: 11>
- DOORBELL = <G90PeripheralTypes.DOORBELL: 12>
- BUTTONID = <G90PeripheralTypes.BUTTONID: 13>
- WATCH = <G90PeripheralTypes.WATCH: 14>
- FINGER_LOCK = <G90PeripheralTypes.FINGER_LOCK: 15>
- SUBHOST = <G90PeripheralTypes.SUBHOST: 16>
- REMOTE_2_4G = <G90PeripheralTypes.REMOTE_2_4G: 17>
- GAS_VALVE = <G90PeripheralTypes.GAS_VALVE: 18>
- CORD_SENSOR = <G90PeripheralTypes.CORD_SENSOR: 126>
- SOCKET = <G90PeripheralTypes.SOCKET: 128>
- SIREN = <G90PeripheralTypes.SIREN: 129>
- CURTAIN = <G90PeripheralTypes.CURTAIN: 130>
- SLIDINGWIN = <G90PeripheralTypes.SLIDINGWIN: 131>
- AIRCON = <G90PeripheralTypes.AIRCON: 133>
- TV = <G90PeripheralTypes.TV: 135>
- TV_BOX = <G90PeripheralTypes.TV_BOX: 136>
- SMART_SWITCH = <G90PeripheralTypes.SMART_SWITCH: 137>
- NIGHTLIGHT = <G90PeripheralTypes.NIGHTLIGHT: 138>
- SOCKET_2_4G = <G90PeripheralTypes.SOCKET_2_4G: 140>
- SIREN_2_4G = <G90PeripheralTypes.SIREN_2_4G: 141>
- SWITCH_2_4G = <G90PeripheralTypes.SWITCH_2_4G: 142>
- TOUCH_SWITCH_2_4G = <G90PeripheralTypes.TOUCH_SWITCH_2_4G: 143>
- CURTAIN_2_4G = <G90PeripheralTypes.CURTAIN_2_4G: 144>
- IR_2_4G = <G90PeripheralTypes.IR_2_4G: 145>
- CORD_DEV = <G90PeripheralTypes.CORD_DEV: 254>
- UNKNOWN = <G90PeripheralTypes.UNKNOWN: 255>
The
Enumand 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.definitions.base.G90PeripheralMatchModes(value)
Bases:
IntEnumDefines compare (match) mode for the peripheral.
- Member Type:
Valid values are as follows:
- ALL = <G90PeripheralMatchModes.ALL: 0>
- ONLY20BITS = <G90PeripheralMatchModes.ONLY20BITS: 1>
- ONLY16BITS = <G90PeripheralMatchModes.ONLY16BITS: 2>
The
Enumand 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.definitions.base.G90PeripheralRwModes(value)
Bases:
IntEnumDefines read/write mode for the peripheral.
- Member Type:
Valid values are as follows:
- READ = <G90PeripheralRwModes.READ: 0>
- WRITE = <G90PeripheralRwModes.WRITE: 1>
- READ_WRITE = <G90PeripheralRwModes.READ_WRITE: 2>
The
Enumand 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.definitions.base.G90PeripheralDefinition(type, subtype, rx, tx, private_data, rw_mode, match_mode, name, protocol, timeout, baudrate, node_count)
Bases:
objectHolds peripheral definition data.
- pyg90alarm.definitions.base.unique_definitions(obj)
Decorator to ensure that peripheral definitions are unique by name and type/subtype/protocol.
- Parameters:
obj (
type[G90PeripheralDefinitionsBase]) – Class to decorate.- Return type:
- Returns:
Decorated class with unique definitions.
- Raises:
G90Error – If definitions are not unique.
- class pyg90alarm.definitions.base.G90PeripheralDefinitionsBase
Bases:
ABCBase class for peripheral definitions.
- abstractmethod classmethod definitions()
Get all peripheral definitions.
- Return type:
- Returns:
List of peripheral definitions.
- classmethod get_by_id(id_type, id_subtype, protocol)
Gets peripheral definition by type, subtype and protocol.
- Parameters:
id_type (
G90PeripheralTypes) – Peripheral type.id_subtype (
int) – Peripheral subtype.protocol (
G90PeripheralProtocols) – Peripheral protocol.
- Raises:
G90PeripheralDefinitionNotFound – If definition not found.
- Return type:
- classmethod get_by_name(name)
Gets peripheral definition by name.
- Parameters:
name (
str) – Peripheral name.- Raises:
G90PeripheralDefinitionNotFound – If definition not found.
- Return type: