gurumitts/pylutron-caseta

RA3/QSX Button LED Names don't identify the Keypad and Button

danaues opened this issue · 9 comments

@cbw, Amazing work on the QSX support, and for adding LED and button press support.

I've been testing with my setup, and I think it would help to use a more meaningful name for the Keypad LEDs

I have 2 keypads in this area, a 3BRL and a 4B. It's hard to tell which led these belong too.
Ideally they would be named "LED_Hallway Main Stairs_Position 1_Button2" or something like that.

image

cbw commented

Thanks for catching that! I may have had a regression, thought I fixed it (or perhaps it was in the HA side of the code I was working on). I'll take a look tonight.

@cbw, FYI another PR was just merged for the lutron_caseta HA component to fix a regression in the handling of 'None' serials.

home-assistant/core#77553

In case this affects your HA testing.

My system is returning an empty string for button_engraving["Text"]. The "Engraving" key exists, so button_engraving doesn't get assigned 'None', just returns a dict with an empty "Text".

button_engraving = button_json.get("Engraving", None)
parent_id = id_from_href(button_json["Parent"]["href"])
button_led = None
button_led_obj = button_json.get("AssociatedLED", None)
if button_led_obj is not None:
button_led = id_from_href(button_led_obj["href"])
if button_engraving is not None:
button_name = button_engraving["Text"].replace("\n", " ")
else:
button_name = button_json["Name"]

changing the if statement to :

if button_engraving is not None and button_engraving["Text"]:  

fixes it for me.
Might be a better way though

For the naming, it would be nice to keep the button naming consistent with the Keypad naming.

button_name = button["button_name"]
station_name = keypad_device["control_station_name"]
self.devices.setdefault(
button_led,
{
"device_id": button_led,
"current_state": -1,
"fan_speed": None,
},
).update(
name="_".join((station_name, f"{button_name} LED")),
type="KeypadLED",

Instead of station_name we could use keypad name, and join it to the button_name LED

keypad_name = keypad_device["name"] 

name="_".join((keypad_name, f"{button_name} LED")), 

This is what mine looks like if I name it this way.

They keypad device name matches the LED's below it. (1st keypad has engraving names, 2nd does not)
image

cbw commented

Great suggestions – incorporated these and tested, looks good on my test QSX processor as well. Submitted #110 with this update.

Now I just need to get my HomeAssistant button code cleaned up and submitted! The HA button situation is a little messy, and may take some refactoring to make clearer with what's in there now for handling Pico events.

Let me know if there is anything I can help with, I"m happy to help test.

cbw commented

@danaues any tips from your experiencing making a PR on homeassistant-core, especially on testing? Are you on the Home Assistant discord by chance?

@cbw, unfortunately, I'm not on the discord. I could join though.
bdraco was great at helping out, was quick to respond and was eager to have new contributors.
I think he's travelling right now, but he will approve and be a great resource.

Do you want me to test anything before you create the PR?