I have developed a cool python library

Python and python framework

Moderator: leecollings

Post Reply
kdschlosser
Posts: 15
Joined: Sunday 23 April 2017 3:14
Target OS: Windows
Domoticz version:
Contact:

I have developed a cool python library

Post by kdschlosser »

I developed a pretty nifty python library that possibly someone might be willing to code a Domoticz interface for

https://github.com/kdschlosser/UPNP_Device

it basically scans a network discovering all UPNP devices. and builds a python object that represents the device (based on IP) it supports embedded devices and nested upnp service. maps out the data types and builds methods for the upnp function calls. check to ensure the proper data type is being used. provides return data types and names for the returned data, as well as parameter names. It is a pretty quick implementation discovers all devices typically in less then 4 seconds.

maybe it could be useful.
devros
Posts: 183
Joined: Saturday 29 October 2016 20:55
Target OS: -
Domoticz version:
Contact:

Re: I have developed a cool python library

Post by devros »

Hi, looks good any info in install and usage ? Looks like setup.py is missing
kdschlosser
Posts: 15
Joined: Sunday 23 April 2017 3:14
Target OS: Windows
Domoticz version:
Contact:

Re: I have developed a cool python library

Post by kdschlosser »

I need to create a new branch and merge my most recent changes. I forgot to do that.

I will have it updated in a second.
kdschlosser
Posts: 15
Joined: Sunday 23 April 2017 3:14
Target OS: Windows
Domoticz version:
Contact:

Re: I have developed a cool python library

Post by kdschlosser »

the usage is really simple.

Code: Select all

import UPNP_Device

for device in UPNP_Device.discover():
    print(device)
    
or if you have a static IP of a device you want to specifically target

Code: Select all

import UPNP_Device

for device in UPNP_Device.discover(ip='192.168.1.1'):
    print(device)
you can also adjust the timeout

Code: Select all

import UPNP_Device

for device in UPNP_Device.discover(timeout=10):
    print(device)
doing the print will spit out the information for every service/device/method/data type basically all of the information you would want to know.

You can iterate over specific devices and services like so

Code: Select all

import UPNP_Device

for device in UPNP_Device.discover(timeout=10):
    for service in device.services:
        print(service.__name__)
with UPNP the devices and services can be nested.

Code: Select all

import UPNP_Device

for device in UPNP_Device.discover(timeout=10):
    for service in device.services:
        print(service.__name__)
        for service in service.services:
            print('   ', service.__name__)
    
    for embedded_device in device.devices:
        print embedded_device.__name__
        for service in embedded_device.services:
            print('   ', serviice.__name__)

and if you want to iterate the functions of a service

Code: Select all

import UPNP_Device

for device in UPNP_Device.discover(timeout=10):
    for service in device.services:
        print(service.__name__)
        for action in service.actions:
            print('   ', action.__name__)

I can get into quite a bit of detail on how to get the data types for the parameters that are used in the functions if needed. But that is a good start there. You should be able to tinker about a bit.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest