Vacation Lighting - Replay Historical Lighting

Correct. This is what I would do. It only requires a few lines of code for the automations.

I am having trouble importing this blue print.

I am getting the following error.

No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.

You can import blueprints of other users from Github and the community forums. Enter the URL of the blueprint below.

Any ideas I love the idea of this and really want to try it.

See post from @timgiwo above. You need to install it manually.
BTW; Here is the code with the changes suggested by @finity

blueprint:
  name: Blueprint - Vacation Lighting 
  description: Vacation Lighting - Replay Sensors to Light Behavior
  domain: automation
  input:
    vacation_mode_toggle:
      name: Vacation Mode - Input Boolean
      selector:
        entity:
          domain: input_boolean
    default_brightness:
      name: Default Brightness
      default: 50
      selector:
        number:
          min: 1
          max: 100
          unit_of_measurement: "%"
          mode: slider
    replay_sensor_1:
      name: Replay Sensor (1)
      selector:
        entity:
          domain: sensor
    light_target_1:
      name: Light Target (1)
      selector:
        entity:
    replay_sensor_2:
      name: Replay Sensor (2)
      selector:
        entity:
          domain: sensor
    light_target_2:
      name: Light Target (2)
      selector:
        entity:
    replay_sensor_3:
      name: Replay Sensor (3)
      selector:
        entity:
          domain: sensor
    light_target_3:
      name: Light Target (3)
      selector:
        entity:
    replay_sensor_4:
      name: Replay Sensor (4)
      selector:
        entity:
          domain: sensor
    light_target_4:
      name: Light Target (4)
      selector:
        entity:
    replay_sensor_5:
      name: Replay Sensor (5)
      selector:
        entity:
          domain: sensor
    light_target_5:
      name: Light Target (5)
      selector:
        entity:
    replay_sensor_6:
      name: Replay Sensor (6)
      selector:
        entity:
          domain: sensor
    light_target_6:
      name: Light Target (6)
      selector:
        entity:
    replay_sensor_7:
      name: Replay Sensor (7)
      selector:
        entity:
          domain: sensor
    light_target_7:
      name: Light Target (7)
      selector:
        entity:
    replay_sensor_8:
      name: Replay Sensor (8)
      selector:
        entity:
          domain: sensor
    light_target_8:
      name: Light Target (8)
      selector:
        entity:
    replay_sensor_9:
      name: Replay Sensor (9)
      selector:
        entity:
          domain: sensor
    light_target_9:
      name: Light Target (9)
      selector:
        entity:
    replay_sensor_10:
      name: Replay Sensor (10)
      selector:
        entity:
          domain: sensor
    light_target_10:
      name: Light Target (10)
      selector:
        entity:
# Declare blueprint inputs as variables for use in {{templates}}        
variables:
  replay_sensor_1: !input replay_sensor_1
  light_target_1: !input light_target_1
  replay_sensor_2: !input replay_sensor_2
  light_target_2: !input light_target_2
  replay_sensor_3: !input replay_sensor_3
  light_target_3: !input light_target_3
  replay_sensor_4: !input replay_sensor_4
  light_target_4: !input light_target_4
  replay_sensor_5: !input replay_sensor_5
  light_target_5: !input light_target_5
  replay_sensor_6: !input replay_sensor_6
  light_target_6: !input light_target_6
  replay_sensor_7: !input replay_sensor_7
  light_target_7: !input light_target_7
  replay_sensor_8: !input replay_sensor_8
  light_target_8: !input light_target_8
  replay_sensor_9: !input replay_sensor_9
  light_target_9: !input light_target_9
  replay_sensor_10: !input replay_sensor_10
  light_target_10: !input light_target_10
  
# Trigger when replay sensor changes state
trigger:
  - platform: state
    entity_id: !input replay_sensor_1
  - platform: state
    entity_id: !input replay_sensor_2
  - platform: state
    entity_id: !input replay_sensor_3
  - platform: state
    entity_id: !input replay_sensor_4
  - platform: state
    entity_id: !input replay_sensor_5
  - platform: state
    entity_id: !input replay_sensor_6
  - platform: state
    entity_id: !input replay_sensor_7
  - platform: state
    entity_id: !input replay_sensor_8
  - platform: state
    entity_id: !input replay_sensor_9
  - platform: state
    entity_id: !input replay_sensor_10

# As long as Vacation Mode is on
condition:
  - condition: state
    entity_id: !input vacation_mode_toggle
    state: 'on'


action:
  - variables:
      corresponding_light: >
        {% if trigger.entity_id == replay_sensor_1 %}
          {{ light_target_1 }}
        {% elif trigger.entity_id == replay_sensor_2 %}
          {{ light_target_2 }}
        {% elif trigger.entity_id == replay_sensor_3 %}
          {{ light_target_3 }}
        {% elif trigger.entity_id == replay_sensor_4 %}
          {{ light_target_4 }}
        {% elif trigger.entity_id == replay_sensor_5 %}
          {{ light_target_5 }}
        {% elif trigger.entity_id == replay_sensor_6 %}
          {{ light_target_6 }}
        {% elif trigger.entity_id == replay_sensor_7 %}
          {{ light_target_7 }}
        {% elif trigger.entity_id == replay_sensor_8 %}
          {{ light_target_8 }}
        {% elif trigger.entity_id == replay_sensor_9 %}
          {{ light_target_9 }}
        {% elif trigger.entity_id == replay_sensor_10 %}
          {{ light_target_10 }}
        {% endif %}
  - choose:
      # Replay turned on && entity_id is "LIGHT"
      - conditions:
          condition: and
          conditions: 
            - condition: template
              value_template: '{{ trigger.to_state.state | int >= 1 }}'
            - condition: template
              value_template: '{{ corresponding_light.split(".")[0] == "light" }}'
        sequence:
          - service: light.turn_on
            data:
              entity_id: '{{ corresponding_light }}'
              brightness_pct: !input default_brightness
          - service: system_log.write
            data:
              message: 'Vacation - Replay Lighting (Blueprint): {{trigger.to_state.entity_id}}: turning on: {{ corresponding_light }}'
              level: info

      # Replay turned on && entity_id is "SWITCH"
      - conditions:
          condition: and
          conditions: 
            - condition: template
              value_template: '{{ trigger.to_state.state | int >= 1 }}'
            - condition: template
              value_template: '{{ corresponding_light.split(".")[0] == "switch" }}'
        sequence:
          - service: switch.turn_on
            data:
              entity_id: '{{ corresponding_light }}'
          - service: system_log.write
            data:
              message: 'Vacation - Replay Lighting (Blueprint): {{trigger.to_state.entity_id}}: turning on:{{ corresponding_light }}'
              level: info

      # Replay turned off
      - conditions:
          condition: and
          conditions: 
            - condition: template
              value_template: '{{ trigger.to_state.state == "0" }}'
        sequence:
          - service: homeassistant.turn_off
            data:
              entity_id: '{{ corresponding_light }}'
          - service: system_log.write
            data:
              message: 'Vacation - Replay Lighting (Blueprint): {{trigger.to_state.entity_id}}: turning off:{{ corresponding_light }}'
              level: info

How do you install it manually? Sorry I’m a newbie…

Have you tried the docs?

Indeed. It all talks about using a URL for installation, not a manual process. I see how there are files in the blueprints directory. Do I copy an existing one and modify it with the file editor? This is an automation type not a script?

Use a text editor and copy the code above into it. Then store the file under the name vacation_lighting.yaml into config/blueprints/automation/homeassistant. Then restart home assistant. “config” is the home assistant configuration directory where all your other config files are stored.

Thank you for the help! I now know how to do manually add blueprints!

So I have the blueprint installed and trying to make an automation with it. Everytime I and save a setup, I get an error, and none of the input is saved. A few questions:

  1. the sensor devices are not existing entities right, that is I have to create them in the automation using the blueprint?

  2. For the sensors, are there any limitations on how the sensors should be named? Would this cause the config not to be saved?

  3. For the entities being controlled, it’s their prior history that is being used right? So the same device that provides the history is the one being used for control?

Sorry for the newbie questions - I’m on my first month of HA use!

  1. Correct. They’re the replay sensors you need to create
  2. No limitations for naming. Just a suggestion on naming convention.
  3. Correct.

There is one caveat that I found. is that if HA requires to fill in all the input fields. I wrote this blueprint to arbitrarily support 10 lights, which means you need to have all 20 (10 x 2) sensor and target inputs filled in when you make your selections deploying the blueprint. If you don’t fill in all the fields, I htink HA gave me an error or just didn’t save at all. Check if that’s the same thing you’re experiencing…

There’s some comments above in the “Notes” section for how to address this.

Thanks for the reply. For some reason I think I am doing the right things, but it isn’t saving.

Here are my settings:

And here is the yaml version:

alias: Vacation Lighting set 1
description: vacation set 1
use_blueprint:
  path: homeassistant/vacation_lighting.yaml
  input:
    vacation_mode_toggle: input_boolean.vacation_mode
    default_brightness: 70
    replay_sensor_1: replaymudroom
    light_target_1: light.mud_room_mudroom_downs
    replay_sensor_2: replaykitchen
    light_target_2: light.kitchen_kitchen_downs
    replay_sensor_3: replaymasterbath
    light_target_3: light.master_bathroom_master_bath_downs
    replay_sensor_4: replaynook
    light_target_4: light.nook_nook_downs
    replay_sensor_5: replayabby
    light_target_5: light.abby_s_room_abby_s_bed_downs
    replay_sensor_6: replayhallway
    light_target_6: light.hallway_hallway_downs
    replay_sensor_7: replayfamilyroom
    light_target_7: light.family_room_family_room_middle_downs
    replay_sensor_8: replaymasterbed
    light_target_8: light.master_bedroom_master_bed_downs_a
    replay_sensor_9: replaymolly
    light_target_9: light.molly_s_room_molly_s_room_downs
    replay_sensor_10: replaymudstairs
    light_target_10: light.mud_stairwell_mudroom_stairwell_high_downs

One strange thing. When I hit save, the automation doesn’t show up in the Automations screen. But all the automations report they turned on in the logbook. I think this happens anytime I add an automation, but wanted to call it out if there was something unusual about it.

Nothing in the notifications shows an error either.

Any ideas?

Strange, it doesn’t seem like this particular issue may be related to the blueprint. Wish I knew, if I were to try anything I’d probably try clearing browser cache first… may be it is creating the automation (which you can validate in the automations.yaml file) but just not appearing on frontend.

It’s definitely not creating an automation. I check on my android app and it definitely doesn’t show up there.

I am running core-2021.6.3. Could that be part of the issue? It shows up as a blueprint, so I think I had installed it properly.

BTW, can the blueprint handle covers as well? None of those are in this list, but I have a bunch of shades that it would also be good to update along with lighting.

Those replay sensors don’t look right. They should start with sensor.
Haveyou created these in your configuration.yaml, as in the first post? The blueprint won’t create them for you. If you have, then you need, for example sensor. replayroom not just replayroom.

2 Likes

That did it! Sorry if that was something obvious. I thought the blueprint would create them when I just named them in the automation. Missed that they needed to be created manually!

Thanks everyone! Will go play with this some more now!

PS BTW, in the code segment in the first post that talks about sensors, the heading is “sensors:”, not “sensor:” Sensors: doesn’t work. :slight_smile:

1 Like

Just set this up. Thanks. Great idea! I made template switches for the TVs so I could do a similar thing with them in a separate automation.

Here’s that blueprint if anyone is interested: (set up for three TVs)

blueprint:
  name: Blueprint - Vacation TV
  description: Vacation TV - Replay Sensors to TV
  domain: automation
  input:
    vacation_mode_toggle:
      name: Vacation Mode - Input Boolean
      selector:
        entity:
          domain: input_boolean
    replay_sensor_1:
      name: Replay Sensor (1)
      selector:
        entity:
          domain: sensor
    tv_target_1:
      name: TV Target (1)
      selector:
        entity:
    replay_sensor_2:
      name: Replay Sensor (2)
      selector:
        entity:
          domain: sensor
    tv_target_2:
      name: TV Target (2)
      selector:
        entity:
    replay_sensor_3:
      name: Replay Sensor (3)
      selector:
        entity:
          domain: sensor
    tv_target_3:
      name: TV Target (3)
      selector:
        entity:

# Declare blueprint inputs as variables for use in {{templates}}        
variables:
  replay_sensor_1: !input replay_sensor_1
  tv_target_1: !input tv_target_1
  replay_sensor_2: !input replay_sensor_2
  tv_target_2: !input tv_target_2
  replay_sensor_3: !input replay_sensor_3
  tv_target_3: !input tv_target_3

############ ADDED AN AUTOMATION MODE HERE #############
mode: parallel
  
# Trigger when replay sensor changes state
trigger:
  - platform: state
    entity_id: !input replay_sensor_1
  - platform: state
    entity_id: !input replay_sensor_2
  - platform: state
    entity_id: !input replay_sensor_3

# As long as Vacation Mode is on
condition:
  - condition: state
    entity_id: !input vacation_mode_toggle
    state: 'on'

action:
  - variables:
      corresponding_tv: >
        {% if trigger.entity_id == replay_sensor_1 %}
          {{ tv_target_1 }}
        {% elif trigger.entity_id == replay_sensor_2 %}
          {{ tv_target_2 }}
        {% elif trigger.entity_id == replay_sensor_3 %}
          {{ tv_target_3 }}
        {% endif %}
  - choose:

      # Replay turned on && entity_id is "SWITCH"
      - conditions:
          condition: and
          conditions: 
            - condition: template
              value_template: '{{ trigger.to_state.state | int >= 1 }}'
            - condition: template
              value_template: '{{ corresponding_tv.split(".")[0] == "switch" }}'
        sequence:
          - service: switch.turn_on
            data:
              entity_id: '{{ corresponding_tv }}'
          - service: system_log.write
            data:
              message: 'Vacation - Replay TV (Blueprint): {{trigger.to_state.entity_id}}: turning on:{{ corresponding_tv }}'
              level: info

      # Replay turned off
      - conditions:
          condition: and
          conditions: 
            - condition: template
              value_template: '{{ trigger.to_state.state == "0" }}'
        sequence:
          - service: homeassistant.turn_off
            data:
              entity_id: '{{ corresponding_tv }}'
          - service: system_log.write
            data:
              message: 'Vacation - Replay TV (Blueprint): {{trigger.to_state.entity_id}}: turning off:{{ corresponding_tv }}'
              level: info

I set my template TV switches to tune to a OTA channel on power, so they don’t use any streaming. I wanted it in a separate blueprint so I could control lights/tv separately. (Or disable it entirely if I decide I don’t like it).

1 Like

I am trying to implement this blueprint, the thing is I did it for my apartment and it works and now I am trying to do it for my office but the value of all the replay sensors is ‘unknown’ instead of ‘0’ and ‘1’.

The only thing that is different is that at home I have entities that are switches and in the office entities that are lights. But that shouldn’t make any difference. Also I have recorder integration for both places.

 - platform: history_stats
    name: "replay_garden_fence_lights"
    entity_id: light.garden_pool_fence_179
    state: "on"
    type: count
    start: >
      {{ as_timestamp(now()) - (7*86400) }}
    duration: 00:00:30


How long ago did you turn recorder on for the lights at the office? Maybe this is just an error because there is no data recorded from a week ago for the “light.garden_pool_fence_179” entity?

Check and see what your “light.garden_pool_fence_179” entity says for one week ago in the history tab.

If it doesn’t have anything from a week ago, and you turned recorder on yesterday, just to test it out, you could try:

 - platform: history_stats
    name: "replay_garden_fence_lights"
    entity_id: light.garden_pool_fence_179
    state: "on"
    type: count
    start: >
      {{ as_timestamp(now()) - (1*86400) }}
    duration: 00:00:30

(All I did was change the look back time frame to 1 day instead of 7, but left the redundant “1*86400” in so you can adjust it back if you want.)

I thought about it, but I was not sure as to why it might cause the error, I set the recorder 6 days before trying the sensor, when I changed to 1 day for one of the sensors it worked, thank you very much for the help. I switched it back to 7, and hope that from tomorrow it will work for all the sensors, thank you again for the help.