Ohh deer, the Christmas is coming. How to handle temporary lights?

Hi,

Soon my wife will turn up side down on my HA setup.
During most part of the year we have regular zigbee bulbs in all our window lamps.
Those lamps will be disconnected and put away during December and replaced with “dumb” Christmas lamps.
Of course I’m gonna make them “smart” with some plugs or esp devices but my problem is the entities.

How do you all handle temporary “unavailable” lights replaced with something else?
I’m thinking about scripts, automations and Google home that use specific entity names.

Will I have to adapt all my config during December and then change back to my old config or is there som automagic solution?

Of course I could “simply” remove my zigbee lights, name the Christmas lights exactly the same and have the same entity names as the zigbee bulbs. However that sounds like no fun and I guess some of you have figured out a way to do this automatically once a year.

Share your best ideas :slight_smile:

1 Like

I include christmas lights in my “normal” automations and scripts. At the moment all my UI stuff is commented away but I plan to change that to a conditional cards and have a boolean for Christmas mode on/off. (If needed for other stuff such as automations I plan to use the boolean for that as well as a condition)

1 Like

Don’t you get errors when some lights are offline? Regular lights during Christmas and Christmas lights the rest of the year?
Or do you have conditions in all automations that if Christmas Boolean is on, ignore regular lights and the other way around?

Do you use Google home/assistant?
That one will probably be tricky to solve, but I’m thinking about exposing some template lights and have a “Christmas” Boolean that makes the template light operate the correct light. One thing that can bug out is that my zigbee lights are dimmable and the Christmas lights are not.
Anyone knows how the template light will be handled by Google if it is dimable sometimes and sometimes not?

How do you all handle temporary “unavailable” lights replaced with something else?
I’m thinking about scripts, automations and Google home that use specific entity names.

Get a divorce. :smiley:

But seriously, packages might be a good way to deal with this sort of config change.

2 Likes

That was my initial thought and solution but then I though that some people here might actually have avoided the divorce by some smart HA setup :rofl:

Packages looks interesting and might solve a part of the problems but the Google home expose will still by tricky and I think template lights will work if Google don’t bug out with the non dimable lights exposed as dimable.

All my chrismas stuff is either 433 plugs (which are no problem at all) or IKEA bulbs. I have not checked for it but I do not think the automation throws an error if the bulb is unavailable. If it do it is not very loud… The automations are there all of the time at the moment but the UI components are not.

1 Like

You could also duplicate the automations/scripts and rename and edit them to use the new entities/ services. Then just turn off the original automations during the Christmas period.

You might have to create a new set of Lovelace cards in a view for the Christmas period too.

Does it have to be zigbee? If you haven’t decided yet MQTT would be quite easy to spin-up, or ESPHome. Both could be used via ESP8266.

That being said, in either case why not just have lights.christmas_lights or lights.occassion that are only available partially? Since christmas comes around again each year keep the spot for it reserved.

Edit: Or you can even use a group! And add/remove members throughout the year, e.g. have two for easter etc.

Thanks for all response.
I’m leaning to have some “Christmas” input boolean and then adopt my scripts and automations with if boolean on, control Christmas lights, if off, control regular lights.

The only problem I have now is Google Home integration.
I know what I want to try but I’m not so good with templating.

Lets say I have following entities:

light.window_light1
light.christmas_window_light1

Input boolean:

input_boolean.christmas 

What I want to achieve is something like:

light:
  - platform: template
    lights:
      windows_light_template1:
        friendly_name: "Window Light Template1"
        level_template: 
#If input_boolean.christmas is on: no level since the christmas light is not dimable
#If input_boolean.christmas off: light.window_light1
        value_template:
#If input_boolean.christmas is on: light.christmas_window_light1
#If input_boolean.christmas off: light.window_light1
        turn_on:
#If input_boolean.christmas is on: light.christmas_window_light1
#If input_boolean.christmas off: light.window_light1
        turn_off:
#If input_boolean.christmas is on: light.christmas_window_light1
#If input_boolean.christmas off: light.window_light1
        set_level:
#If input_boolean.christmas is on: no level since the christmas light is not dimable
#If input_boolean.christmas off: light.window_light1

Is this possible with template lights? And can somebody help writing the correct template?
If possible it would be a nice way to expose light.windows_light_template1 to google home and in that way only have one light to manage in the google home app. Also it should work automatically without having to reasign any light every Christmas.

So I tried this and now I’m stuck.
light.vardagsrum_fonster_1 is the supposed regular zigbee light with britghtnes control.
light.lusthus_fonster_1 is the supposed christmas light with no brightness control.

- platform: template
  lights:
    test_lampa_1:
      friendly_name: 'Test Lampa'
      level_template: 
        {% if is_state('input_boolean.christmas_lights', 'on') %}
          '{{ 100 if is_state("light.lusthus_fonster_1", "on") else 0 }}'
        {% else %}
          '{{states.light.vardagsrum_fonster_1.attributes.brightness }}'
        {% endif %}
      value_template:
        {% if is_state('input_boolean.christmas_lights', 'on') %}
          '{{ is_state("light.lusthus_fonster_1", "on") }}'
        {% else %}
          '{{ is_state("light.vardagsrum_fonster_1", "on") }}'
        {% endif %}
      turn_on:
        service: light.turn_on
        entity_id: 
          {% if is_state('input_boolean.christmas_lights', 'on') %}
            light.lusthus_fonster_1
          {% else %}
            light.vardagsrum_fonster_1
          {% endif %}
      turn_off:
        service: light.turn_off
        entity_id: 
          {% if is_state('input_boolean.christmas_lights', 'on') %}
            light.lusthus_fonster_1
          {% else %}
            light.vardagsrum_fonster_1
          {% endif %}

This is what the log showed when I restared HA:

2019-11-24 13:32:38 ERROR (SyncWorker_1) [homeassistant.util.yaml.loader] while scanning for the next token
found character '%' that cannot start any token
  in "/config/lights.yaml", line 46, column 10
2019-11-24 13:32:38 ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: while scanning for the next token
found character '%' that cannot start any token
  in "/config/lights.yaml", line 46, column 10

Line 46, column 10 is the first % after “level_template”.

Any ideas?

So another try but still errors.
Can’t get my head around templates :frowning:

2019-11-24 22:27:58 ERROR (MainThread) [homeassistant.config] Invalid config for [light.template]: not a valid value for dictionary value @ data['lights']['test_lampa_1']['turn_off'][0]['entity_id']. Got None
not a valid value for dictionary value @ data['lights']['test_lampa_1']['turn_on'][0]['entity_id']. Got None. (See /config/lights.yaml, line 0). Please check the docs at https://home-assistant.io/integrations/light.template/ 

This time I tried this adding >-

- platform: template
  lights:
    test_lampa_1:
      friendly_name: 'Test Lampa'
      level_template: >-
        {% if is_state('input_boolean.christmas_lights', 'on') %}
          '{{ 100 if is_state("light.lusthus_fonster_1", "on") else 0 }}'
        {% else %}
          '{{states.light.vardagsrum_fonster_1.attributes.brightness }}'
        {% endif %}
      value_template: >-
        {% if is_state('input_boolean.christmas_lights', 'on') %}
          '{{ is_state("light.lusthus_fonster_1", "on") }}'
        {% else %}
          '{{ is_state("light.vardagsrum_fonster_1", "on") }}'
        {% endif %}
      turn_on:
        service: light.turn_on
        entity_id: >-
          {% if is_state('input_boolean.christmas_lights', 'on') %}
            light.lusthus_fonster_1
          {% else %}
            light.vardagsrum_fonster_1
          {% endif %}
      turn_off:
        service: light.turn_off
        entity_id: >-
          {% if is_state('input_boolean.christmas_lights', 'on') %}
            light.lusthus_fonster_1
          {% else %}
            light.vardagsrum_fonster_1
          {% endif %}

HELP :smiley:

Unless I miss my guess… all lights involved in being Christmas are just turned off or on, is that right?

Why not add them to a group to abstract them as one entity?

Then you can add a simple switch for the Christmas group, or make an automation with triggers and conditions such as time of day and calendar period?

Well, that’s not really what I want.

I want to create a template light that operates Christmas or Regular light based on if the Boolean is on or off.
Then I want to expose that template light to Google assistant and Google will think it’s one light only and don’t throw errors about lights that are offline. Also it will be a matter of just flipping the Boolean when Christmas is near and then flip it back after Christmas.

Oh I see.
Is AND or OR: Are the regular lights always on, and optionally Christmas lights, with this one trigger?
Or is it one or the other?

It’s OR. Our regular window lights (zigbee) will be stored in the basement for about a month and replaced by some Christmas lights that will probably be controlled by some esp device.
Then a month later the regular lights will come back up and the Christmas lights stored for 11 months.
Easiest solution would be to ban Christmas lights in the house but IF Christmas lights = BAN, THEN = divorce :wink:

I think my template is almost correct but still I can’t figure out how to make it 100% working.

Hah yes, easier than a divorce :wink:

So, what if you create a light group:

- platform: group
  name: "Window Lights"
  entities:
    - light.lusthus_fonster_1
    - light.vardagsrum_fonster_1
    - light.window_normal_1
    - light.window_normal_2

Since BOTH Christmas and Regular lights are members, they’ll all be triggered with a service call or action to “light.on”, i.e. “Turn on the light [group]”.

I do not think an error will be reported for missing members in the group. (Not verified)

At the very least you could make two groups “regular” and “Christmas” window lights.

Groups simplify things greatly.

EDIT: While I can certainly see where you are going, and the templates/automations are fun to explore, as a software developer… I encourage you to keep to the simplest most robust system from a practical point of view. Less entities (i.e. one group) in the script would be easier to maintain.

1 Like

If it’s possible to expose a group of lights as a single light to Google assistant this is definitely an approach I’m willing to try.
Will do it tomorrow since I’m already in bed.
Will report back if it works as expected.

Thanks for putting me on a different path that will probably achieve just what I want :smiley:

Your lights are coming from home assistant in the first place right?
You can use a light group in any place you use a light for a service call.

I slept, worked and have now tried the light group as suggested by @mitchins .

Works as expected. Google assistant/home sees all grouped lights as one light when the light group is exposed and no errors from what I can see.
So even if the template light would have been fun to get working I think I just settle with this solution.

Thank you all for your time!

Best regards.