pyg90alarm.cloud.messages
Cloud message implementations for G90 alarm systems.
This module provides concrete message classes for cloud communication with G90 alarm systems, including ping messages, discovery messages, status change notifications, and alarm notifications.
Functions
|
Register a cloud message class. |
Classes
|
Command response message sent by the device. |
|
Acknowledgement message sent by the cloud server in response to a hello message. |
|
Hello discovery request message sent by the device. |
|
Discovery response message from the cloud to the device. |
|
Information response message from the cloud server to a device's hello request. |
|
Hello request message sent by the device to the cloud server. |
|
Response message from the cloud server to a hello request from a device. |
|
Notification message from the device to the cloud server. |
|
Ping request message sent by the device to the cloud server. |
|
Response message for ping requests. |
|
Status change alarm request message from the device to the cloud. |
|
Status change request message from the device to the cloud. |
Status change sensor request message from the device to the cloud. |
- pyg90alarm.cloud.messages.cloud_message(obj)
Register a cloud message class.
This decorator registers the cloud message class in the global registry and ensures there are no duplicate registrations for the same command/ source/destination combination.
- Parameters:
obj (
Type[TypeVar(CloudMessageT, bound= G90CloudMessage)]) – The cloud message class to register- Return type:
- Returns:
The registered cloud message class
- Raises:
ValueError – If a class with the same command/source/destination is already registered
- class pyg90alarm.cloud.messages.G90CloudPingRespMessage(context)
Bases:
G90CloudMessageResponse message for ping requests.
A message sent in response to a ping request from the device.
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches another message.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudPingReqMessage(context)
Bases:
G90CloudMessagePing request message sent by the device to the cloud server.
This message is sent every minute as a keepalive mechanism.
- Attr _responses:
The possible response message classes
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches another message.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudHelloAckMessage(context, flag=1)
Bases:
G90CloudMessageAcknowledgement message sent by the cloud server in response to a hello message.
This message confirms receipt of the hello request from the device.
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches another message.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudHelloRespMessage(context, flag=31)
Bases:
G90CloudMessageResponse message from the cloud server to a hello request from a device.
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches another message.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudHelloInfoRespMessage(context, port=0)
Bases:
G90CloudMessageInformation response message from the cloud server to a device’s hello request.
This message contains information about the port the device should use for communication.
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches another message.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudHelloReqMessage(context, _guid, flag1, flag2, flag3, flag4, fw_ver, flag5, flag6, flag7, flag8, flag9, flag10)
Bases:
G90CloudMessageHello request message sent by the device to the cloud server.
This message is sent every minute as part of the device’s heartbeat mechanism.
- property guid: str
Get the device GUID as a string.
- Returns:
The device’s GUID decoded from bytes to string
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches another message.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudHelloDiscoveryRespMessage(context, ip_addr=b'', flag2=0, flag3=0, port=0, _timestamp=0)
Bases:
G90CloudMessageDiscovery response message from the cloud to the device.
This message contains information about the cloud server’s IP, port, and timestamp.
- property timestamp: datetime
Get the timestamp as a datetime object.
- Returns:
The message timestamp converted to a datetime object with UTC timezone
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches another message.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudHelloDiscoveryReqMessage(context, _guid, flag1, flag2, flag3, flag4, fw_ver, flag5, flag6, flag7)
Bases:
G90CloudMessageHello discovery request message sent by the device.
This message is used during the device discovery process to locate the cloud server.
- property guid: str
Get the device GUID as a string.
- Returns:
The device’s GUID decoded from bytes to string
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches another message.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudStatusChangeReqMessage(context, type, _state, _timestamp)
Bases:
G90CloudStatusChangeReqMessageBaseStatus change request message from the device to the cloud.
This message is sent when the device’s status changes, such as arming or disarming.
- property as_device_alert: G90DeviceAlert
Convert the message to a device alert object.
- Returns:
A G90DeviceAlert object constructed from the message properties
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches the expected type and format.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- property timestamp: datetime
Get the timestamp as a datetime object.
- Returns:
The message timestamp converted to a datetime object with UTC timezone.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudStatusChangeSensorReqMessage(context, type, sensor_id, _sensor_source, _sensor_state, _sensor, _timestamp)
Bases:
G90CloudStatusChangeReqMessageBaseStatus change sensor request message from the device to the cloud.
This message is sent when a sensor’s status changes, such as when motion is detected or a door/window is opened.
- property sensor: str
Get the sensor name as a string.
- Returns:
The sensor name decoded from bytes with null characters removed
- property as_device_alert: G90DeviceAlert
Convert the message to a device alert object.
- Returns:
A G90DeviceAlert object constructed from the message properties
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches the expected type and format.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- property timestamp: datetime
Get the timestamp as a datetime object.
- Returns:
The message timestamp converted to a datetime object with UTC timezone.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudStatusChangeAlarmReqMessage(context, type, sensor_id, _sensor_type, _sensor_state, _sensor, _timestamp)
Bases:
G90CloudStatusChangeReqMessageBaseStatus change alarm request message from the device to the cloud.
This message is sent when an alarm is triggered on the device, such as when an intrusion is detected or when the panic button is pressed.
- property sensor: str
Get the sensor name as a string.
- Returns:
The sensor name decoded from bytes with null characters removed
- property as_device_alert: G90DeviceAlert
Convert the message to a device alert object.
- Returns:
A G90DeviceAlert object constructed from the message properties
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches the expected type and format.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- property timestamp: datetime
Get the timestamp as a datetime object.
- Returns:
The message timestamp converted to a datetime object with UTC timezone.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudNotificationMessage(context)
Bases:
G90CloudMessageNotification message from the device to the cloud server.
This message carries notification data from the device that may include sensor data or other information.
- property as_notification_message: bytes
Extract the notification message payload.
- Returns:
The raw notification message bytes extracted from the header payload
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches another message.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.
- class pyg90alarm.cloud.messages.G90CloudCmdRespMessage(context, flag1, seq_num1, flag3, seq_num2, cmd, subcmd)
Bases:
G90CloudMessageCommand response message sent by the device.
This message contains command and sequence information.
- property body: bytes
Extract the response body payload.
- Returns:
The raw response body bytes extracted from the header payload
- classmethod format()
Get the format string for the message.
- Return type:
- Returns:
The format string.
- classmethod from_wire(data, context)
Decode a message from its wire representation.
- Parameters:
data (
bytes) – The raw bytes of the message.context (
G90CloudMessageContext) – The message context.
- Return type:
TypeVar(CloudMessageT, bound= G90CloudMessage)- Returns:
An instance of the message class.
- classmethod header_matches(value)
Check if the header matches the expected header for this message type.
- Parameters:
value (
G90CloudHeader) – The header to compare against.- Return type:
- Returns:
True if the headers match, False otherwise.
- classmethod matches(value)
Check if the message matches another message.
- Parameters:
value (
G90CloudMessage) – The message to compare against.- Return type:
- Returns:
True if the messages match, False otherwise.
- classmethod size()
Get the size of the message in bytes.
- Return type:
- Returns:
The size of the message.
- to_wire()
Encode the message to its wire representation.
- Return type:
- Returns:
The raw bytes of the message.
- wire_responses(context)
Get the wire representations of the responses to this message.
- Parameters:
context (
G90CloudMessageContext) – The message context.- Return type:
- Returns:
A list of raw bytes for the responses.