Skip to content

Commit

Permalink
Merge pull request #408 from ParadoxAlarmInterface/dev
Browse files Browse the repository at this point in the history
Next iteration
  • Loading branch information
yozik04 authored Nov 13, 2023
2 parents 15ae861 + df1e3d3 commit 64ea576
Show file tree
Hide file tree
Showing 19 changed files with 124 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Before creating a bug report look into wiki and FAQ page:
- Wiki: https://github.com/ParadoxAlarmInterface/pai/wiki
- FAQ: https://github.com/ParadoxAlarmInterface/pai/wiki/FAQ
- Use search before posting. Maybe your issue was already solved.
- You can always use https://gitter.im/paradox-alarm-interface/community to ask a quick question.
- You can always use https://matrix.to/#/#paradox-alarm-interface_community:gitter.im to ask a quick question.
-->

## Alarm system
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/usage_question.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Before asking a question look into wiki and FAQ page:
- Wiki: https://github.com/ParadoxAlarmInterface/pai/wiki
- FAQ: https://github.com/ParadoxAlarmInterface/pai/wiki/FAQ
- Use search before posting. Maybe your issue was already solved.
- You can always use https://gitter.im/paradox-alarm-interface/community to ask a quick question.
- You can always use https://matrix.to/#/#paradox-alarm-interface_community:gitter.im to ask a quick question.
-->

## Alarm system
<!-- Describe your panel model (EVO192, Spectra SP4000, Magellan MG5050), access mode (Serial, IP150, etc..) and hardware. -->

## Environment
<!--
<!--
Windows, Linux, RPI...
Python version
-->
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm64/v8
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Publish to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<div align="center">
<div style="display: flex;">
<a href="https://gitter.im/paradox-alarm-interface/community">
<img alt="Gitter" src="https://img.shields.io/gitter/room/paradox-alarm-interface/community?logo=gitter">
<a href="https://matrix.to/#/#paradox-alarm-interface_community:gitter.im">
<img alt="Matrix" src="https://img.shields.io/matrix/pai:gitter.im.svg">
</a>
#paradox-alarm-interface_community:gitter.im
<a href="https://github.com/ParadoxAlarmInterface/pai/actions/workflows/master.yml">
<img alt="CI/CD master" src="https://github.com/ParadoxAlarmInterface/pai/actions/workflows/master.yml/badge.svg?branch=master">
</a>
Expand All @@ -13,12 +14,9 @@
<img alt="Docker Arch" src="https://img.shields.io/badge/docker_arch-386%7Camd64%7Carmv6%7Carmv7%7Carm64-green?logo=docker">
<img alt="Docker Pulls" src="https://img.shields.io/docker/pulls/paradoxalarminterface/pai?logo=docker">
</a>
<a href="https://travis-ci.org/ParadoxAlarmInterface/pai/branches">
<img alt="GitHub top language" src="https://img.shields.io/github/languages/top/ParadoxAlarmInterface/pai?label=python%203.8%2B&logo=python">
<a href="https://snyk.io/test/github/ParadoxAlarmInterface/pai?targetFile=requirements.txt">
<img src="https://snyk.io/test/github/ParadoxAlarmInterface/pai/badge.svg?targetFile=requirements.txt" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/ParadoxAlarmInterface/pai?targetFile=requirements.txt" style="max-width:100%;">
</a>
<a href="https://snyk.io/test/github/ParadoxAlarmInterface/pai?targetFile=requirements.txt">
<img src="https://snyk.io/test/github/ParadoxAlarmInterface/pai/badge.svg?targetFile=requirements.txt" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/ParadoxAlarmInterface/pai?targetFile=requirements.txt" style="max-width:100%;">
</a>
<img alt="GitHub" src="https://img.shields.io/github/license/ParadoxAlarmInterface/pai">
</div>
</div>
Expand All @@ -39,7 +37,7 @@ Support for Magellan, Spectra and EVO panels is very stable. If you find a bug,

For further information and detailed usage refer to the [Wiki](https://github.com/ParadoxAlarmInterface/pai/wiki).

If you are having issues, or wish to discuss new features, join us at our [Gitter community](https://gitter.im/paradox-alarm-interface)
If you are having issues, or wish to discuss new features, join us at our [Matrix community](https://matrix.to/#/#paradox-alarm-interface_community:gitter.im)

On Android, if you install [MQTT Dash](https://play.google.com/store/apps/details?id=net.routix.mqttdash), and [follow the instructions](https://github.com/ParadoxAlarmInterface/pai/wiki#mqtt-dash) you will automatically get a panel like this:
![mqtt_dash](https://user-images.githubusercontent.com/497717/52603920-d4984d80-2e60-11e9-9772-578b10576b3c.jpg)
Expand Down Expand Up @@ -92,7 +90,7 @@ This work is inspired or uses parts from the following projects:
* Spinza at https://github.com/spinza/paradox_mqtt

## Thanks
* Ivan Markov - [@ivmarkov](https://github.com/ivmarkov) - Multi-platform Docker builds with Travis
* Ivan Markov - [@ivmarkov](https://github.com/ivmarkov) - Multi-platform Docker builds
* Claudiu Bucur - [@clau-bucur](https://github.com/clau-bucur) - For fixing HomeAssistant plugin after Supervisor(2021.02.5) upgrade [#199](https://github.com/ParadoxAlarmInterface/pai/issues/199)
* David Tekan - [@tekand](https://github.com/tekand) - For supporting different label encodings.

Expand Down
1 change: 1 addition & 0 deletions config/pai.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import logging
# MQTT_CONTROL_TOPIC = 'control' # Base for control of other elements (ROOT/CONTROL/TYPE)
# MQTT_DEFINITIONS_TOPIC = 'control' # Base for definitions
# MQTT_HOMEASSISTANT_DISCOVERY_PREFIX = 'homeassistant'
# MQTT_HOMEASSISTANT_ENTITY_PREFIX = '' # If you want to prefix all entities you can use: "Paradox {serial_number} ", placeholders "serial_number" and "model" are supported. Default: "" - no prefix
# MQTT_OUTPUT_TOPIC = 'outputs'
# MQTT_DOOR_TOPIC = 'doors'
# MQTT_KEYPAD_TOPIC = 'keypads'
Expand Down
48 changes: 26 additions & 22 deletions paradox/config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
import os
import sys
import re
import sys


class Config(object):
class Config:
DEFAULTS = {
"LOGGING_LEVEL_CONSOLE": logging.INFO, # See documentation of Logging package
"LOGGING_LEVEL_FILE": logging.ERROR,
Expand Down Expand Up @@ -69,10 +69,10 @@ class Config(object):
), # Duration of a PGM pulse in seconds
"SYNC_TIME": False, # Update panel time periodically when time drifts more than SYNC_TIME_MIN_DRIFT
"SYNC_TIME_MIN_DRIFT": (
120,
int,
(120, 0xFFFFFFFF)
), # Minimum time drift in seconds to initiate time sync
120,
int,
(120, 0xFFFFFFFF),
), # Minimum time drift in seconds to initiate time sync
"SYNC_TIME_TIMEZONE": "", # By default pai uses the same timezone as pai host
"PASSWORD": (
None,
Expand Down Expand Up @@ -101,7 +101,11 @@ class Config(object):
"MQTT_USERNAME": (None, [str, type(None)]), # MQTT Username for authentication
"MQTT_PASSWORD": (None, [str, type(None)]), # MQTT Password
"MQTT_RETAIN": True, # Publish messages with Retain
"MQTT_QOS": (0, int, (0, 2)), # Publish messages with QOS level (0 - fire and forget, 1 - at least once, 2 - exactly once)
"MQTT_QOS": (
0,
int,
(0, 2),
), # Publish messages with QOS level (0 - fire and forget, 1 - at least once, 2 - exactly once)
"MQTT_PROTOCOL": ("3.1.1", str, ("3.1", "3.1.1", "5")), # Protocol to use
"MQTT_TRANSPORT": ("tcp", str, ("tcp", "websockets")), # Transport to use
"MQTT_BIND_ADDRESS": "", # MQTT Bind address (Paho default)
Expand All @@ -113,6 +117,7 @@ class Config(object):
), # Interval for republishing all data
"MQTT_HOMEASSISTANT_AUTODISCOVERY_ENABLE": False,
"MQTT_HOMEASSISTANT_CODE": (None, [str, type(None)]),
"MQTT_HOMEASSISTANT_ENTITY_PREFIX": "", # If you want to prefix all entities you can use: "Paradox {serial_number} ", placeholders "serial_number" and "model" are supported. Default: "" - no prefix
# MQTT Topics
"MQTT_BASE_TOPIC": "paradox", # Root of all topics
"MQTT_ZONE_TOPIC": "zones", # Base for zone states
Expand All @@ -136,6 +141,7 @@ class Config(object):
"MQTT_SEND_PANIC_TOPIC": "panic",
"MQTT_PUBLISH_RAW_EVENTS": True,
"MQTT_PUBLISH_DEFINITIONS": False, # Publish definitions of partitions/zones/users to mqtt.
"MQTT_PREFIX_DEVICE_NAME": False, # Add device ID as prefix to entity names: Paradox 12345678
"MQTT_INTERFACE_TOPIC": "interface",
"MQTT_TOGGLE_CODES": {},
"MQTT_USE_NUMERIC_STATES": False, # use 0 and 1 instead of True and False
Expand Down Expand Up @@ -172,12 +178,12 @@ class Config(object):
["DEBUG", "INFO", "WARN", "ERROR", "CRITICAL"],
),
"HOMEASSISTANT_PUBLISH_PARTITION_PROPERTIES": [ # List of partition properties to publish
'target_state',
'current_state'
"target_state",
"current_state",
],
"HOMEASSISTANT_PUBLISH_ZONE_PROPERTIES": [ # List of zone properties to publish
'open',
'tamper'
"open",
"tamper",
],
"HOMEASSISTANT_NOTIFICATIONS_IGNORE_EVENTS": [], # List of tuples or regexp matching "type,label,property=value,property2=value" eg. [(major, minor), "zone:HOME:entry_delay=True", ...]
"HOMEASSISTANT_NOTIFICATIONS_ALLOW_EVENTS": [], # Same as before but as a white list. Default is use EVENT_FILTERS
Expand Down Expand Up @@ -280,11 +286,7 @@ class Config(object):
CONFIG_FILE_LOCATION = (None,)

def __dir__(self):
return (
list(self.DEFAULTS.keys())
+ list(self.__class__.__dict__)
+ dir(super(Config, self))
)
return list(self.DEFAULTS.keys()) + list(self.__class__.__dict__) + dir(super())

def __init__(self):
self._reset_defaults()
Expand Down Expand Up @@ -314,9 +316,9 @@ def load(self, alt_location=None):
else:
default_type = [type(default)]

if float in default_type and not int in default_type:
if float in default_type and int not in default_type:
default_type.append(int)
if int in default_type and not float in default_type:
if int in default_type and float not in default_type:
default_type.append(float)
if type(v) in default_type:
setattr(self, k, v)
Expand All @@ -343,8 +345,8 @@ def load(self, alt_location=None):
if valid:
setattr(self, k, v)
else:
err = "Error parsing configuration value: Invalid value for config argument {}. Allowed are: {}".format(
type(v), k, expected_value
err = "Error parsing configuration value: Invalid value for config argument {} (type {}). Allowed are in: {}".format(
k, type(v), expected_value
)
sys.stderr.write(err + "\n")
raise (Exception(err))
Expand Down Expand Up @@ -425,8 +427,9 @@ def _reset_defaults(self):

config = Config()

comma_splitter_re = re.compile('\s*,\s*')
range_re = re.compile('(\d+)\s*-(\d+)\s*$')
comma_splitter_re = re.compile(r"\s*,\s*")
range_re = re.compile(r"(\d+)\s*-(\d+)\s*$")


def string_to_id_list(input: str):
arr = []
Expand All @@ -443,6 +446,7 @@ def string_to_id_list(input: str):

return arr


def get_limits_for_type(elem_type: str, default: list = None):
limits = config.LIMITS.get(elem_type, default)
if limits is None:
Expand Down
27 changes: 11 additions & 16 deletions paradox/connections/ip/stun_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, site_id, email, panel_serial):

async def connect(self) -> None:
self.connection_timestamp = 0
logger.info("Connecting to Site: {}".format(self.site_id))
logger.info("Connecting to Site: %s", self.site_id)
if self.site_info is None:
self.site_info = await self._get_site_info(
siteid=self.site_id, email=self.email
Expand All @@ -36,7 +36,7 @@ async def connect(self) -> None:
if self.site_info is None:
raise ConnectToSiteFailed("Unable to get site info")

logger.debug("Site Info: {}".format(json.dumps(self.site_info, indent=4)))
logger.debug("Site Info: %s", json.dumps(self.site_info, indent=4))
self.module = self._select_module()

if self.module is None:
Expand All @@ -63,7 +63,7 @@ async def connect(self) -> None:
f"STUN Connection Bind Request error: {stun.get_error(stun_r)}"
)

logger.info("Connected to Site: {}".format(self.site_id))
logger.info("Connected to Site: %s", self.site_id)

async def _stun_connect(self, xoraddr):
logger.debug("STUN Connect Request")
Expand Down Expand Up @@ -102,9 +102,7 @@ def _select_module(self):
continue

logger.debug(
"Found module with panel serial: {}".format(
module["panelSerial"]
)
"Found module with panel serial: %s", module["panelSerial"]
)

if not self.panel_serial: # Pick first available
Expand Down Expand Up @@ -133,18 +131,15 @@ def refresh_session_if_required(self) -> None:
self.connection_timestamp = time.time()

def close(self):
self.site_info = None
self.module = None

if self.stun_control:
try:
self.stun_control.close()
self.stun_control = None
except:
logger.exception("stun_control socket close failed")
self.stun_control.close()
self.stun_control = None
if self.stun_tunnel:
try:
self.stun_tunnel.close()
self.stun_tunnel = None
except:
logger.exception("stun_tunnel socket close failed")
self.stun_tunnel.close()
self.stun_tunnel = None

self.connection_timestamp = 0

Expand Down
3 changes: 2 additions & 1 deletion paradox/hardware/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create_panel(core, start_communication_response: Container = None) -> Panel:
from . import evo

return evo.Panel_EVO192(core, start_communication_response, True)
elif product_id == "DIGIPLEX_EVO_HD":
elif product_id in ["DIGIPLEX_EVO_HD", "DIGIPLEX_EVO_HD_PLUS"]:
from . import evo

return evo.Panel_EVOHD(core, start_communication_response, True)
Expand All @@ -34,6 +34,7 @@ def create_panel(core, start_communication_response: Container = None) -> Panel:
"SPECTRA_SP7000",
"SPECTRA_SP65",
"SPECTRA_SP6000_PLUS",
"SPECTRA_SP7000_PLUS",
"MAGELLAN_MG5000",
"MAGELLAN_MG5050",
"MAGELLAN_MG5050_PLUS",
Expand Down
Loading

0 comments on commit 64ea576

Please sign in to comment.