home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.57k stars 29.91k forks source link

Adding dimmable lights to new rfxtrx integration #38045

Closed Fonta closed 4 years ago

Fonta commented 4 years ago

I'm running Home Assistant 0.113.0b3 which has the new rfxtrx integration and now run into an issue where I want to show switches as lights in the GUI. This can be done by using the light.switch platform and works very well for switches that control lights which are not dimmable and only support on/off.

However, I'm also trying to add a couple of lights which do support dimming. These are in-wall dimmers which control lights.

In the previous version I could use the light.rfxtrx platform which gave me the possibility to add device codes which would then show as dimmable lights in the gui:

light: 
  - platform: rfxtrx
    devices:
      0b11000569bc0cfe01010f70:
        name: Main Livingroom

And for on/off lights I would add them to the switch.rfxtrx platform.

switch
  - platform: rfxtrx
      0b110002004aa7de01010f70:
        name: Home Cinema

All you can do now is add the devices in the rfxtrx integration, but you can't define them as dimmable. Also device_class: light doesn't do anything.

rfxtrx:
  device: /dev/ttyS0
  debug: False
  devices:
    # Switch - Door Light (on/off)
    0b110007004aa7de03000070:
    # Switch - Desk Light (on/off)
    0b11000e0049c87a03000070:
    # Switch - Home Cinema
    0b110002004aa7de01010f70:
    # Switch - krk speakers
    0b11000240bc0cfe08010f70:
    # Switch - Floor LED (on/off)
    0b110000004a216201010f60:
    # Switch - Window Light (on/off)
    0b110005004aa7de02010f70:
    # Switch - Bedroom - Door Side Light (on/off)
    0b1100000049c87a01010f70:
    # Switch - Bedroom - Window Side Light (on/off)
    0b1100010049c87a02010f70:

    # Light - Main Living Room Light (dimmable)
    0b11000569bc0cfe01010f70:
      device_class: light
    # Light - Main Bedroom Light (dimmable)
    0b11000283bc0cfe06010f70:
      device_class: light
    # Light - Hallway Light (dimmable)
    0b11000423bc0cfe00010f70:
      device_class: light
    # Light - Toilet Light (dimmable)
    0b11000261bc0cfe02010f70:
      device_class: light
elupus commented 4 years ago

Okey, the event code you use to add them need to be a dimming command. Ie when you figured out those event codes you should have a triggered a dimming event. Anyway i can convert them for you: 0b11000569bc0cfe01010f70 -> 0b11000569bc0cfe01020f70 0b11000283bc0cfe06010f70 -> 0b11000283bc0cfe06020f70 0b11000423bc0cfe00010f70 -> 0b11000423bc0cfe00020f70 0b11000261bc0cfe02010f70 -> 0b11000261bc0cfe02020f70

Fonta commented 4 years ago

The codes were generated using what's described on https://www.home-assistant.io/integrations/switch.rfxtrx/ using: 0b11000{{ range(100,700) | random | int }}bc0cfe0{{ range(0,10) | random | int }}010f70

Changing the device ids to dimming sounds logical. If I however copy the converted codes, the devices show up in the GUI, but missing an entity.

Entities for the device after changing the code: image

Switch device: image

elupus commented 4 years ago

Weird. This is how it looks for me for code: 0b11000261bc0cfe02020f70

image

Fonta commented 4 years ago

That's indeed weird. I just created a new code 0b11000190bc0cfe02020f70, added that to the config and restarted. It only shows the sensor and binary_sensor.

Here's how the device and entities look like in the registry: image

image

image

probot-home-assistant[bot] commented 4 years ago

Hey there @danielhiversen, mind taking a look at this issue as its been labeled with an integration (rfxtrx) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

probot-home-assistant[bot] commented 4 years ago

rfxtrx documentation rfxtrx source (message by IssueLinks)

elupus commented 4 years ago

Found the issue. Really annoying. I must try to get a fix in for next beta. You can work around it by placing all your lights first in the config.

Fonta commented 4 years ago

Got it to work. It however breaks as soon as I add back the switches in the configuration. The switches are after the lights in the config.

elupus commented 4 years ago

Ah, yea true. Will have to wait for release then. (I've tagged it for inclusion)

Fonta commented 4 years ago

Cool. Will wait for that then. :)