Custom Proxy Platform - Easily Convert Switches to Lights!

Ever had the problem that some integration would expose some entities as switches, when they really were lights? With my new custom light proxy platform you can easily convert all switches to lights (without any complicated templates)

In most cases it’s as simple as this:

# Example configuration.yaml entry
light:
  - platform: proxy
    name: Kitchen Lights
    entity_id: switch.kitchen_lights_as_switch

This will copy the states of switch.kitchen_lights_as_switch into a new light.kitchen_lights entity. All turn_on/turn_off commands you send to the light will automatically be forwarded to the switch.

See https://github.com/OttoWinter/home-assistant-proxy-platform for more info.

5 Likes

it‘s so cool 酷😎

That’s very easy to do with template light too.

light:
  - platform: template
    lights:
      kitchen_lights:
        friendly_name: "Kitchen Lights"
        value_template: "{{ is_state('switch.kitchen_lights', 'on') }}"
        turn_on:
        - service: switch.turn_on
          data:
            entity_id: switch.kitchen_lights
        turn_off:
        - service: switch.turn_off
          data:
            entity_id: switch.kitchen_lights
2 Likes

Yes I know :slight_smile:

It’s just that I’ve seen many users stumble over this and using those templates is really too complicated for the use-case I think.

And then consider adding the template for each one of your switches, the proxy platform makes it just that much easier. Also, the proxy platform handles some other stuff too:

  1. it supports any switch-like entity (for example input_boolean)
  2. it reports unavailable if the switch doesn’t exist or isn’t available.
  3. (not too important, but it’s a lot faster; and probably more robust, for example having multiple service calls at once)
  • If for some reason the entity id of the switch changes, with the template you’ll have to change three lines, whereas with this platform you’ll only have to do it once :slight_smile:

Truly a great platform this. Is there a way to optimise the syntax for more than one light/switch?
Currently my config looks like this:

light:
  - platform: proxy
    entity_id: switch.hall_light_switch
  - platform: proxy
    entity_id: switch.bedroom_light_switch
  - platform: proxy
    entity_id: switch.livingroom_light_switch

It could be nice with a more clean config like

 light:
   - platform: proxy
     entities: 
       - switch.hall_light_switch
       - switch.bedroom_light_switch
       - switch.livingroom_light_switch

Found this by searching.
Is this component still active. Can it be used in 0.93?

@Bluhme - I don’t think this can be used currently.
I tried changing to the new package structure for >0.91 and gave it a try but it fails.
I think this is due to the changes in 0.88 that prevents custom overlays of components or some change in the way components are initialized.
@OttoWinter - any plans to update this?

Did you create the __init__.py and manifest.json files for it? I wouldn’t mind giving this a try myself if it works

If you want to try, just rename proxy.py to __init__.py and drop it in /config/custom_components/light_proxy/ as there are no dependencies listed.
I don’t think it needs a manifest.json
If you need a minimal one, you can get the one I created here
I was getting light.proxy not found when checking my config and did not get an initialization success message in my logs. (running 0.93.1)

gents, this component is already in HA

4 Likes

… and now I feel stupid! Thanks :upside_down_face:

I’m probably missing something obvious, but what is the advantage of having something as a light instead of switch?

Some devices such as plug-in smart switches or even hard-wired z-wave devices will show in HA as a switch (rather than a light) by default. If for example one of those items is connected to a lamp, then you would want it to show in HA as a light, not a switch.

OMG Juan, thank you. Guess I should read the docs more frequently… it’s been there since 0.83!
:thinking::flushed:

Yes, I understand that. I have many switches that are connected to lights. But why would you want that? The icon can be changed. Feature-wise it will remain the same. What do you obtain from it?

This way the device becomes part of the light domain, so when you issue commands based on a domain, it is included.

Also importantly is that you can’t group switches with lights and have them behave the same way.
Only lights can be placed in light groups

The supported features of all lights will be added together. For example, if you have one RGB light in a group of otherwise brightness-only lights, the light group will be shown with a color picker.

:grin::grin::grin: not at all. I found it by mistake, it’s difficult to keep up with HA features as they expand continuously.