G90 Alarm system protocol
Project description
Description
Python package to control G90-based alarm systems.
Many manufacturers sell such systems under different brands - Golden Security, PST, Kerui and others. Those are cheap low-end systems, typically equipped with WiFi and possible GSM interfaces for connectivity, and support different range of peripherals:
Wired and wireless sensors
Relays (switches)
… and probably others
The package implements asynchronous I/O over most of code paths using asyncio.
Disclaimer
The author has no affiliation or any relationship to any of the hardware vendors in question. The code has been created upon many trial and error iterations.
Motivation
The primary motivation creating the code is the comfort of using the security system - the mobile applications provided by the vendor, called “Carener”, is slow and crashes sometimes. Instead, it would be awesome to have the system integrated into larger ecosystems, like Home Assistant, HomeKit and such. Hence, the code has been created to interact with the security system using Python, and it opens up a way for further integrations.
Supported hardware
It might not be possible to list every system supported by the package due to manufacturers naming the products differently. Here is the list of hardware known to work with the package:
And the list of sensors, actual set of device should be notable larger as many of other manufacturers produce similar items. The names in parenthesis are taken from the alarm system documentation, for example, Home Alarm GB90-Plus.
Wired PIR sensors
Wireless PIR sensors (WPD01, WMS08)
Door/window sensors (WDS07, WRDS01)
Water leak sensors (LSTC01)
Smoke sensors (WSD02)
Gas sensors (WGD01)
Switches/relays (JDQ)
Basically, the alarm system uses 433 MHz communications for the wireless devices using EV1527, PT2262 protocols. The mobile application also mentions some devices using 2.4GHz, although details of the protocols haven’t been identified as no such hardware has been available for experimentation.
Known caveats
Wireless shutter sensor (WRDS01) doesn’t send anything on sensor closed, only when opened. In contrast, WDS07 wireless door sensor does both.
Wireless relays (at least JDQ) use same RF code for switching on and off, when configured in toggle mode. That means a RF signal repeater will make controlling such relays unpredictable, since the code will be sent more than once.
Low battery notifications for wireless sensors (at least for WDS07 and WSD02) are often missing, either due to the sensors not sending them or the device doesn’t receive those.
Wired sensors toggle on line state change, i.e. those aren’t limited to have normal closed (NC) or normal open (NO) contacts only. Best used with NC contact sensors though, since an intruder cutting the line will trigger the alarm.
Device notifications
Local notifications
There is a hidden device capability to send protocol notifications over the WiFi interface, thus called local. The notifications are done using broadcast UDP packets with source/destination ports being 45000:12901 (non-configurable), and sent when the device has IP address of its WiFi interface set to 10.10.10.250. That is the same IP the device will allocate to the WiFi interface when AP (access point is enabled). Please note enabling the AP is not required for the notifications to be sent, only the IP address matters. Likely the firmware does a check internally and enables those when corresponding IP address is found on the WiFi interface.
Depending on your network setup, ensuring the 10.10.10.250 IP address is allocated to the WiFi interface of the device might be as simple as DHCP reservation. Please check the documentation of your networking gear on how to set the IP address allocation up.
For the local notifications to be enabled the G90Alarm.use_local_notifications() needs to be called upon constructing an instance of G90Alarm class, then G90Alarm.listen_notifications() to start processing those coming from the panel - the code fragment below demonstrates that though being incomplete since callbacks (e.g. G90Alarm.on_armdisarm()) should be set for the actual processing of the notifications.
from pyg90alarm import G90Alarm
# Create an instance of the alarm panel
alarm = G90Alarm(host='10.10.10.250')
# Enable local notifications
await alarm.use_local_notifications()
# Start listening for notifications
await alarm.listen_notifications()
Cloud notifications
The cloud protocol is native to the panel and is used to interact with mobile application. The package can mimic the cloud server and interpret the messages the panel sends to the cloud, allowing to receive the notifications and alerts. While the protocol also allows to send commands to the panel, it is not implemented and local protocol is used for that - i.e. when cloud notifications are in use the local protocol still utilized for sending commands to the panel.
The cloud protocol is TCP based and typically interacts with cloud service at known IP address and port, which could be customized. To process the cloud notifications all the traffic from panel towards the configured IP address service needs to be received by the node where the package is running.
Please see the section for further details on the protocol.
The benefit of the cloud notifications is that the panel no longer required to have 10.10.10.250 IP address.
The package could act as:
Standalone cloud server with no Internet connectivity or cloud service required at all - good if you’d like to avoid having a vendor service involved. Please note the mobile application will show panel as offline in this mode
Chained cloud server, where in addition to interpreting the notifications it will also forward all packets received from the panel to the cloud server, and pass its responses back to the panel. This allows to have notifications processed by the package and the mobile application working as well.
The code fragments below demonstrate how to utilize both modes - please note those are incomplete, since no callbacks are set to process the notifications.
Standalone mode
from pyg90alarm import G90Alarm
# Create an instance of the alarm panel
alarm = G90Alarm(host='<panel IP address>')
# Configure cloud server address the panel should use - the host running the
# package.
await alarm.set_cloud_server_address(
cloud_ip='<host IP address running the package>', cloud_port=5678
)
# Enable cloud notifications
await alarm.use_cloud_notifications(
# The host/port the package will listen on for the cloud notifications,
# should match ones above.
cloud_ip='<host IP address running the package>',
cloud_port=5678,
cloud_local_port=5678,
upstream_host=None
)
# Start listening for notifications
await alarm.listen_notifications()
Chained mode
from pyg90alarm import G90Alarm
# Create an instance of the alarm panel
alarm = G90Alarm(host='<panel IP address>')
# Configure cloud server address the panel should use - the host running the
# package.
await alarm.set_cloud_server_address(
cloud_ip='<host IP address running the package>', cloud_port=5678
)
# Enable cloud notifications
await alarm.use_cloud_notifications(
# The host/port the package will listen on for the cloud notifications,
# should match ones above.
cloud_ip='<host IP address running the package>',
cloud_port=5678,
cloud_local_port=5678,
# Upstream cloud server address the package should forward the
# notifications to.
upstream_host='47.88.7.61',
upstream_port=5678
)
# Start listening for notifications
await alarm.listen_notifications()
Quick start
pip install pyg90alarm
Documentation
Please see online documentation for details on the protocol, its security, supported commands and the API package provides.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyg90alarm-2.7.3.tar.gz.
File metadata
- Download URL: pyg90alarm-2.7.3.tar.gz
- Upload date:
- Size: 121.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa4653e4f760fa632fd86b2771f4430e2ddf21bb45069db4607c8602fe703793
|
|
| MD5 |
a0a3ec914d264e19f0295ac4cad2513b
|
|
| BLAKE2b-256 |
9388e70759bcfa283baad11e9d4278fa0f860f6b8b78b630167361a5f97a3fac
|
Provenance
The following attestation bundles were made for pyg90alarm-2.7.3.tar.gz:
Publisher:
main.yml on hostcc/pyg90alarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyg90alarm-2.7.3.tar.gz -
Subject digest:
fa4653e4f760fa632fd86b2771f4430e2ddf21bb45069db4607c8602fe703793 - Sigstore transparency entry: 973112259
- Sigstore integration time:
-
Permalink:
hostcc/pyg90alarm@ba3c323ef63dca92ad233b5b228681cb97748061 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/hostcc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@ba3c323ef63dca92ad233b5b228681cb97748061 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyg90alarm-2.7.3-py3-none-any.whl.
File metadata
- Download URL: pyg90alarm-2.7.3-py3-none-any.whl
- Upload date:
- Size: 115.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f69ffab7c10da765d63eb0558a6ef772e86a1dc79f328339d3e4869a23fbc38
|
|
| MD5 |
1280a011a21342650321e23e5b675347
|
|
| BLAKE2b-256 |
17f9da11fa19bf4e11d74e5df1c1a4c12ad8a59014784a668ed6379053cb7560
|
Provenance
The following attestation bundles were made for pyg90alarm-2.7.3-py3-none-any.whl:
Publisher:
main.yml on hostcc/pyg90alarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyg90alarm-2.7.3-py3-none-any.whl -
Subject digest:
4f69ffab7c10da765d63eb0558a6ef772e86a1dc79f328339d3e4869a23fbc38 - Sigstore transparency entry: 973112355
- Sigstore integration time:
-
Permalink:
hostcc/pyg90alarm@ba3c323ef63dca92ad233b5b228681cb97748061 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/hostcc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@ba3c323ef63dca92ad233b5b228681cb97748061 -
Trigger Event:
push
-
Statement type: