Hi, it is possibile to get „away mode” with simulation of presence?
How should it work?
choose entities, group of devices like bulbs,leds etc. which will be turning on and off
Set how many days/hours- activation time of „away mode”
Start „away mode”
During away mode activity, chosen entities are turning on/off randomly for randomly (not set early) time. Thanks this, we have simulation of being at home. This is different than automation because set automation is repeated - „away mode” is full unpredictable.
I have such automation already implemented in my setup.Works very similar tour description, with few small differences:
I have 2 groups set up; one for family members (group.family in code below that contains all family members that if all absent triggers simulation) and one for lights (group.simulation_lights that contain all lights to participate in simulation) I use to simulate presence
I have script triggered by time pattern platform every 10 minutes (it runs 24 x 7 ) that check conditions: IF time is between sunset - 30 minutes AND before 22:30 AND there is nobody home (determined on family group presence status) it triggers action of toggling (so it switches on/off depending on current status) random light from group WITH random delay from 0 to 30 minutes.
then I have another automation that is triggered at 22:30 with random delay between 15 and 59 minutes that switches all ights in the group off.
Very simple, probably not the cleanes solution but it works perfectly and I do not even need to think if anybody is home or not to trigger simulation. Also self adjusting to season
Here is full code for this automation:
#############################################################################
## Turn on/off indoor lights randomly straing 30 min before sunset till 22:30
#############################################################################
- id: '12'
alias: Random Away Lights
initial_state: True
hide_entity: False
trigger:
- platform: time_pattern
minutes: '/10'
# seconds: '/10'
condition:
- condition: state
entity_id: group.family
state: 'not_home'
# state: 'home'
- condition: sun
after: sunset
after_offset: '-00:30:00'
- condition: time
before: '22:30:00'
# before: '10:45:00'
action:
- delay: "00:{{ '{:02}'.format(range(0, 30) | random | int) }}:00"
#- delay: "00:00:{{ '{:02}'.format(range(0, 10) | random | int) }}"
- service: homeassistant.toggle
data_template:
entity_id: "{{ state_attr('group.simulation_lights','entity_id') | random }}"
################################################################
## Turn off indoor lights randomly between 22:45 ~ 23:30
################################################################
- id: '13'
alias: Turn off all lights
initial_state: True
hide_entity: False
trigger:
- platform: time
at: '22:30:00'
# at: '10:46:00'
condition:
- condition: state
entity_id: group.family
state: 'not_home'
# state: 'home'
action:
- delay: '00:{{ range(15,59) | random | int }}:00'
- service: homeassistant.turn_off
entity_id: group.simulation_lights
Configurable presets and evaluation of alarm, wind, home presence. Every preset can be different and can make random covers/lights, total open-close/turn on-off or ignore. Every preset can have different rules for some evaluation. Anyway for help some users cover and lights have an override toggle that ignore the configuration. Another toggle enable simulation repetition.
All are triggered by sun or time, day, evening and night.
At start of these, it run a simulation, if repetition enabled it repeats it based on a fixed time, medium for day, short for evening, long for night
When triggered it generate a random time before start simulation, if covers/lights are configured as random it generate a random time from items (cover 1 -> random time -> cover 2…). Same for light. Based on day/evening/night it have random values for covers, like day from 80 to 90% and night from 5 to 15% for example… and items trigger are based on a random status. For example it maybe open cover 1 but not cover 2, turn on light 1 2 but not 3 and 4 5 6 but not 7. Random whereever is possible.
All information are saved in a last execution sensor, waiting times too.
There is a main toggle for completly disable simulation. Evert preset have configurable icon and there are 10 available configuration for presets, so can exists 2 presets with same configuraion number. Presets and config. are hardcoded.
When disabled from evaluation or toggle all executuion stop.
For now, only italian. I hope is clear how it works.
i think a perfect presence simulation should capture the movement (lights on/off) from the last couple of days and clone it (or with an automatic-mode)
I worked lot on it in last months, but it is very embedded with my configuration.
You have to edit lot of code to make it works on your configuration. Change presence, alarm, rain, wind sensors… covers, lights items… notifications… If you have not one of these, disable the evaluation toggle or the cover\lights toggle to bypass. I added my time control package.
And change it to your language, for now… only Italian.
I tested it and seems works fine, tell me if you have “bugs”.
Thanks a lot! I’m going to see it in detail and adapt it to my configuration. The important thing is to have the basic idea and distribution of the solution, then it is to adapt it little by little depending on the devices, sensors and others.
I’ve been around a lot and didn’t know how to configure it correctly. I take a look at it and I’ll tell you how I’m doing, that now on vacation I have more time
Creating this automation made me crazy because I had to consider many variants and multiple configurations, evaluation of multiple sensors (blocking all if there is strong wind \ rain to prevent the shutters from opening), managing the presence and the alarm and doing so that it auto starts or stops when needed with scenarios for work, vacation… I made everything configurable with sensors but the hardest part was creating sensors that tell you what is happening and what will happen to test their operation and verify that it was doing what you wanted.
I’ve downloaded the lastest version of the component today and I’ve had the same problem.
But I was able to add the integration after I have changed the value for the delta to 5 (or something different).
After that the integration was successfully added and I was able to the change that back to 7 in the settings.
Maybe you can’t add the integration when the delta is the same as the purge interval from the recorder.
I’m new to HA (coming from Homeseer where I have something similar to your code implemented) and would like to implement something very similar, so having something as a reference would be appreciated