lawtancool / pyControl4

Python 3 asyncio package for interacting with Control4 systems
https://lawtancool.github.io/pyControl4
Apache License 2.0
38 stars 16 forks source link

Blind devices? #9

Closed brunchboy closed 2 years ago

brunchboy commented 2 years ago

First off, let me say thank you so much for creating this library! It is the first thing that has given me hope that I will be able to get the level of programmatic control I’d like to have over the automated blind system that was installed in the home I bought.

I can also report that the code seems to work with OS 2.0 (my Director is reporting version 2.10.1.544795-res). I am going to try to get it updated to OS 3.0 when I get more blinds installed, but the dealer is so overworked right now it has been months and I haven’t even been able to get a bid for that finalized!

By tweaking test.py I was able to download all the item information into allitems.txt, and see the blinds present there. I will paste an example blind item below. Is there any way I can help get these devices supported? They seem to have one parameter, which is the percentage at which they are open, and that can be read or set between 0% and 100%.

I will try to dig a bit deeper into how the code and protocol are working, and see if I can figure anything out myself, but as this is all completely new to me, I’m hoping someone who already understands it can help steer me in the right direction.

Here’s a sample blind item, one of my patio black-out blinds:

 {
  "type": 7,
  "typeName": "device",
  "name": "Patio Left BO",
  "parentId": 35,
  "id": 36,
  "filename": "blind.c4i",
  "proxy": "blind",
  "proxyOrder": 1,
  "proxyMeta": [
   {
    "name": "Qmotion Qadvanced Roller Shade",
    "proxybindingid": 5001,
    "smallSource": "composer",
    "smallImage": "devices_sm/blinds.gif",
    "largeSource": "composer",
    "largeImage": "devices_lg/blinds.gif",
    "proxy": "blind"
   }
  ],
  "categories": [
   "blinds_shades"
  ],
  "siteId": 7,
  "siteName": "Home",
  "buildingId": 8,
  "buildingName": "House",
  "floorId": 9,
  "floorName": "Main",
  "roomId": 10,
  "roomName": "Master Bedroom",
  "largeImage": "devices_lg/blinds.gif",
  "smallImage": "devices_sm/blinds.gif",
  "protocolId": 35,
  "protocolName": "Qmotion Qadvanced Roller Shade",
  "protocolFilename": "blind_qmotion_qadvanced_roller_shade.c4z",
  "capabilities": {
   "can_stop": true,
   "has_level": true,
   "level_closed": 0,
   "level_discrete_control": true,
   "level_open": 100,
   "level_resolution": 1,
   "level_unknown": -1,
   "movement": 1
  },
  "control": "blind",
  "version": 3,
  "created": "05/09/2005 12:30 PM",
  "modified": "03/11/2016 10:00 AM",
  "model": "",
  "manufacturer": "",
  "protocolControl": "lua_gen",
  "deviceOrder": 13,
  "allControlBindingsHidden": 0,
  "URIs": {
   "variables": "/api/v1/items/36/variables",
   "network": "/api/v1/items/36/network",
   "bindings": "/api/v1/items/36/bindings",
   "commands": "/api/v1/items/36/commands"
  }
 }
brunchboy commented 2 years ago

Good news! By looking at the light code, and messing around a bit more with test.py I was able to fetch the variables and commands for one of my blinds, and I just succeeded in moving it to different positions! So this is looking extremely promising. I’ll try to put together a blind.py based on light.py and can explore that linter and code formatter if you would be interested in a PR for it. I haven’t coded in Python before, but it looks pretty readable, especially with such close examples to base my own code on.