gurumitts / pylutron-caseta

Apache License 2.0
153 stars 97 forks source link

Support for RA2 Select In-Line Dimmer #103

Closed crazystick closed 2 years ago

crazystick commented 2 years ago

I have the RA2 Select system I'd like to use with HA. The scenes work within HA so I'm hoping that just adding InLineDimmer and InLineSwitch to _LEAP_DEVICE_TYPES will just work. Only started with HA last night but happy to test something with a bit of guidance.

Here's a snippet from HA's diagnostic:

"data": {
      "devices": {
        "1": {
          "device_id": "1",
          "current_state": -1,
          "fan_speed": null,
          "zone": null,
          "name": "Smart Bridge 2",
          "button_groups": null,
          "type": "RA2SelectMainRepeater",
          "model": "RRK-SEL-REP2-BL",
          "serial": 53030971
        },
        ...
        "6": {
          "device_id": "6",
          "current_state": 0,
          "fan_speed": null,
          "zone": "3",
          "name": "Main Bathroom_Main Lights",
          "button_groups": null,
          "type": "InLineSwitch",
          "model": "RRK-R6ANS-240",
          "serial": 60575713
        },
        ...
        "10": {
          "device_id": "10",
          "current_state": 0,
          "fan_speed": null,
          "zone": "6",
          "name": "Master Bedroom_Main Lights",
          "button_groups": null,
          "type": "InLineDimmer",
          "model": "RRK-R25NE-240",
          "serial": 49259950
        },
BenHall commented 2 years ago

I have the same issue/requirement and I agree with your idea.

In the Lutron component, it calls the library for lights via https://github.com/home-assistant/core/blob/dev/homeassistant/components/lutron_caseta/light.py#L44

The code for this translates the "light" into the Lutron Leap types. This loops around on all the types and returns them https://github.com/gurumitts/pylutron-caseta/blob/855b339e257681ae5e65caeb98a1a09030172073/pylutron_caseta/smartbridge.py#L200

I think the issue is that https://github.com/gurumitts/pylutron-caseta/blob/855b339e257681ae5e65caeb98a1a09030172073/pylutron_caseta/__init__.py#L8 doesn't include "InLineDimmer" and "InLineSwitch" so they are not being included in HA.

The original commit was https://github.com/gurumitts/pylutron-caseta/issues/8 so I think it's just been missed off the list?

BenHall commented 2 years ago

It looks like this has been included with the support for RA3.

Could we do a smaller PR just for these two types?

iCSpotRun commented 2 years ago

@BenHall Agree. Would also like to add the devices listed in issue #98, but I've yet to secure these devices and test for their identity for inclusion. Anyone here know another way to discover these?

BenHall commented 2 years ago

@iCSpotRun Sadly not. I only have inline dimmers and switches which makes the response in the first post.

crazystick commented 2 years ago

I also don't have access to anything else beyond what I added in the initial comment I'm afraid.

crazystick commented 2 years ago

Small update. I patched __init__.py in my home assistant installation, the lights show up, and they are controllable and dimmable.

BenHall commented 2 years ago

Small update. I patched __init__.py in my home assistant installation, the lights show up, and they are controllable and dimmable.

I missed the update. That's great news. Can you share a gist or fork of your changes please?

crazystick commented 2 years ago

have created PR #104 with these changes.

I run HA in docker using docker-compose. I tested these changes using the following docker-compose.yml:

version: '3'
services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - config:/config
      - /srv/homeassistant/pylutron_caseta_init_py:/usr/local/lib/python3.10/site-packages/pylutron_caseta/__init__.py
    environment:
      - TZ=Europe/Tallinn
    restart: unless-stopped
    privileged: true
    network_mode: host

volumes:
  config:
    driver: local
    driver_opts:
      type: none
      device: /srv/homeassistant/volumes/config
      o: bind