Change entity from light.device to switch.device

Hello,

Sorry if this is a duplicate post or not (but i could not find anything similar on the forum). I am using Hass.io + HA bridge + homebridge. I would like to use all my devices with Siri. The problem is, all my devices are considerate as lights. So when i am trying to ask Siri to turn off the lights, it is turning off everything. So i would like to know how can i change the entity of my devices with HA bridge and home assistant. For example: light.projector > switch.projector.

thank you for your help ! :slight_smile:

EDIT: I am using HA bridge for my harmony hub

Why are you using HAbridge in the middle? That’s the problem. Go straight from Hassio to Homebridge and all your devices will be passed through as their proper entity types.

sorry i forgot to mention that i have an Harmony Hub, that why im using HAbridge.

Hello
I have similar problems, I want to change my switch.device to light.device, because there are lights attached to these switches and for Google Home to understand that there are lights not switch.
I get my switches and lights through Tellstick Live. I don’t have switch or lights in my config.yaml.

Or can I do anything else to get Google Home (Assistant) to understand the switches as lights. As it is now, I can not say, “Turn of lights in Living Room”, then it only extinguishes a lamp sitting on a dimmer. If, on the other hand, I say “Turn of Switches in Living Room”, the other lights turn off, but not the dimmer.

There may be a much better way to do this, but I don’t use Google Home so I don’t have any experience with it.

But, having said that, you might be able to use Template Lights (https://www.home-assistant.io/components/light.template/) to create a light entity “wrapper” for each switch entity. E.g.:

light:
  - platform: template
    lights:
      abc:
        friendly_name: 'Light ABC'
        level_template: '{{ 255 if is_state("switch.abc", "on") else 0 }}'
        value_template: '{{ is_state("switch.abc", "on") }}'
        turn_on:
          service: switch.turn_on
          entity_id: switch.abc
        turn_off:
          service: switch.turn_off
          entity_id: switch.abc
        set_level:
          service_template: switch.turn_'{{ "off" if brightness == 0 else "on" }}'
          entity_id: switch.abc
      # Repeat for additional switches
      def:
        ...

With this you can control “abc” as either switch.abc or light.abc.

Disclaimer: I haven’t tried this so I might have gotten the details wrong.

1 Like

Thank you sir! I think I got it to work, this is my code, and I get my light.vrum_fonster1 under “states”.

light:

  - platform: template
    lights:
      vrum_fonster1:
        friendly_name: 'Living Room 2'
        level_template: '{{ 100 if is_state("switch.vrum_fonster1", "on") else 0 }}'
        value_template: '{{ is_state("switch.vrum_fonster1", "on") }}'
        turn_on:
          service: switch.turn_on
          entity_id: switch.vrum_fonster1
        turn_off:
          service: switch.turn_off
          entity_id: switch.vrum_fonster1
        set_level:
          service_template: switch.turn_'{{ "off" if brightness == 0 else "on" }}'
          entity_id: switch.vrum_fonster1

What should I do with this, as in your example? (I got an error when I checked my config, I just removed it and it seems to work…)

def:
  ...

I guess I have to do this for each switch? Can not put all switches together in any way? They must have an unique id.

That was just my way of saying you repeat this structure for more switches/lights. That part wasn’t intended to be entered verbatim. :slight_smile:

Yes, I believe you’d have to have an individual entry for each switch for which you want a “light wrapper”. Maybe there’s an easier way, but if there is, I’m not seeing it.

you can probably create a group for your switches.
and then use the group entity in your template light.

2 Likes

Ah, that’s a good idea. But if so, the template would need to be a adjusted a bit. So something like this:

light:
  - platform: template
    lights:
      group1:
        friendly_name: 'Light Group 1'
        turn_on:
          service: homeassistant.turn_on
          entity_id: group.switch_group_1
        turn_off:
          service: homeassistant.turn_off
          entity_id: group.switch_group_1
        set_level:
          service_template: homeassistant.turn_'{{ "off" if brightness == 0 else "on" }}'
          entity_id: group.switch_group_1

This assumes group.switch_group_1 exists and is a group of the switch entities you want to control as a group of lights. And you would control it as light.group1.

BTW, I removed value_template and level_template, which then causes the default “optimistic” behavior, which I believe just means that it remembers what state & level it was set to last and reports that as the current state & brightness level.

1 Like

And this you say now … :joy:
I’ve entered all of my rooms and synced with Google Home, looks and works as it should. Maybe i will try to test with groups but do not have so many switches so that’s no problem. (And I want to control only one particular light)
And before you posted last example I changed the Value:
level_template: '{{**100** if is_state ("switch.vrum_fonster1", "on") else 0}}'

100 to 255 for the icon to light 100% yellow.

And to see the changes, I had to restart HA.
Little feedback if someone else have benefits from this.

Thanks for the help!

1 Like

Ah, I keep forgetting for brightness there’s brightness (0 to 255) and brightness_pct (0 to 100.) I always use brightness_pct. I’ll go back and adjust the example accordingly (like you say, for future reference.)

Yeah, if you want individual light control then you’d probably want individual template lights for each switch entity.

Although this still may not be the best way, I’m glad it helped. :slight_smile:

1 Like

Hi.

I followed your steps and got everything to work with Google Assistant but now HA and Google Home is showing both a light and switch for the same unit.

Is there a way to only get the light to be shown and not the switch?

Try hiding the switch.

Thanks for the tip, I tried it and the switch got hidden in HA but not in Google Home when I relinked it to hass.io
Both the light and the switch for the same unit was discovered by google home.

i dont have google home, but i am sure that you can specify which entities you want exposed and which not.

I found a way to exlude the switch.
I’m using Google Assistant via Home Assistant Cloud

Added this in configuration.yaml

# Cloud
cloud:
  google_actions:
    filter:
      exclude_entities:
        - switch.amandas_rum_fonster
        - switch.amandas_rum_sangen

When you have updated your configuration.yaml, restart HA and then say “ok google, sync my devices” (my google assistant talks swedish so I said it in swedish and that worked just fine)
This way you don’t need to relink hass.io in google home.