Vacation mode triggered by alarm

Hi am a newbie in this and would like some help to start off. Been reading but not sure how to start. After a few I will get the hang of things. :slight_smile:

I have a DSC alarm with envisialink4 .
Last night I managed to connect home assistant to my different zones. (baby steps but got it to work)
I see the disarm /arm , My house keypad and all my zones I configured in the overview page in top row.

What I would like to do is set up a vacation mode when not at home so lights go on and off at a certain time. This can be triggered by armed and disarmed mode of my alarm if it is possible.
If someone could guide me in my configuration this is what I would like it to do.

When system is armed in away mode not home mode between sunset and midnight, I would like for my 7 different lights to go on and off in a random mode as to create a feel of presence in the home.
I would like to also have 1 and/or 2 lights at the same time.

I have seen some scripts with vacation mode here but would need help to integrate it with my alarm system if possible.

Can anyone help

Thanks

I will be trying this that I found.
Hopefully I will make it work

Ok playing around and have some issues.
I set up a group and it works
Now using vacation mode based on script I found here for alarm and I am getting this error when I do a configuration validation after adding the Random lights on while sunset and armed away script

Error loading /config/configuration.yaml: while parsing a block mapping in “/config/configuration.yaml”, line 1, column 1 expected <block end>, but found ‘-’ in “/config/configuration.yaml”, line 150, column 1
I indicated which one is line 150

Here is my configuration file with sensitive information replaced by 0’s

Also some questions in bold

Thanks

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: 0
  longitude: 0
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 0
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: UTC
  # Customization file
  customize: !include customize.yaml

# Show links to resources in log and frontend
introduction:

# Enables the frontend
frontend:

# Enables configuration UI
config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
  # Optional, allows Home Assistant developers to focus on popular components.
  # include_used_components: true

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

# Sensors
sensor:
  # Weather prediction
  - platform: yr

# Text to speech
tts:
  - platform: google

# Cloud
cloud:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml



tuya:
  username: "0000"
  password: "0000"
  country_code: "1"
  
august:
  login_method: email  
  username: "0000"
  password: "0000"


envisalink:
  host: 192.168.2.000
  panel_type: "DSC"
  user_name: "0000"
  password: "0000"
  code: "0000"
  port: 4025
  evl_version: 4
  keepalive_interval: 60
  zonedump_interval: 30
  timeout: 10
  panic_type: Police
  zones:
    1:
      name: 'Front Door'
      type: 'door'
    2:
      name: 'Patio kitchen'
      type: 'door'
    3:
      name: 'Patio Family'
      type: 'door'
    4:
      name: 'Motion Rooms'
      type: 'motion'
    5:
      name: 'Motion Family'
      type: 'motion'
    6:
      name: 'Motion Garage'
      type: 'motion'
    7:
      name: 'Motion Basement'
      type: 'motion'
    13:
      name: 'Door Laundry'
      type: 'door'
    14:
      name: 'Door Garage'
      type: 'garage_door'
    16:
      name: 'Smoke Detector'
      type: 'smoke'
  partitions:
    1:
      name: 'My house'
      
      
      
      
light:
  - platform: group
    name: Away lights
    entities:
      - light.53411381807d3a59486b #bedroom
      - light.53411381807d3a59491c #family room
      - light.53411381807d3a596f8c #fireplace lights 
      - light.53411381807d3a597774 #kitchen ceiling
      - light.53411381807d3a5972d7 #kitchen Island
      - light.53411381807d3a597131 #living room ceiling lights


################################################################
## Random lights on while sunset and armed away
################################################################
- alias: Random Away Lights **this is line 150**
  initial_state: True
  hide_entity: False

  trigger:
    - platform: time
      minutes: '/30' **What is the 30 for? isn't it triggerd by sunset below? or is this the random of every 30 minutes switch light?**
      seconds: 00

  condition:
    - condition: state
      entity_id: alarm_control_panel.ha_alarm
      state: 'armed_away'

    - condition: sun
      after: sunset
  
  action:
    - delay: "00:{{ '{:02}'.format(range(5, 11) | random | int) }}:00"

    - condition: state
      entity_id: alarm_control_panel.ha_alarm
      state: 'armed_away'

    - service: homeassistant.toggle
      data_template:
        entity_id: "{{ state_attr('group.away_lights','entity_id') | random }}"
 
##########################################################
## Sunrise Random Lights Off
##########################################################
- alias: Random Lights Off Sunrise
  initial_state: True
  hide_entity: False

  trigger:
    - platform: sun
      event: sunrise **How do I change this to end at midnight instead of sunrise?**
  
  condition:
    - condition: state
      entity_id: alarm_control_panel.ha_alarm
      state: 'armed_away'

  action:
    - service: homeassistant.turn_off
      entity_id: group.away_lights

##########################################################
## Alarm Disarmed Random lights Off
##########################################################
- alias: Random Lights Off Disarmed
  initial_state: True
  hide_entity: False

  trigger:
    - platform: state
      entity_id: alarm_control_panel.ha_alarm
      from: 'armed_away'
      to: 'disarmed'

  action:
    - service: homeassistant.turn_off
      entity_id: group.away_lights

there is no way anyone can help you with the way your code is formatted in the post.

you need to format it all properly.

here you go I edited the previous post hope this is better

1 Like

You have 1 automation section that specifically calls out creating automations in a separate automations.yaml file.

Then you proceed to try to add automations at line 150 outside the any section when they should be in an automation section. I.E. automations.yaml. (which you call out in line 69: automation: !include automations.yaml).

You need to do 1 of the following:

  1. Move your automations into your automation.yaml files.
  2. Create a second automation section at line 148 named automation 2: Although you may run into issues with this method.

Thanks for the reply but I am a total noob not sure how to this. Don’t know what to transfer exactly to the automation file?
Can you give me example so I can just copy paste :slight_smile:
Is there a way I can just leave all in the configuration file and correct errors from there?

I mean, you just need to copy and paste the automations you have written into your automation.yaml file. There isn’t any example to give…

ok I put this in the automation file and left configuration file as is and still giving me same error

> automations:
> - alias: Random Away Lights **this is line 150**
>   initial_state: True
>   hide_entity: False
> 
>   trigger:
>     - platform: time
>       minutes: '/30'
>       seconds: 00
> 
>   condition:
>     - condition: state
>       entity_id: alarm_control_panel.ha_alarm
>       state: 'armed_away'
> 
>     - condition: sun
>       after: sunset
>   
>   action:
>     - delay: "00:{{ '{:02}'.format(range(5, 11) | random | int) }}:00"
> 
>     - condition: state
>       entity_id: alarm_control_panel.ha_alarm
>       state: 'armed_away'
> 
>     - service: homeassistant.toggle
>       data_template:
>         entity_id: "{{ state_attr('group.away_lights','entity_id') | random }}"
>  
> 
> - alias: Random Lights Off Sunrise
>   initial_state: True
>   hide_entity: False
> 
>   trigger:
>     - platform: sun
>       event: sunrise
>   
>   condition:
>     - condition: state
>       entity_id: alarm_control_panel.ha_alarm
>       state: 'armed_away'
> 
>   action:
>     - service: homeassistant.turn_off
>       entity_id: group.away_lights
> 
> 
> - alias: Random Lights Off Disarmed
>   initial_state: True
>   hide_entity: False
> 
>   trigger:
>     - platform: state
>       entity_id: alarm_control_panel.ha_alarm
>       from: 'armed_away'
>       to: 'disarmed'
> 
>   action:
>     - service: homeassistant.turn_off
>       entity_id: group.away_lights

remove the automations: line. That’s already declared in configuration.yaml.

still same error

did you remove what you copied in the other area? Not for nothing but you are giving little to no information here.

Show the error and the full configuration. Some of this is going to have to be understood by you. If the error contains a line # and a position number, look at that line and position. That’s where your error is

I have taken out of configuration file and pasted only in automations.
Now no more error let’s hope it works.
Thanks for your help and patience so far. I am learning as I go :slight_smile:

BTW
Sorry my full configuration is in my first post. and the error was stated there. Here it is again.

Error loading /config/configuration.yaml: while parsing a block mapping in “/config/configuration.yaml”, line 1, column 1 expected <block end>, but found ‘-’ in “/config/configuration.yaml”, line 150, column 1
I indicated which one is line 150

Update ok see it my automations section in the overview file. will have to see if works now as I arm disarm and other conditions are met.
Thanks again

need help can’t figure it out. Not working

I have the automation listed above in my automation yaml
I have in groups my All lights group
I have in configuration my alarm system which the configuration file is listed above

In home assistant overview I see tile with all lights listed and all other lights below
I have an automation tile which has listed
Random away lights
Random lights off disarmed
Random lights off sunrise
All above 3 have the blue switch to on

But my issue is if I arm system after sunset the lights are not going on.
If I manually turn on light in the away group and disarm the system or wait till sunlight the lights don’t turn off.

If I manually trigger the Random All lights nothing happens

If I manually turn on light and disarm system and manually trigger the Random lights off disarmed or the Random lights off sunrise then the lights will turn off.

Why is this not working when conditions are met ? What am I doing wrong?

If it helps here are my different yaml files

In automation I have

################################################################
## Random lights on while sunset and armed away
################################################################
- alias: Random Away Lights
  initial_state: True
  hide_entity: False

  trigger:
    - platform: time
      minutes: '/30' 
      seconds: 00

  condition:
    - condition: state
      entity_id: alarm_control_panel.ha_alarm
      state: 'armed_away'

    - condition: sun
      after: sunset
  
  action:
    - delay: "00:{{ '{:02}'.format(range(5, 11) | random | int) }}:00"

    - condition: state
      entity_id: alarm_control_panel.ha_alarm
      state: 'armed_away'

    - service: homeassistant.toggle
      data_template:
        entity_id: "{{ state_attr('group.all_lights','entity_id') | random }}"
 
##########################################################
## Sunrise Random Lights Off
##########################################################
- alias: Random Lights Off Sunrise
  initial_state: True
  hide_entity: False

  trigger:
    - platform: sun
      event: sunrise 
  condition:
    - condition: state
      entity_id: alarm_control_panel.ha_alarm
      state: 'armed_away'

  action:
    - service: homeassistant.turn_off
      entity_id: group.all_lights

##########################################################
## Alarm Disarmed Random lights Off
##########################################################
- alias: Random Lights Off Disarmed
  initial_state: True
  hide_entity: False

  trigger:
    - platform: state
      entity_id: alarm_control_panel.ha_alarm
      from: 'armed_away'
      to: 'disarmed'

  action:
    - service: homeassistant.turn_off
      entity_id: group.all_lights

In groups I have

light:
    name: All lights
    entities:
      - light.53411381807d3a59486b #bedroom
      - light.53411381807d3a59491c #family room
      - light.53411381807d3a596f8c #fireplace lights 
      - light.53411381807d3a597774 #kitchen ceiling
      - light.53411381807d3a5972d7 #kitchen Island
      - light.53411381807d3a597131 #living room ceiling lights

In configuration I have

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: 0
  longitude: 0
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 0
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: UTC
  # Customization file
  customize: !include customize.yaml

# Show links to resources in log and frontend
introduction:

# Enables the frontend
frontend:

# Enables configuration UI
config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
  # Optional, allows Home Assistant developers to focus on popular components.
  # include_used_components: true

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

# Sensors
sensor:
  # Weather prediction
  - platform: yr

# Text to speech
tts:
  - platform: google

# Cloud
cloud:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml



tuya:
  username: "0000"
  password: "0000"
  country_code: "1"
  


envisalink:
  host: 192.168.2.???
  panel_type: "DSC"
  user_name: "????"
  password: "????"
  code: "0000"
  port: 4025
  evl_version: 4
  keepalive_interval: 60
  zonedump_interval: 30
  timeout: 10
  panic_type: Police
  zones:
    1:
      name: 'Front Door'
      type: 'door'
    2:
      name: 'Patio kitchen'
      type: 'door'
    3:
      name: 'Patio Family'
      type: 'door'
    4:
      name: 'Motion Rooms'
      type: 'motion'
    5:
      name: 'Motion Family'
      type: 'motion'
    6:
      name: 'Motion Garage'
      type: 'motion'
    7:
      name: 'Motion Basement'
      type: 'motion'
    13:
      name: 'Door Laundry'
      type: 'door'
    14:
      name: 'Door Garage'
      type: 'garage_door'
    16:
      name: 'Smoke Detector'
      type: 'smoke'
  partitions:
    1:
      name: 'My house'

It’s not going to trigger immediately, you have a 5- 11 minute delay coupled with a 30 minute period. So that means, if you go armed_away, you could be waiting anywhere between 5 minutes and 41 minutes for the lights to turn on (or off).

Thanks for the answer but I was gone all weekend and even after hours nothing was on in the house

Also as mentionned even if I turn on the light manually and disarm the system or wait till after sunrise with system armed. Light stays on

Well I notice a few things.

  1. group.all_lights is a premade group that you don’t have to specify. It’s done by home assistant.
  2. The group you are creating is called group.lights, not group.all lights.
  3. (Noticed in previous post, current looks ok). Are you putting the ** comments in? Switch those to a single #. Comments in yaml are # this is a comment. *'s are not a comment and will be used in yaml.
  4. All of your automations look correct. Even with the items I am pointing out above they should all work. So what does that mean? Well the good news is that all of your automations have 1 common condition. All of them are looking at the state of your alarm panel. None of them are firing, so first thing I would do is verify that the armed_away state is actually correct.

So, what I would do to test this instead of waiting 90000 hours between triggers is the following:

Make a new automation that fires minutely and does not have a delay. Do not use a condition at first. Once that works, add a ‘armed_away’ condition. See if it still works. Then continuously add all your conditions until it’s working.