Vacation Lighting - Replay Historical Lighting

Hi, trying to add this blueprint but keep getting the below error when pasting the url in or trying to import with my blueprints?
image

Thanks @davearneson ! I’ve added it to the original post

@Eldudemeister this was covered above. in short, HA looks for the first code block to import. this won’t work for this post (and other posts as well) so you’ll need to manually create the blueprint. The other configurations for the replay sensors and recorder would need to be manually coded into your configuration as well.

1 Like

Ah sorry I missed that, makes sense though, will give it a try!

1 Like

Hi @timgiwo ,

Great Idea!
I also tried to play with it once on one specific light but did not move further to generalizing through blueprints.

Thanks for this Blueprint that makes it easier to maintain :slight_smile:

One thing I am thinking of a way to make it even more simple not needing specify which lights to apply to and have to make an automation for each 10 lights.

But this will require the ability to loop/iterate through all light entities. Is that possible at all?

If possible, then no risk on looping through all lights and will only work on those where recording is enabled/configured. But not necessarily all switches may be includes. Therefor we will need to indicate which ones to apply to and can do that adding the entity names to some kind of a list.

If this is possible the only thing users need to do:

  • Enable recording for entities
  • Add selected switches on a list

Then In fact, there will be no need for a blue print but one generic Automation that handles the whole work without hardcoding any entity names.

What do you think?

Any body have experience with looping on a set of entities?

Thanks :slight_smile:

It’s a good idea, but I’m not sure of there’s a straight forward way to interact with the home assistant database directly from an automation without the use of more sensors. Would love to see others implementation of the idea if possible!

Seems possible, look at the following example
Switch everything off except excluded entities - Share your Projects! - Home Assistant Community (home-assistant.io)

It includes most of the needed code. We just need, in stead of always turning off, to set to state from recording.

What do you think?

How can I test this without waiting a week?
Can I see what has been stored for each for each entity?

You can change the statistical sensor specifying another amount of time to go back and match.as in the following example :

##########
# Sensors
##########
sensor:
  # Replay Sensor - Make a new one for each light to monitor
  # All sensors will have naming convention "sensor.replay_xxxxx"
  - platform: history_stats
    name: "replay_office_lamp"
    entity_id: light.office_lamp
    state: "on"
    type: count
    start: >
      {{ as_timestamp(now()) - (7*24*60*60) }}
    duration: 00:00:30

The figures 7*24*60*60 means 60 second x 60 minutes x 24 hours x 7 days

You can change it to be 3 hours like this 3*60*60 or 2 days like this 2*24*60*60 and so on,
Hope this makes sense otherwise let me know and I’ll try to explain further.

I’d like to control more than 10 devices. Twelve is what I have in mind. Is controlling such a number possible simply by adding code to the Blueprint to include;

**Add new sensors and targets**
 replay_sensor_11:
      name: Replay Sensor (11)
      selector:
        entity:
          domain: sensor
    light_target_12:
      name: Light Target (12)
      selector:
        entity:

**Declaring blueprint inputs and variables**
 replay_sensor_11: !input replay_sensor_11
  light_target_11: !input light_target_11
  replay_sensor_12: !input replay_sensor_12
  light_target_12: !input light_target_12

**Adding additional trigger's**
  - platform: state
    entity_id: !input replay_sensor_11
  - platform: state
    entity_id: !input replay_sensor_12

**Adding additional actions**
        {% elif trigger.entity_id == replay_sensor_11 %}
          {{ light_target_11 }}
        {% elif trigger.entity_id == replay_sensor_12 %}
          {{ light_target_12 }}

**Then add two Replay sensors**

Is this the correct approach or is there another way to add two additional device?

Update: problem solved. I added the code and sensors mentioned above, which resulted in exactly what I wanted. The updated blueprint works wonderfully.

2 Likes

I am unable to import this blueprint, and instead get the error message: No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.

2 Likes

Read my posts above. Basically, you need to add it manually.

Thanks, that helped. I had tried adding it manually, but stupidly forgot to name it explicitly as a yaml file.

Why did adding blueprints from the forum stop working? Do they now need to be on GitHub? Quite unhandy to manually add a blueprint using the smartphone… this is not working as intended, right?

The error message I got suggests a problem with this particular page, and how the yaml file is named. I just tried another blueprint, and it imported fine.

Hi everyone,

I made another take that might be easier to configure and maintain.
It is just one automation, no need for blueprints.
Take a look at this:

Let me know if I can help you getting to top work :slight_smile:

Hi Everyone.

This is exactly what I’ve been looking for. I just have a few questions:

  1. do I have to set the entity record time manually to 7 days in my config.yaml?
  2. once I’ve completed the all the steps, should I see an automation called Vacation Mode in on the automation page. currently I can see the code added to automation.yaml, but nothing new is showing up on the automations page.

its a bit difficult to work out if this automation is actually running and working. :expressionless:

regards

Sups

1 Like

Hi Sups-

  1. The description assumes you’re using the recorder component. Any value above 7 is just fine!

  2. The code for the automation is actually a “Blueprint”. It is its own thing so you will add a blue print using the code above then as another step create the automation from the blueprint. That’s when you’ll be prompted to fill in all the variables with the entities described above. After that then the automation will show up under “automations”

If you want to be able to “see” the on/off switch you would add the input boolean to your Lovelace dashboard

Hey Timgiwo

Thanks for a super quick response.

So, with point 2 I did exactly as you described and that’s where I have a problem I think, I created the automation using the blueprint, I see the additional config added to my automation.yaml but no new automations on the ‘automations’ page. Is that expected?

Cheers

Sups

Not expected it should show up in automations. Might need to check home assistant logs

Ahhhh haaaa!

I do have an error in my logs:

'Logger: homeassistant.components.automation
Source: components/automation/init.py:638
Integration: Automation (documentation, issues)
First occurred: 16:33:17 (1 occurrences)
Last logged: 16:33:17

Blueprint Blueprint - Vacation Lighting generated invalid automation with inputs OrderedDict([(‘vacation_mode_toggle’, ‘input_boolean.vacation_mode’), (‘replay_sensor_1’, ‘sensor.replay_loft_light’), (‘light_target_1’, ‘switch.loft_light’), (‘replay_sensor_2’, ‘sensor.replay_1st_floor_light’), (‘light_target_2’, ‘light.1st_floor_light_255’), (‘replay_sensor_3’, ‘sensor.replay_hallway_light’), (‘light_target_3’, ‘light.hallway_light_51’), (‘replay_sensor_4’, ‘sensor.replay_lounge_light’), (‘light_target_4’, ‘light.lounge_lights_264’), (‘replay_sensor_5’, ‘sensor.replay_kitchen_light’), (‘light_target_5’, ‘light.kitchen_lights_308’), (‘replay_sensor_6’, ‘sensor.replay_dining_room_light’), (‘light_target_6’, ‘light.dining_room_lights_380’), (‘replay_sensor_7’, ‘sensor.replay_lounge_lamp’), (‘light_target_7’, ‘switch.lamp’)]): required key not provided @ data[‘entity_id’]. Got None’

Anyone have any idea why this is?