Is it possible to change the domain on an entity? I have several light switches that show up as switch
and I would prefer they be under the light
domain.
I think this is typically done by creating a Template Light. You can then hide the switch entity.
light:
- platform: template
lights:
my_light:
value_template: "{{ states('switch.my_switch') }}"
turn_on:
service: switch.turn_on
entity_id: switch.my_switch
turn_off:
service: switch.turn_off
entity_id: switch.my_switch
That worked! Thanks!
Sorry for hijacking this thread but I have a similar problem:
The entitiy_id is âswitch.candlesâ
If I go to states in dev-tools I can enter âswitch.candleâ in the entity and âonâ or âoffâ in the state and the candles will turn on or off
If I set a âEntity buttonâ card in lovelace the light will toggle on then off when selected and not stay on.
I tried you code above and then tried a âEntities cardâ and âLightâ card with a switch but the same results i.e. I turn the candles on and they immediately go off again
Sorted it, the candles were being controlled in a different automation platform via a virtual input switch, changed to a toggle switch and allâs well
Thanks very much for pointing this out! Much cleaner yaml-wise to use than the template for converting switches to lights.
As an aside and wishful thinking - if only there was a âFan_Lightâ platform to remap ceiling fans that are imported as dimmable lights to fans with multiple speeds. I have a fan template that solves this remapping now but it is a quite complex bit of yamlleese.
Hey,
Could you give me a hint on that fan template thing? I also have a dimmable zigbee controller added to my hue bridge which controls fan speed and i donât want to show them up as âlightsâ.
Thank you in advance!
Hi @fighterii,
Hereâs that fan template thing. As I said earlier, itâ's a bit complex, but gets the job done. Itâs especially good for voice commands to refer to a fan as a fan, not a dang light. Note that the brightness to speed value settings here are appropriate for a GE/Jasco Zwave fan 3-speed fan switch.
fan:
- platform: template
fans:
den_ceiling_fan:
friendly_name: "Den Ceiling Fan"
speeds: ['low', 'medium', 'high']
value_template: "{{ states('light.den_ceiling_fan') }}"
speed_template: >
{% if (state_attr('light.den_ceiling_fan', 'brightness')|int < 85) %} {{ "low" }}
{% elif (state_attr('light.den_ceiling_fan', 'brightness')|int > 170) %} {{ "high" }}
{% else %} {{ "medium" }} {% endif %}
turn_on:
service: light.turn_on
entity_id: light.den_ceiling_fan
turn_off:
service: light.turn_off
entity_id: light.den_ceiling_fan
set_speed:
service: light.turn_on
entity_id: light.den_ceiling_fan
data_template:
brightness: >
{% set speedlist = { 'low':25, 'medium':125, 'high':255 } %}
{{ speedlist[speed] if speed in speedlist else 255 }}
bedrooom_ceiling_fan:
<snip>
How can this Light Switch template be used for every switch? Or for a list of switches, do I have to re-configure every single switch all over again?
There is no need to change your switch configurations. Simply add the light switch template to create new light entities for them. You will still have the original switch entities, but I configure Google Assistant to ignore them, and donât display them in lovelace.
light: # associate zwave power switches to lights...
- platform: switch
name: "Porch Lights"
entity_id: switch.porch_lights
- platform: switch
name: "Dining Room Lamp"
entity_id: switch.dr_floor_lamp
- platform: switch
name: "Entry Lamp"
entity_id: switch.entry_lamp
EDIT: oops, sorry for replying to an old post which Iâm sure youâve solved by now. I was directed here by a âlikeâ and thought your question was a new post.
No worries. Your response here was helpful to me. Although, it would be nice if there was a way to do this from the UI if the current push is toward using the UI rather than yaml. Hopefully thatâll get added sooner rather than later.
I personally dislike duplicating entities even if theyâre not terribly difficult to hide, so I really wish there was just a way to indicate a switch goes to a light and just make it work without jumping through hoops.
So I canât get this to work. It will turn on, but wonât adjust the speed.
fan:
- platform: template
fans:
living_room_fan:
friendly_name: "Living Room Fan"
value_template: "{{ states('light.living_room_fan_hallway') }}"
speed_template: >
{% set output = {0: "Off", 85: "Low", 170: "Medium", 255: "High"} %}
{% set idx = state_attr('light.living_room_fan_hallway', 'brightness') %}
{{ output[idx] }}
turn_on:
service: homeassistant.turn_on
entity_id: light.living_room_fan_hallway
turn_off:
service: homeassistant.turn_off
entity_id: light.living_room_fan_hallway
set_speed:
service: homeassistant.turn_on
entity_id: light.living_room_fan_hallway
data_template:
brightness: >
{% set mapper = {'Off': 0, 'Low': 85, 'Medium': 170, 'High': 255} %}
{{ mapper[speed] }}
speeds:
- 'Off'
- 'Low'
- 'Medium'
- 'High'
What am I doing wrong? Lol
What Im I doin wrong?? I want to add those switches to light groupâŠ
light:
- platform: group
name: 2krs valot
entities:- light.2_krs_keittio_kaappi
- light.2_krs_valokatto_oikea
- light.2_krs_valokatto_vasen
- light.din_rail_dimmer_23_01_50
- light.din_rail_dimmer_23_00_61
- switch.din_rail_on_off_23_08_db
- light.din_rail_dimmer_23_01_cb
- switch.din_rail_on_off_23_08_33
- switch.din_rail_on_off_23_08_de
- platform: switch
name: â2 krs. Kuilu kruunuâ
entity_id: switch.din_rail_on_off_23_08_db - platform: switch
name: â2 krs. ruokapöytĂ€â
entity_id: switch.din_rail_on_off_23_08_33 - platform: switch
name: â2 krs. Tauluvalotâ
entity_id: switch.din_rail_on_off_23_08_de
How would you go about converting a light to become a switch?
The OP here was how to convert switches that control lights to be referred to as lights in a more appropriate light domain. I see now that you are asking the opposite - how to turn a light into a switch. Thatâs a curious use case that I donât have a quick answer for.
Thanks for taking the time to reply. This is a strange one, as it is quite normal to use switches - often in the form of âpillsâ to switch lights on/off. As such, the switch actually should correctly be identified as a light. So the OPâs request is answered by the âSwitch as Xâ integration.
But I have several âpillsâ from different manufacturers that do identify themselves as lights by default. Now since these âpillsâ can be used to switch almost anything on/off (not only lights), it is sometimes very convenient to define them as switches and not as lights.
I for one, have âpillsâ that controls my coffee machine, toaster, boiler, etc. When I ask Home Assistant to turn off all lights in the kitchen, it also switches off all of those other devices because the âpillsâ are defined as lights. I know there is a possibility to create a so called shadow entity using templating, but that gives you a new switch entity while the original light remains. So the problem also remains.
I wonder why the HA Dev team hasnât recognized this as a much needed feature.
A simple solution to that is to place the original light in another area (or if you are talking about google home, exclude it from syncing to google).