Lutron Caseta Interface

Since I am incredibly lazy I wrote a little bash script to automate grabbing the code from @jhn’s repo. I use the docker so every time I upgrade I have to redo it. Hopefully this helps someone out. You may have to modify it if you are not using the docker.

#!/bin/sh
mkdir -p /usr/src/app/homeassistant/components/caseta
cd /usr/src/app/homeassistant/components/caseta
wget https://raw.githubusercontent.com/jhanssen/home-assistant/11c4d1042c68a29cd55d0f053745064b52ce1809/homeassistant/components/caseta/__init__.py
wget https://raw.githubusercontent.com/jhanssen/home-assistant/11c4d1042c68a29cd55d0f053745064b52ce1809/homeassistant/components/caseta/casetify.py
cd ../light
wget https://raw.githubusercontent.com/jhanssen/home-assistant/11c4d1042c68a29cd55d0f053745064b52ce1809/homeassistant/components/light/caseta.py
cd ../sensor
wget https://raw.githubusercontent.com/jhanssen/home-assistant/11c4d1042c68a29cd55d0f053745064b52ce1809/homeassistant/components/sensor/caseta.py
cd ../switch
wget https://raw.githubusercontent.com/jhanssen/home-assistant/11c4d1042c68a29cd55d0f053745064b52ce1809/homeassistant/components/switch/caseta.py
1 Like

It would be great if the excellent library by @gurumitts currently supporting Caseta could be augmented with the Telnet features to support pico remotes on the Smart Bridge Pro. I think it was in there originally and taken out in favor of supporting the wider audience of non-pro bridge users.

I have a Smart Bridge Pro (L-BDGPRO2-WH) and have been poking around with the SSH interface which is available on both pro and non-pro bridges. It’s pretty neat and some real possibilities there.

After you login with SSH (the key is in the source code and the user is leap), you get a blank screen. Don’t expect a command prompt or shell!

Start with this one:

{"CommuniqueType":"ReadRequest","Header":{"Url":"/project"}}

Then wherever you see Url or href, you can take that and make another ReadRequest.

Get a list of all your devices:

{"CommuniqueType":"ReadRequest","Header":{"Url":"/device"}}

For your dimmers and switches you’ll see a zone number, like /zone/1.

Turn turn on Zone 1 to 100% brightness:

{"CommuniqueType":"CreateRequest","Header":{"Url":"/zone/1/commandprocessor"},"Body":{"Command":{"CommandType":"GoToLevel","Parameter":[{"Type":"Level","Value":100}]}}}

This is what the Home Assistant component is using.

In the Lutron app they support a Scene feature and in the interface they call these virtual buttons. Here’s your scene list (it is 100 buttons):

{"CommuniqueType":"ReadRequest","Header":{"Url":"/virtualbutton"}}

Now trigger the first scene:

{"CommuniqueType":"CreateRequest","Header":{"Url":"/virtualbutton/1/commandprocessor"},"Body":{"Command":{"CommandType":"PressAndRelease"}}}

It would be great if these could be incorporated into Home Assistant somehow (virtualbutton service?). If you have a lot of Lutron lights it is easier to walk around the house and program with the Lutron app. Then you just need a service in HA to call them and you could tie them to any automation. It would set all your Lutron light levels in one shot.

Going further into the SSH (or LEAP interface as they call it), I found you can program the levels and fade time for every single Pico remote button and all 100 virtual buttons. This is more than you can do in Lutron’s own app which does not support fade time. The major caveat however, it that you can program the fade time on the buttons (real or virtual) and NOT on the light itself. So while this helps you to customize the behavior of your pico remotes and Lutron-generated scenes, there would be no way to turn on a light from HA with an arbitrary fade time without using the Telnet interface (which already supports arbitrary fade times).

To program the fade rate for a scene or pico button, you have to go through a bunch of steps to figure out the /programmingmodel/, then the /preset/ number, then the /presetassignment/ number. If it is a non-virtual button you also need to go through /device/-> /buttongroup/ -> /button/ to figure it out.

Here is the sequence that I went through for a virtual button:

{"CommuniqueType":"ReadRequest","Header":{"Url":"/virtualbutton/1"}}
{"CommuniqueType":"ReadRequest","Header":{"Url":"/preset/1"}}
{"CommuniqueType":"ReadRequest","Header":{"Url":"/presetassignment/13"}}

At this point I know my virtual button is /presetassignment/13 so I can set the level to 0 and fade to 2 minutes (120 seconds):

{"CommuniqueType":"UpdateRequest","Header":{"MessageBodyType":"OnePresetAssignmentDefinition","Url":"/presetassignment/13"},"Body":{"PresetAssignment": { "Level": 0, "Fade": 120 }}}

I found a few other neat tricks:

  • Check if you are on a Pro model with a Telnet service (a.k.a. Lutron Integration Protocol (LIP) Server):
{"CommuniqueType":"ReadRequest","Header":{"Url":"/server"}}
  • Enable the LIP server (Pro only):
{"CommuniqueType":"UpdateRequest","Header":{"MessageBodyType":"OneServerDefinition","Url":"/server/2"},"Body":{"Server":{"EnableState":"Enabled"}}}
  • Get that pesky Integration Report for Pro models that they insist must be sent to you by email (why Lutron??) (Pro only):
{"CommuniqueType":"ReadRequest","Header":{"Url":"/server/2/id"}}
  • The Smart Bridge advertises itself on the network using MDNS (IP 224.0.0.251). I think that means is could be added to Home Assistant’s discovery component.

  • Here’s how to check out the high and low trim levels on a device:

{"CommuniqueType":"ReadRequest","Header":{"Url":"/zone/1/tuningsettings"}}
  • Simulate pressing and holding a Pico raise/lower button:
{"CommuniqueType":"CreateRequest","Header":{"Url":"/button/122/commandprocessor"},"Body":{"Command":{"CommandType":"PressAndHold"}}}
  • I don’t have shades, but the CommandTypes should be "ShadeLimitRaise" and "ShadeLimitLower" with "Parameter":{"Type":"Action","Value":"Start"} or "Parameter":{"Type":"Action","Value":"Stop"}. This is to start a shade moving or to stop a moving shade. GoToLevel also works on shades and is what’s used in Home Assistant.

  • The ordering of the buttons within a /buttongroup/# in my system for a 3 button raise-lower (3BRL) pico was On, Favorite, Off, Raise, Lower. So if you want to program the fade on the favorite button, try the third entry.

If you have the non-pro bridge and are hell bent on keeping it, there are some possible work-arounds for the lack of pico remote button presses in Home Assistant (assuming Telnet is eventually integrated for the Smart Bridge Pro users). In theory, you could buy a plug-in dimmer, stick it in a closet with nothing pluggin into it and assign your pico to it. Then program each button on the pico to set a certain level and make a sensor in Home Assistant based on brightness. Trigger automations based on the brightness level changes. It requires mapping Lutron brightness levels 0-100 to HA brightness of 0 to 255 so could support about 85 buttons or 28 pico remotes (assuming 3 usable scene buttons per remote).

If anyone has any questions, let me know. I’m not finished investigating the SSH interface and there may be a few more bits and pieces to share.

7 Likes

@upsert I came to this thread looking for ways to integrate Caseta Scenes into HA, but it looks like you’ve already found it (great job btw). Have you (or someone else) already started working on getting that integrated into the HA code? It’s definitely a feature I’d really like to have. I know that creating a scene in HA is nearly the same, but I really really like how Caseta scenes fade all of the lights on/off at the exact same time instead of sequentially. It has no functional impact, but it just makes me happy :slight_smile:

@upsert Absolutely outstanding information. I am very interested in any other information that you come up with regarding this interface. I am writing my own script @ home…just simply want RadioRA2 Keypads to control Caseta and RA2 devices at the same time. I have it working, but there are glitches such as timeouts, etc. Anything you come up with and feel like sharing I would be greatly appreciative.

@upsert, I made some progress on this.

I had to update the pylutron_caseta library that the lutron_caseta library uses. You can find it in my fork. Replace the file in ~/.homeassistant/deps/pylutron_caseta with my version. I’ve submitted a pull request to the original author to get it integrated.

As for the actual home assistant code, here is my branch to work on this. You’ll need to replace homeassistant/components/lutron_caseta.py and add homeassistant/components/lutron_caseta.py. I can’t submit my changes until the pylutron_caseta changes are accepted by that dev though since it’s a dependency (unless someone tells me differently).

Try this out and let me know if you run into any issues!

Nice! I’m about to go away on vacation but I’ll try it when I get back in August. I would also like to contribute and maybe help bring back telnet support to complement the existing setup. Multi-hub support would also be good as I suspect many DIY users are using multiple Smart Bridges rather than go up to RadioRA 2.

Fun fact: although there is a 50 device limit on Caseta, the first Plugin Dimmer you add will act as a repeater and extend the effective range up to 60 feet. Didn’t find that out until I saw it in the app.

I have poked around a bit more on the LEAP server, but no luck getting Fade to work like with the Pro bridge.

Here are the timeclock functions (scheduled actions in the app):

{"CommuniqueType":"ReadRequest","Header":{"Url":"/timeclock"}}
{"CommuniqueType":"ReadRequest","Header":{"Url":"/timeclockevent"}}

There are some places for services including Alexa, Sonos and Nest (none of which I have):

{"CommuniqueType":"ReadRequest","Header":{"Url":"/service"}}
{"CommuniqueType":"ReadRequest","Header":{"Url":"/service/1"}}
{"CommuniqueType":"ReadRequest","Header":{"Url":"/service/sonos"}}

If you had the Sonos integration I’m sure there are commands for Play/Pause/Next Track.

A few commands related to load shedding for their industrial/commercial products or perhaps RadioRA 2 Powr Savr occupancy sensors:

{"CommuniqueType":"ReadRequest","Header":{"Url":"/area"}}
{"CommuniqueType":"ReadRequest","Header":{"Url":"/area/1/loadshedding"}}
{"CommuniqueType":"ReadRequest","Header":{"Url":"/area/1/occupancysettings"}}

Also found a ping command which could be useful just to make sure a connection is alive:

{"CommuniqueType":"ReadRequest","Header":{"Url":"/server/status/ping"}}

@upsert does fade not work at all with the non-pro version? I thought you mentioned above that it would work with scenes. Does it work with the pro version to fade a single light?

From what I can tell, the caseta component hasn’t been updated in the past 2.5 months, so I’ve started to make the changes I’ve been wanting. I only have one hub though, so I wouldn’t be able to help with multi-hub support :slight_smile: However, I am interested in scenes and getting fading to work.

@kevinfcook Fade works on the non-Pro bridge if you program it into a scene (virtualbutton) or Pico button. It does not have arbitrary “Go to level xx, fade yy seconds” for any dimmer, like on the Pro bridge Telnet interface. I’ve tried many different parameters on the GoToLevel request but no luck so far.

There is no actual Python code support for setting fade times for scenes or Pico buttons in pylutron-caseta library, but it could be added using the commands I’ve documented above. Not sure how it would be handled in Home Assistant as it is likely a one-time activity when programming your scenes.

Assuming it were supported in pylutron-caseta as a service call, you could do it with an input select populated with your scene names, an input slider for fade and delay and a script or automation to run it. Stick it all in a group and put it into a ‘Settings’ view in the frontend.

@upsert ok, that’s a shame. Maybe there’s just something you haven’t uncovered yet. How are you figuring all of this out? Just trying different combinations of keys?

As for scene transitions, let me play around with it to see what I can come up with. I think I’ve uncovered something interesting. For example for my virtual button #4:

{"CommuniqueType":"ReadRequest","Header":{"Url":"/virtualbutton/4"}}

{"CommuniqueType":"ReadResponse","Header":{"MessageBodyType":"OneVirtualButtonDefinition","StatusCode":"200 OK","Url":"/virtualbutton/4"},"Body":{"VirtualButton":{"href":"/virtualbutton/4","Name":"Cooking","ButtonNumber":3,"ProgrammingModel":{"href":"/programmingmodel/4"},"Parent":{"href":"/project"},"IsProgrammed":true}}}

I’m assuming the virtual button # and the preset # are always the same?

{"CommuniqueType":"ReadRequest","Header":{"Url":"/preset/4"}}

{"CommuniqueType":"ReadResponse","Header":{"MessageBodyType":"OnePresetDefinition","StatusCode":"200 OK","Url":"/preset/4"},"Body":{"Preset":{"href":"/preset/4","Parent":{"href":"/programmingmodel/4"},"PresetAssignments":[{"href":"/presetassignment/94"},{"href":"/presetassignment/93"}],"DimmedLevelAssignments":[{"href":"/dimmedlevelassignment/94"},{"href":"/dimmedlevelassignment/93"}]}}}

I have two dimmers in virtual button #4, so it looks like each is represented by a separate dimmedlevelassignment. I can dive deeper into a preset and see individual dimmers:

{"CommuniqueType":"ReadRequest","Header":{"Url":"/presetassignment/93"}}
{"CommuniqueType":"ReadResponse","Header":{"MessageBodyType":"OnePresetAssignmentDefinition","StatusCode":"200 OK","Url":"/presetassignment/93"},"Body":{"PresetAssignment":{"href":"/presetassignment/93","Parent":{"href":"/preset/4"},"AffectedZone":{"href":"/zone/12"},"Fade":2,"Delay":0,"Level":100}}}

{"CommuniqueType":"ReadRequest","Header":{"Url":"/presetassignment/94"}}
{"CommuniqueType":"ReadResponse","Header":{"MessageBodyType":"OnePresetAssignmentDefinition","StatusCode":"200 OK","Url":"/presetassignment/94"},"Body":{"PresetAssignment":{"href":"/presetassignment/94","Parent":{"href":"/preset/4"},"AffectedZone":{"href":"/zone/11"},"Fade":2,"Delay":0,"Level":100}}}

So, I’m assuming you have to set the fade time separately on each dimmer in a scene. It doesn’t look like there’s a way to set it for the scene as a whole.

I’m thinking we can do this to fade individual lights in pylutron_caseta:

  1. Receive light id and brightness from HA
  2. Dynamically create scene with only that light in it (we can use virtual button 99 since it’s pretty unlikely to get used ever)
  3. Set fade time
  4. Set desired brightness
  5. Activate scene

The same scene can be reused for each light passed to us by HA. It’s clunky, but it might be the only option.

Sorry… I have been on travel. .I will take a look as soon as I am back. Hopefully some time next week. Let’s get it merged. Thanks for the PR.

Cheers!

1 Like

Thanks!! I merged my changes. Looks like scenes will be available in the next release (I assume 0.51).

1 Like

Support for multiple bridges would be great. Many people need multiple bridges to surpass the 50 device limit, and to extend the range of their Caseta systems.

Hey, I know this is a requested feature and would love to support it. The issue comes with testing the multiple bridges. It is very difficult to code for a setup to that I do not have. Having said that, I can add support for multiple bridges and allow the community to beta test the new feature before fully releasing. Looks like we have a few folks that have contributed to this component so we should be able to have some good support. I can’t give a time estimate life is just too busy at the moment. I hope you understand.

Cheers

I think @jhn’s fork here actually supports multiple bridges. Maybe this code could be implemented into yours? Thank you for your contributions, and I totally understand that this isn’t a high priority for you!

caseta:
bridges:
- host: [ip address of first bridge]
devices:
- id: 1
type: switch
- id: 3
type: switch
- host: [ip address of second bridge]
devices:
- id:
type:

Can someone point me to the git repo for the Caseta code that is actually in HASS?

Look at:

homeassistant/components/lutron_caseta.py
homeassistant/components/light/lutron_caseta.py
homeassistant/components/switch/lutron_caseta.py
homeassistant/components/cover/lutron_caseta.py
homeassistant/components/scene/lutron_caseta.py

Hi everyone,
I have a StaplesConnect that i’m now using only to manage the 7 Picos i have, and all the rest is handled by HA. I just bought a Caseta non-PRO hub, thinking i could link the Picos and use them as switches in HA but they don’t show up. I read the whole thread and before I pull the trigger and return the non-PRO, i want to be sure:

are the Pico working (reliably) with HA if i buy a PRO hub?

@lucacri Currently the lutron caseta component in Home Assistant does not produce any events in Home Assistant for pressing Pico buttons, other than the lights levels changing (i.e. no sensors for the remote buttons). Some more work needs to be done on the underlying pylutron library to support this on Smart Bridge Pro hubs.

I’ve been poking around the Python code to see how much work it will be and I think @gurumitts would be amenable to pull requests to implement it.

A work-around is to use the jhn branch mentioned above. Also appears to be not maintained so it does not have scene support, which was added recently.

Also, if you are choosing between a non-Pro and Pro hub, the Pro hub would be potentially getting Pico support in a future release but the non-Pro hub would not support it (it has no Telnet interface). So in my opinion, it is worth it to get a Pro hub even if the features are not yet implemented in Home Assistant.

I would love to get involved with this project. I have been a ST user for quite some time and actually had a project to integrate the caseta switches into ST before they added official support. In fact I think it was linked somewhere above in this thread. I have it working with either a pro or non pro hub pretty reliably and supports the Picos on the pro hub. I had just started working on multi hub support, but have been getting more and more frustrated with ST and am considering switching over so this component is a major priority for me.

I am still trying to wrap my head around how HASS works, but would love to contribute to this project. I have started looking at the current component and will see what I can get done!

I really hope that you can do this. that would be great.
I keep eying out some of the pro hubs on ebay but havent purchased one yet.

I would be ok with just a way to see scene status but im thinking that it is not possible with the regular hub.