connectorlocal


Nameconnectorlocal JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/ConnectorGit/connectorlocal
SummaryPython library for interfacing with Connector Shades
upload_time2023-04-18 02:47:24
maintainer
docs_urlNone
authorLucas
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # connectorlocal

Python library for interfacing with Connector Shades

This library allows you to control Connector Shades.
This library is primarly writen to be used with HomeAssistant but can also be used stand alone.




## Installation

Use pip:

```$ pip install connectorlocal```



## Retrieving Key

The Connector Shades API uses a 16 character key that can be retrieved from the official "Connector Shades" app for [Ios](https://itunes.apple.com/cn/app/connector/id1344058317?mt=8) or [Android](https://play.google.com/store/apps/details?id=com.smarthome.app.connector).
Open the app, click the button in the upper left corner to expand the page, then click the setting button in the upper left corner to enter the "Settings page", click the About option to enter the "About page",Please quickly tap this "Connector Shades About" page 5 times, a popup will apear that gives you the key.

![alt text](./pictures/About_page.jpg)

![alt text](./pictures/key.jpg)



## Usage

For creation of a device you could use the following lines of codes (using a correct IP of the gateway and Key retrieved from the App)

```python
from connector_local import ConnectorHub

connector = ConnectorHub(ip="192.168.31.100", key="12ab345c-d67e-8f")
# If you want to add multiple HUB, Please use & as separator
connector = ConnectorHub(ip="192.168.31.100&192.168.31.101", key="12ab345c-d67e-8f")
```

When the connector instance is created, you need to actively open the receiving, because the connector is based on local UDP communication.

```python
connector.start_receive_data()
```

After opening UDP reception, you need to actively wait for about 3 seconds (it takes a little time to query the device and update the device status), and then query the device list

```python
connector.device_list()
```

Some example code that will print the information of the gateway and all connected blinds:

```
>>> from connector_local import ConnectorHub
>>> connector = ConnectorHub(ip="192.168.31.100", key="12ab345c-d67e-8f")
>>> connector.start_receive_data()
>>> hubs = connector.device_list()
>>> print(hubs)
>>> {'a4cf1216c014': <__main__.Hub object at 0x0000022012E6D610>}
```

If you want to get the sub-device under HUB, you can get it through hub.blinds

```python
>>> hub = hubs["a4cf1216c014"]
>>> blinds_list = hub.blinds
>>> print(blinds_list)
>>> {'a4cf1216c014000a': <__main__.OneWayBlind object at 0x00000235DA92D610>, 'a4cf1216c014000d': <__main__.OneWayBlind object at 0x00000235DA92DA90>, 'a4cf1216c014000e': <__main__.TwoWayBlind object at 0x00000235DA92D6A0>, 'a4cf1216c0140015': <__main__.TwoWayBlind object at 0x00000235DA92D970>, 'a4cf1216c0140016': <__main__.TwoWayBlind object at 0x00000235DA92D760>, 'a4cf1216c0140017': <__main__.TwoWayBlind object at 0x00000235DA92D8E0>}
```

OneWayBlind supports up stop and down, 

TwoWayBlind supports up stop down and percentage control

```python
blinds = blinds_list["a4cf1216c014000e"]
# open blinds
blinds.open()
# stop blinds
blinds.stop()
# close blinds
blinds.close()
# Control blinds to 50% (0% is open, 100% is close)
blinds.target_position(percent = 50)
# Control blinds to 90 degrees (Angle control range is 0 to 180 degrees)
blinds.target_angle(angle = 90)

```

## ConnectorHub

| method / property              | arguments | argument type | explanation                                                  |
| ------------------------------ | --------- | ------------- | ------------------------------------------------------------ |
| connector.start_receive_data() | /         | /             | Join UDP multicast and create threads.                       |
| connector.close_receive_data() | /         | /             | Close receive thread.                                        |
| connector.device_list()        | /         | /             | Return the device list.                                      |
| connector.is_connected         | /         | /             | Return the connect status                                    |
| connector.error_code           | /         | /             | If the connection status is False, you need to check the error code.         1000 :connection succeeded        1001: key is wrong                                1002: port is occupied |



## Hub

| method / property   | arguments | argument type | explanation                                          |
| ------------------- | --------- | ------------- | ---------------------------------------------------- |
| hub.blinds_list     | /         | /             | Return all blinds.                                   |
| hub.hub_version     | /         | /             | Return hub version.                                  |
| hub.hub_mac         | /         | /             | Return hub mac.                                      |
| hub.devicetype      | /         | /             | Return device type.                                  |
| hub.update_blinds() | /         | /             | Update the status of all Two Way Blind under the hub |



## OneWayBlind

| method / property    | arguments | argument type | explanation                     |
| -------------------- | --------- | ------------- | ------------------------------- |
| blinds.open()        | /         | /             | open blinds                     |
| blinds.close()       | /         | /             | close blinds                    |
| blinds.stop()        | /         | /             | stop blinds                     |
| blinds.mac           | /         | /             | return the blinds mac           |
| blinds.device_type   | /         | /             | return the blinds device type   |
| blinds.type          | /         | /             | return the blinds type          |
| blinds.wireless_mode | /         | /             | return the blinds wireless mode |



## TwoWayBlind

| method / property                   | arguments | argument type | explanation                            |
| ----------------------------------- | --------- | ------------- | -------------------------------------- |
| blinds.open()                       | /         | /             | open blinds                            |
| blinds.close()                      | /         | /             | close blinds                           |
| blinds.stop()                       | /         | /             | stop blinds                            |
| blinds.target_position(percent=100) | percent   | int (0-100)   | Percentage control.                    |
| blinds.target_angle(angle = 90)     | angle     | int (0-180)   | Angle control.                         |
| blinds.mac                          | /         | /             | return the blinds mac                  |
| blinds.device_type                  | /         | /             | return the blinds device type          |
| blinds.type                         | /         | /             | return the blinds type                 |
| blinds.wireless_mode                | /         | /             | return the blinds wireless mode        |
| blinds.update_state()               | /         | /             | update the position of the blind.      |
| blinds.isClosed                     | /         | /             | return if the cover is closed or not.  |
| blinds.position                     | /         | /             | return current position of the blinds. |

## Attribute Value Explanation

| wireless mode | explanation                      |
| ------------- | -------------------------------- |
| 0             | Uni-direction                    |
| 1             | Bi-direction                     |
| 2             | Bi-direction (mechanical limits) |
| 3             | Wi-Fi                            |
| 4             | Bi-direction(virtual percentage) |
| 5             | Others                           |

| type | explanation         |
| ---- | ------------------- |
| 1    | Roller Blinds       |
| 2    | Venetian Blinds     |
| 3    | Roman Blinds        |
| 4    | Honeycomb Blinds    |
| 5    | Shangri-La Blinds   |
| 6    | Roller Shutter      |
| 7    | Roller Gate         |
| 8    | Awning              |
| 10   | Day&night Blinds    |
| 11   | Dimming Blinds      |
| 12   | Curtain             |
| 13   | Curtain(Open Left)  |
| 14   | Curtain(Open Right) |

| deviceType | explanation         |
| ---------- | ------------------- |
| 02000001   | Wi-Fi Bridge        |
| 10000000   | 433Mhz radio motor  |
| 22000000   | Wi-Fi Curtain       |
| 22000002   | Wi-Fi tubular motor |
| 22000005   | Wi-Fi receiver      |


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ConnectorGit/connectorlocal",
    "name": "connectorlocal",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Lucas",
    "author_email": "admin@shadeconnector.com",
    "download_url": "",
    "platform": "any",
    "description": "# connectorlocal\r\n\r\nPython library for interfacing with Connector Shades\r\n\r\nThis library allows you to control Connector Shades.\r\nThis library is primarly writen to be used with HomeAssistant but can also be used stand alone.\r\n\r\n\r\n\r\n\r\n## Installation\r\n\r\nUse pip:\r\n\r\n```$ pip install connectorlocal```\r\n\r\n\r\n\r\n## Retrieving Key\r\n\r\nThe Connector Shades API uses a 16 character key that can be retrieved from the official \"Connector Shades\" app for [Ios](https://itunes.apple.com/cn/app/connector/id1344058317?mt=8) or [Android](https://play.google.com/store/apps/details?id=com.smarthome.app.connector).\r\nOpen the app, click the button in the upper left corner to expand the page, then click the setting button in the upper left corner to enter the \"Settings page\", click the About option to enter the \"About page\",Please quickly tap this \"Connector Shades About\" page 5 times, a popup will apear that gives you the key.\r\n\r\n![alt text](./pictures/About_page.jpg)\r\n\r\n![alt text](./pictures/key.jpg)\r\n\r\n\r\n\r\n## Usage\r\n\r\nFor creation of a device you could use the following lines of codes (using a correct IP of the gateway and Key retrieved from the App)\r\n\r\n```python\r\nfrom connector_local import ConnectorHub\r\n\r\nconnector = ConnectorHub(ip=\"192.168.31.100\", key=\"12ab345c-d67e-8f\")\r\n# If you want to add multiple HUB, Please use & as separator\r\nconnector = ConnectorHub(ip=\"192.168.31.100&192.168.31.101\", key=\"12ab345c-d67e-8f\")\r\n```\r\n\r\nWhen the connector instance is created, you need to actively open the receiving, because the connector is based on local UDP communication.\r\n\r\n```python\r\nconnector.start_receive_data()\r\n```\r\n\r\nAfter opening UDP reception, you need to actively wait for about 3 seconds (it takes a little time to query the device and update the device status), and then query the device list\r\n\r\n```python\r\nconnector.device_list()\r\n```\r\n\r\nSome example code that will print the information of the gateway and all connected blinds:\r\n\r\n```\r\n>>> from connector_local import ConnectorHub\r\n>>> connector = ConnectorHub(ip=\"192.168.31.100\", key=\"12ab345c-d67e-8f\")\r\n>>> connector.start_receive_data()\r\n>>> hubs = connector.device_list()\r\n>>> print(hubs)\r\n>>> {'a4cf1216c014': <__main__.Hub object at 0x0000022012E6D610>}\r\n```\r\n\r\nIf you want to get the sub-device under HUB, you can get it through hub.blinds\r\n\r\n```python\r\n>>> hub = hubs[\"a4cf1216c014\"]\r\n>>> blinds_list = hub.blinds\r\n>>> print(blinds_list)\r\n>>> {'a4cf1216c014000a': <__main__.OneWayBlind object at 0x00000235DA92D610>, 'a4cf1216c014000d': <__main__.OneWayBlind object at 0x00000235DA92DA90>, 'a4cf1216c014000e': <__main__.TwoWayBlind object at 0x00000235DA92D6A0>, 'a4cf1216c0140015': <__main__.TwoWayBlind object at 0x00000235DA92D970>, 'a4cf1216c0140016': <__main__.TwoWayBlind object at 0x00000235DA92D760>, 'a4cf1216c0140017': <__main__.TwoWayBlind object at 0x00000235DA92D8E0>}\r\n```\r\n\r\nOneWayBlind supports up stop and down, \r\n\r\nTwoWayBlind supports up stop down and percentage control\r\n\r\n```python\r\nblinds = blinds_list[\"a4cf1216c014000e\"]\r\n# open blinds\r\nblinds.open()\r\n# stop blinds\r\nblinds.stop()\r\n# close blinds\r\nblinds.close()\r\n# Control blinds to 50% (0% is open, 100% is close)\r\nblinds.target_position(percent = 50)\r\n# Control blinds to 90 degrees (Angle control range is 0 to 180 degrees)\r\nblinds.target_angle(angle = 90)\r\n\r\n```\r\n\r\n## ConnectorHub\r\n\r\n| method / property              | arguments | argument type | explanation                                                  |\r\n| ------------------------------ | --------- | ------------- | ------------------------------------------------------------ |\r\n| connector.start_receive_data() | /         | /             | Join UDP multicast and create threads.                       |\r\n| connector.close_receive_data() | /         | /             | Close receive thread.                                        |\r\n| connector.device_list()        | /         | /             | Return the device list.                                      |\r\n| connector.is_connected         | /         | /             | Return the connect status                                    |\r\n| connector.error_code           | /         | /             | If the connection status is False, you need to check the error code.         1000 :connection succeeded        1001: key is wrong                                1002: port is occupied |\r\n\r\n\r\n\r\n## Hub\r\n\r\n| method / property   | arguments | argument type | explanation                                          |\r\n| ------------------- | --------- | ------------- | ---------------------------------------------------- |\r\n| hub.blinds_list     | /         | /             | Return all blinds.                                   |\r\n| hub.hub_version     | /         | /             | Return hub version.                                  |\r\n| hub.hub_mac         | /         | /             | Return hub mac.                                      |\r\n| hub.devicetype      | /         | /             | Return device type.                                  |\r\n| hub.update_blinds() | /         | /             | Update the status of all Two Way Blind under the hub |\r\n\r\n\r\n\r\n## OneWayBlind\r\n\r\n| method / property    | arguments | argument type | explanation                     |\r\n| -------------------- | --------- | ------------- | ------------------------------- |\r\n| blinds.open()        | /         | /             | open blinds                     |\r\n| blinds.close()       | /         | /             | close blinds                    |\r\n| blinds.stop()        | /         | /             | stop blinds                     |\r\n| blinds.mac           | /         | /             | return the blinds mac           |\r\n| blinds.device_type   | /         | /             | return the blinds device type   |\r\n| blinds.type          | /         | /             | return the blinds type          |\r\n| blinds.wireless_mode | /         | /             | return the blinds wireless mode |\r\n\r\n\r\n\r\n## TwoWayBlind\r\n\r\n| method / property                   | arguments | argument type | explanation                            |\r\n| ----------------------------------- | --------- | ------------- | -------------------------------------- |\r\n| blinds.open()                       | /         | /             | open blinds                            |\r\n| blinds.close()                      | /         | /             | close blinds                           |\r\n| blinds.stop()                       | /         | /             | stop blinds                            |\r\n| blinds.target_position(percent=100) | percent   | int (0-100)   | Percentage control.                    |\r\n| blinds.target_angle(angle = 90)     | angle     | int (0-180)   | Angle control.                         |\r\n| blinds.mac                          | /         | /             | return the blinds mac                  |\r\n| blinds.device_type                  | /         | /             | return the blinds device type          |\r\n| blinds.type                         | /         | /             | return the blinds type                 |\r\n| blinds.wireless_mode                | /         | /             | return the blinds wireless mode        |\r\n| blinds.update_state()               | /         | /             | update the position of the blind.      |\r\n| blinds.isClosed                     | /         | /             | return if the cover is closed or not.  |\r\n| blinds.position                     | /         | /             | return current position of the blinds. |\r\n\r\n## Attribute Value Explanation\r\n\r\n| wireless mode | explanation                      |\r\n| ------------- | -------------------------------- |\r\n| 0             | Uni-direction                    |\r\n| 1             | Bi-direction                     |\r\n| 2             | Bi-direction (mechanical limits) |\r\n| 3             | Wi-Fi                            |\r\n| 4             | Bi-direction(virtual percentage) |\r\n| 5             | Others                           |\r\n\r\n| type | explanation         |\r\n| ---- | ------------------- |\r\n| 1    | Roller Blinds       |\r\n| 2    | Venetian Blinds     |\r\n| 3    | Roman Blinds        |\r\n| 4    | Honeycomb Blinds    |\r\n| 5    | Shangri-La Blinds   |\r\n| 6    | Roller Shutter      |\r\n| 7    | Roller Gate         |\r\n| 8    | Awning              |\r\n| 10   | Day&night Blinds    |\r\n| 11   | Dimming Blinds      |\r\n| 12   | Curtain             |\r\n| 13   | Curtain(Open Left)  |\r\n| 14   | Curtain(Open Right) |\r\n\r\n| deviceType | explanation         |\r\n| ---------- | ------------------- |\r\n| 02000001   | Wi-Fi Bridge        |\r\n| 10000000   | 433Mhz radio motor  |\r\n| 22000000   | Wi-Fi Curtain       |\r\n| 22000002   | Wi-Fi tubular motor |\r\n| 22000005   | Wi-Fi receiver      |\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python library for interfacing with Connector Shades",
    "version": "0.1.2",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "137aba25d858bb417301b32ae0f44da09ac15bc107461429564c0372b0a12fdc",
                "md5": "fc2eea02752ae5c507977db4e8d4a196",
                "sha256": "9e0d51c91b397c3d620fb7039322fa937271ef18a8ab0fff69d3dd3e8ba59368"
            },
            "downloads": -1,
            "filename": "connectorlocal-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fc2eea02752ae5c507977db4e8d4a196",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8501,
            "upload_time": "2023-04-18T02:47:24",
            "upload_time_iso_8601": "2023-04-18T02:47:24.737846Z",
            "url": "https://files.pythonhosted.org/packages/13/7a/ba25d858bb417301b32ae0f44da09ac15bc107461429564c0372b0a12fdc/connectorlocal-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-18 02:47:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ConnectorGit",
    "github_project": "connectorlocal",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "connectorlocal"
}
        
Elapsed time: 0.30489s