Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Py2N

Asynchronous library to control 2N Telekomunikace® devices

This library is under development

Requirements

  • Python >= 3.9
  • aiohttp >= 3.12.0

Install

pip install py2n

Example

from py2n import Py2NDevice, Py2NConnectionData

import asyncio
import aiohttp

async def main():
    """Run with aiohttp ClientSession."""
    async with aiohttp.ClientSession() as session:
        await run(session)


async def run(websession):
    """Use library."""
    device = await Py2NDevice.create(
        websession,
        Py2NConnectionData(
            host="192.168.1.69",
            username="username",
            password="password",
            # auth_method="digest", # default: "basic"
            # protocol="https", # default: "http"
            # ssl_verify=True, # default: False
        ),
    )

    await device.restart()

asyncio.run(main())

auth_method controls HTTP auth scheme and supports "basic" (default) and "digest". Digest auth relies on aiohttp.DigestAuthMiddleware. 2N recommends Digest Auth, especially if using plain HTTP instead of HTTPS. ssl_verify controls TLS certificate verification for HTTPS connections. Requires the device to present a trusted server certificate (e.g. Let's Encrypt).

About

Python library for 2N® products

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages