Exported by ChatGPT Exporter at 2023-03-21T19:05:20.202Z
Sure, here's an example HomeAssistant automation that simulates home presence using random lights and switch toggles while you're away:
automation:
- alias: Simulate Home Presence
trigger:
- platform: state
entity_id: device_tracker.your_device_tracker # replace with your device tracker entity id
to: 'not_home'
- platform: time
at: '22:00:00' # replace with your preferred start time for the automation
action:
- repeat:
while:
- condition: state
entity_id: device_tracker.your_device_tracker # replace with your device tracker entity id
state: 'not_home'
sequence:
- service: light.turn_on
data:
entity_id: group.random_lights # replace with your group of random lights
brightness: 50
rgb_color: [255, 255, 255]
- delay: '{{ range(180, 300) | random }}' # random delay between 3 to 5 minutes
- service: light.turn_off
data:
entity_id: group.random_lights # replace with your group of random lights
- delay: '{{ range(60, 120) | random }}' # random delay between 1 to 2 minutes
- service: switch.turn_on
data:
entity_id: group.random_switches # replace with your group of random switches
- delay: '{{ range(180, 300) | random }}' # random delay between 3 to 5 minutes
- service: switch.turn_off
data:
entity_id: group.random_switches # replace with your group of random switches
This automation triggers when your device tracker state changes to "not_home" (indicating that you've left), or at your preferred start time (in this case, 10:00 PM). It then repeats the following sequence of actions as long as your device tracker state remains "not_home":
This automation uses the range and random Jinja2 filters to generate random delays between the actions. You'll need to replace the device_tracker.your_device_tracker, group.random_lights, and group.random_switches entities with the appropriate entity IDs for your HomeAssistant setup.
Sure, here's an updated version of the HomeAssistant automation that only simulates home presence by turning on lights during nighttime hours:
automation:
- alias: Simulate Home Presence
trigger:
- platform: state
entity_id: device_tracker.your_device_tracker # replace with your device tracker entity id
to: 'not_home'
- platform: time
at: '22:00:00' # replace with your preferred start time for the automation
condition:
- condition: sun
after: sunset
before: sunrise
action:
- repeat:
while:
- condition: state
entity_id: device_tracker.your_device_tracker # replace with your device tracker entity id
state: 'not_home'
- condition: sun
after: sunset
before: sunrise
sequence:
- service: light.turn_on
data:
entity_id: group.random_lights # replace with your group of random lights
brightness: 50
rgb_color: [255, 255, 255]
- delay: '{{ range(180, 300) | random }}' # random delay between 3 to 5 minutes
- service: light.turn_off
data:
entity_id: group.random_lights # replace with your group of random lights
- delay: '{{ range(60, 120) | random }}' # random delay between 1 to 2 minutes
- service: switch.turn_on
data:
entity_id: group.random_switches # replace with your group of random switches
- delay: '{{ range(180, 300) | random }}' # random delay between 3 to 5 minutes
- service: switch.turn_off
data:
entity_id: group.random_switches # replace with your group of random switches
The condition section has been added to the automation, which checks if the current time is after sunset and before sunrise (i.e., during nighttime hours) before executing the actions. This prevents the lights from turning on during the day when you're not at home.
Note that you'll need to replace the device_tracker.your_device_tracker, group.random_lights, and group.random_switches entities with the appropriate entity IDs for your HomeAssistant setup.
If you have a connected alarm system that you use to arm your house when nobody is at home, you can use that as a trigger for your HomeAssistant automation instead of relying on the device trackers of individual family members.
Here's an updated version of the HomeAssistant automation that uses the alarm state as a trigger:
automation:
- alias: Simulate Home Presence
trigger:
- platform: state
entity_id: alarm_control_panel.your_alarm_entity_id # replace with your alarm entity ID
to: 'armed_away'
condition:
- condition: sun
after: sunset
before: sunrise
action:
- repeat:
while:
- condition: state
entity_id: alarm_control_panel.your_alarm_entity_id # replace with your alarm entity ID
state: 'armed_away'
- condition: sun
after: sunset
before: sunrise
sequence:
- service: light.turn_on
data:
entity_id: group.random_lights # replace with your group of random lights
brightness: 50
rgb_color: [255, 255, 255]
- delay: '{{ range(180, 300) | random }}' # random delay between 3 to 5 minutes
- service: light.turn_off
data:
entity_id: group.random_lights # replace with your group of random lights
- delay: '{{ range(60, 120) | random }}' # random delay between 1 to 2 minutes
- service: switch.turn_on
data:
entity_id: group.random_switches # replace with your group of random switches
- delay: '{{ range(180, 300) | random }}' # random delay between 3 to 5 minutes
- service: switch.turn_off
data:
entity_id: group.random_switches # replace with your group of random switches
In this automation, the trigger has been changed to the armed_away state of your alarm system. The condition section remains the same to ensure that the actions are only executed during nighttime hours.
If you have specific lights and switches that you want to use for simulating home presence, make sure to replace group.random_lights and group.random_switches with the appropriate entity IDs for your HomeAssistant setup.
This automation assumes that you arm your alarm system when nobody is at home, and disarms it when someone returns. If this is not the case, you may need to modify the automation to use a different trigger that better fits your specific situation.
When simulating home presence, it's best to use a mix of lights from different rooms within the house, rather than just one specific room. This can help create the illusion that people are moving around the house and using different rooms.
Ideally, you should choose lights that are visible from outside the house, such as front-facing windows or balcony lights. If you have smart bulbs or switches installed throughout your home, you can create a group of random lights that includes lights from different rooms.
Here's an example of how you can create a group of random lights:
group:
random_lights:
name: Random Lights
entities:
- light.living_room
- light.bedroom_1
- light.kitchen
- light.dining_room
- light.hallway
- light.bathroom
- light.outdoor_lights
In this example, the group.random_lights entity includes lights from the living room, bedroom 1, kitchen, dining room, hallway, bathroom, and outdoor lights. You can adjust the list of lights to include other rooms as well.
When the automation runs, it will randomly turn on and off the lights in this group, creating the illusion that someone is moving around the house and using different rooms.