gurumitts / pylutron-caseta

Apache License 2.0
153 stars 98 forks source link

Serena Shades support #5

Closed anoopr closed 7 years ago

anoopr commented 7 years ago

Hi! Thank you so much for your work on the lutron_caseta component. It's fantastic!

I have two sets of Serena Shades, and I was wondering if there's anything I could do to help add support. Please let me know!

gurumitts commented 7 years ago

Thanks for the compliment. Lets see what it would take. Let me do some digging to see what the next steps would be. Ill reply to this thread within a few days.

gurumitts commented 7 years ago

@anoopr can you post your lutron integration report here?

flyespresso commented 7 years ago

Intg Report.txt

Here's mine if it helps, I have a shade as well.

gurumitts commented 7 years ago

Cool.. looks like the shades show up as a zone. The good news is it may already be supported at this level. Can you guys give this a shot?

pip install pylutron_caseta

Then in a python3 interpreter:

from pylutron_caseta.smartbridge import Smartbridge

sb = Smartbridge(hostname="192.168.XX.XXX") # provide the ip address of your smart bridge
print(sb.get_devices())
# Look for the device_id of your shade.  We will call this device_id
sb.set_value(device_id, 100) #  This should close( or open)? them.
sb.set_value(device_id, 0) # this should do the opposite
sb.set_value(device_id, 50) # this should make them rest at the half way point.  

Please detail your experience afterwards and we can discuss the next steps.

gurumitts commented 7 years ago

If device_id is 4:

sb.set_value("4", 50) 
flyespresso commented 7 years ago

I'm anything but a python person at all but this is what I keep getting as an error:

`pi@hassbian:~ $ python3 Python 3.4.2 (default, Oct 19 2014, 13:31:11) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information.

from pylutron_caseta.smartbridge import Smartbridge Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.4/dist-packages/pylutron_caseta/smartbridge.py", line 9, in import paramiko File "/usr/local/lib/python3.4/dist-packages/paramiko/init.py", line 30, in from paramiko.transport import SecurityOptions, Transport File "/usr/local/lib/python3.4/dist-packages/paramiko/transport.py", line 34, in from cryptography.hazmat.primitives.ciphers import algorithms, Cipher, modes File "/usr/local/lib/python3.4/dist-packages/cryptography/hazmat/primitives/ciphers/init.py", line 7, in from cryptography.hazmat.primitives.ciphers.base import ( File "/usr/local/lib/python3.4/dist-packages/cryptography/hazmat/primitives/ciphers/base.py", line 9, in import cffi ImportError: No module named 'cffi' `

gurumitts commented 7 years ago

Hmmm.. odd.. can you try this:

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

Then

pip install paramiko
flyespresso commented 7 years ago

OK that worked!

Here is the shades device ID string:

{'device_id': '8', 'zone': '5', 'current_state': 0, 'name': 'Upper Shade', 'type': 'SerenaRollerShade'}

This is the results:

100= Fully open

50 = Halfway

0 = Closed

Yeah it's counterintuitive!

gurumitts commented 7 years ago

Awesome...

I'll add the cover component for homeassistant based on the above information.

Thanks for testing it out and reporting back.

gurumitts commented 7 years ago

@thephilz can you verify that the device_id and zone are unique across all the devices connected to the smartbridge.

flyespresso commented 7 years ago

Device_ID for sure, but some items don't have a zone at all. Though none of my Zone's have multiple items–I can try later and see if there is any way that they could be in the same zone. Taking a look at the print devices/integration report:

{'9': {'current_state': -1, 'zone': None, 'device_id': '9', 'type': 'Pico3ButtonRaiseLower', 'name': 'Shade Pico'},

'7': {'current_state': -1, 'zone': None, 'device_id': '7', 'type': 'Pico3ButtonRaiseLower', 'name': 'Loft Pico'},

'4': {'current_state': 0, 'zone': '2', 'device_id': '4', 'type': 'WallDimmer', 'name': 'Kitchen'},

'8': {'current_state': 0, 'zone': '5', 'device_id': '8', 'type': 'SerenaRollerShade', 'name': 'Upper Shade'},

'12': {'current_state': 0, 'zone': '8', 'device_id': '12', 'type': 'WallSwitch', 'name': 'Shower'},

'3': {'current_state': -1, 'zone': None, 'device_id': '3', 'type': 'Pico3ButtonRaiseLower', 'name': 'Hallway Pico'},

'6': {'current_state': 0, 'zone': '4', 'device_id': '6', 'type': 'WallDimmer', 'name': 'Vanity'},

'2': {'current_state': 0, 'zone': '1', 'device_id': '2', 'type': 'WallDimmer', 'name': 'Hallway'},

'5': {'current_state': 0, 'zone': '3', 'device_id': '5', 'type': 'WallDimmer', 'name': 'Thrusters'},

'10': {'current_state': 0, 'zone': '6', 'device_id': '10', 'type': 'PlugInDimmer', 'name': 'Lamp'},

'13': {'current_state': 0, 'zone': '9', 'device_id': '13', 'type': 'WallDimmer', 'name': 'Storage Room'},

'1': {'current_state': -1, 'zone': None, 'device_id': '1', 'type': 'SmartBridge', 'name': 'Smart Bridge'}}

gurumitts commented 7 years ago

So based on what I am seeing. We should be able to get this into home-assistant as a cover platform. It will be able to support open, close, and set_position. This should be enough for most day to day operations and automations.

flyespresso commented 7 years ago

Great! Let me know if I can do anything else!

gurumitts commented 7 years ago

Any chance you can test this branch: https://github.com/gurumitts/home-assistant/tree/support_lutron_serena_shades

gurumitts commented 7 years ago

related home-assistant community thread: https://community.home-assistant.io/t/support-for-lutron-serena-shades/17517

gurumitts commented 7 years ago

PRs are out:

https://github.com/home-assistant/home-assistant/pull/7565

https://github.com/home-assistant/home-assistant.github.io/pull/2622