jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
198 stars 48 forks source link

Issue with Luton Aurora Controller; can't utilize "level" as a trigger (ie, when turning the knob to dim/brighten lights) #273

Open ajtatum opened 5 months ago

ajtatum commented 5 months ago

Describe the bug

So I recently purchased a Lutron Aurora Controller and added it to Hubitat with a custom driver. This is how it shows up in Hubitat:

thorium_MUiKKXqyyt

When I add it to the list of devices to be made available to Home Assistant, the device shows up as a light with a button which can toggle lights on and off:

thorium_MThgkhKv7r

When I to automations, the only "physical action" I can make use of is when the button is pushed:

thorium_p8E8BdZT5R

There isn't any way for me to make an automation, that I know of at least, that can make use of the outer knob where someone can dim or brighten the lights. Right now, I've built an automation in Hubitat so that the lights basically copy the attributes of the Aurora controller, and while that works, I really don't want to have remember if an automation is in Hubitat or Home Assistant.

Is there anyway to take full advantage of this device in Home Assistant?

Thank you! AJ

Environment

ajtatum commented 4 months ago

Any ideas on this? I'm running into conflicts between hubitat and home assistant if the switches are part of an automation in HA. I'd have to move all automations that are a part of this switch to Hubitat... Which would suck lol.

smoores-dev commented 4 months ago

I'm having exactly the same problem! It would be great if there was a way to override the heuristics that this integration uses for determine what to expose in Home Assistant for a given device.

@jason0x43 do you have any ideas as to how we might work around this? If you have a direction to point me in, I'd be willing to take a stab at a PR, as well, if one is necessary.

jason0x43 commented 4 months ago

Hmmm...a couple questions:

  1. What are you trying to achieve? Is the goal to detect brightness changes in the light?
  2. Does the light have a brightness/level control in Home Assistant, or is it just showing up as a simple switch?
smoores-dev commented 4 months ago

Thanks for responding so quickly!! So to be clear, this thing is a dimmer switch, not a light. Here's a link: https://residential.lutron.com/us/en/stand-alone-controls/smart-bulb-dimmer.

I can't speak for @ajtatum, but I wish to use the level from the dimmer switch to set the brightness level on a light/group of lights that are in Home Assistant but not in Hubitat.

The dimmer switch doesn't have a level attribute in HA; it just shows up as a simple switch. It does have a level in Hubitat.

jason0x43 commented 4 months ago

Could you send me the device capabilities for the switch? From the screenshot I see that it has a level attribute, so I'd expect it to have Hubitat's SwitchLevel capability, but maybe it's not reporting that (third party drivers don't always seem to be great about following Hubitat's spec).

smoores-dev commented 4 months ago

I'm actually using the official driver! Here's the output, it does seem to have the SwitchLevel capability:

{
    "id": "148",
    "name": "Lutron Aurora Controller",
    "label": "Second floor guest room dimmer",
    "type": "Lutron Aurora Controller",
    "room": "Second Floor Guest Room",
    "attributes": [
        {
            "name": "level",
            "currentValue": 1,
            "dataType": "NUMBER"
        },
        {
            "name": "pushed",
            "currentValue": 1,
            "dataType": "NUMBER"
        },
        {
            "name": "battery",
            "currentValue": 100,
            "dataType": "NUMBER"
        },
        {
            "name": "numberOfButtons",
            "currentValue": 1,
            "dataType": "NUMBER"
        },
        {
            "name": "switch",
            "currentValue": "on",
            "dataType": "ENUM",
            "values": [
                "on",
                "off"
            ]
        }
    ],
    "capabilities": [
        "Configuration",
        "Actuator",
        "Battery",
        {
            "attributes": [
                {
                    "name": "battery",
                    "dataType": null
                }
            ]
        },
        "SwitchLevel",
        {
            "attributes": [
                {
                    "name": "level",
                    "dataType": null
                }
            ]
        },
        "Switch",
        {
            "attributes": [
                {
                    "name": "switch",
                    "dataType": null
                }
            ]
        },
        "PushableButton",
        {
            "attributes": [
                {
                    "name": "numberOfButtons",
                    "dataType": null
                },
                {
                    "name": "pushed",
                    "dataType": null
                }
            ]
        }
    ],
    "commands": [
        "configure",
        "off",
        "on",
        "push",
        "setLevel"
    ]
}
smoores-dev commented 4 months ago

Oh... huh! I just went and checked in Home Assistant, and actually there is a level entity there! It was just disabled for some reason. I enabled it, I'll see if that works for automations. Will report back!

smoores-dev commented 4 months ago

Yeeeup, that works just fine! This at least resolves my issue; there may be another issue with the third party driver, but all that I was missing was that the level and switch entities for the device were disabled for some reason!

jason0x43 commented 4 months ago

there is a level entity there

Interesting. What does that look like in HA? I've only ever seen level controls that are part of the light or switch.

smoores-dev commented 4 months ago

image

jason0x43 commented 4 months ago

Are you overriding the device type, by chance? I would have expected that device to be detected as a light due to the presence of the SwitchLevel attribute, in which case the switch level would have been wrapped into the light state as a "brightness" attribute which could be used in automations.

jason0x43 commented 4 months ago

Regarding the original issue, about utilizing "level" as a trigger, currently the only device triggers the integration supports are for button pushes. Support for other triggers is doable, but until that support is added you could use a numeric state trigger on a level attribute.

smoores-dev commented 4 months ago

Are you overriding the device type, by chance? I would have expected that device to be detected as a light due to the presence of the SwitchLevel attribute, in which case the switch level would have been wrapped into the light state as a "brightness" attribute which could be used in automations.

Yes, I am! I just added a second Aurora device to verify this: if I don't override the type to be a switch, the "light" device that is imported seems to have no level entity at all, nor does it have a level control, just an on/off toggle.

Once I enabled the level and switch entities, though, I was indeed able to use entity state triggers to accomplish what I wanted!

jason0x43 commented 4 months ago

the "light" device that is imported seems to have no level entity at all, nor does it have a level control, just an on/off toggle.

It wouldn't have a separate level entity as a light, or generally as any other type of switch with level control (cover, fan controller, etc.). For example, as a light, the level is the brightness attribute of the light. If a level switch is used as a fan controller, the level would map to the percentage (fan speed) attribute.

If the Aurora controller is added as a light, it should have a switch entity:

Screenshot 2024-06-02 at 21 39 58

Tapping the entity name (not toggling it) should give you a controller with an on-off button and a level slider.

Screenshot 2024-06-02 at 21 40 09

If you look at the state info for the light entity in the Developer Tools, it should have a brightness attribute (at least if the switch is on).

Screenshot 2024-06-02 at 21 41 23

If, as a light, it's only showing up as a basic on/off light without a brightness attribute, something is wrong somewhere. 🙂

ajtatum commented 3 months ago

Sorry I missed this as I've had some health issues, but thanks @jason0x43 for looking into this. It sounds like what I and @smoores-dev want are the same, so I'll take a look at the entity in HA to see if it updated to have the level control.

ajtatum commented 3 months ago

@smoores-dev / @jason0x43 - I tried both the default driver and the custom one and neither of them showed the "Level" sensor. Is there something I'm missing?

Default Driver: thorium_ntK6awK0f0

Custom Driver: thorium_wk5M4tVyBx

smoores-dev commented 3 months ago

It looks like it's still set up as a light; I had to override the device type to be "switch" to see the disabled level entity

ajtatum commented 3 months ago

@smoores-dev - I actually just read your comment about that and am researching how to override the device type. I've only used the Helper before to change the device type of a switch. Would you mind sharing how you go about doing that or sharing a link with more info? I'd really appreciate!

ajtatum commented 3 months ago

I've taken a couple stabs borrowing code from what I could find from ZHA and other integrations, but the configuration is invalid. I've tried something like:

hubitat:
  device_config:
    56: # Hubitat Device ID
      type: "switch"
smoores-dev commented 3 months ago

Oh! This is built in to the Hubitat integration; when you submit the configuration in the UI, one of the confirmation panels asks you about whether any devices that it detected as lights should actually be switches

ajtatum commented 3 months ago

I totally forgot about that popup, thanks @smoores-dev! I now have the Level sensor!

jason0x43 commented 2 months ago

@ajtatum When using the device as a light (without overriding the type), if you tap the switch entity on the device page (not the toggle, but the entity name)

image

you should get a popup with a slider

image

The popup for a non-dimmable switch will be a toggle

image

The brightness slider control is how switch level is handled for a light. Lights won’t have separate sensors for brightness (level), color, or any other light attributes. That is typically how other Home Assistant integrations handle light devices as well.

Some common ways to react to brightness changes are:

  1. Trigger on brightness in automations image
  2. Create a template sensor that tracks a particular device attribute (e.g. brightness), and then use that in automations.