palazzem / econnect-python

API adapter used to control programmatically an Elmo alarm system
BSD 3-Clause "New" or "Revised" License
8 stars 5 forks source link

feat: add `client.query(q.PANEL)` API to retrieve panel details #140

Closed palazzem closed 5 months ago

palazzem commented 5 months ago

Related Issues

Proposed Changes:

This PR introduces two changes:

  1. When calling client.auth() (/api/login), the client stores the response that includes the panel details
  2. client.query(q.PANEL) returns the panel details response that is cached after the first call

Query Example

client.query(q.PANEL)

# Returns
{
    "last_id": 0,
    "panel": {
        "description": "T-800 1.0.1",
        "last_connection": "01/01/1984 13:27:28",
        "last_disconnection": "01/10/1984 13:27:18",
        "major": 1,
        "minor": 0,
        "source_ip": "10.0.0.1",
        "connection_type": "EthernetWiFi",
        "device_class": 92,
        "revision": 1,
        "build": 1,
        "brand": 0,
        "language": 0,
        "areas": 4,
        "sectors_per_area": 4,
        "total_sectors": 16,
        "inputs": 24,
        "outputs": 24,
        "operators": 64,
        "sectors_in_use": [
            True,
            True,
            True,
            True,
            False,
            False,
            False,
            False,
            False,
            False,
            False,
            False,
            False,
            False,
            False,
            False,
        ],
        "model": "T-800",
        "login_without_user_id": True,
        "additional_info_supported": 1,
        "is_fire_panel": False,
    },
}

Testing:

Authenticate the client and call the query method:

client.auth("username", "password")
client.query(q.PANEL)

Extra Notes (optional):

n/a

Checklist

coveralls commented 5 months ago

Pull Request Test Coverage Report for Build 7758244806


Totals Coverage Status
Change from base Build 7746013940: 0.0%
Covered Lines: 381
Relevant Lines: 381

💛 - Coveralls