feat: improve presence simulation with staggered lighting and realistic behavior

- Replace simultaneous light activation with sequential (staggered) control
- Add per-light random delays for more natural behavior
- Implement reverse-order light shutdown for realism
- Introduce time-based variations (morning, midday, evening)
- Add randomized music playback using Spotify playlist on Sonos
- Refactor automation using repeat loops and variables for maintainability
This commit is contained in:
2026-03-26 15:47:26 +01:00
parent 0b4fc7f2f4
commit 14824b0ab7
+80 -62
View File
@@ -1,4 +1,4 @@
alias: Presence Simulation - Tidsblokke (robust) alias: Presence Simulation - Tidsblokke (realistisk)
mode: restart mode: restart
trigger: trigger:
@@ -16,40 +16,57 @@ condition:
action: action:
- variables: - variables:
rand_delay: "{{ range(300,1200) | random }}" # 5-20 min lights_morning:
- light.livingroom
- light.indkoersel_2
- light.andreas_vaerelse
- light.bedroom
- light.daniels_vaerelse
- light.forgang
lights_midday:
- light.kokken
- light.indkoersel
lights_evening:
- light.livingroom
- light.indkoersel_2
- light.andreas_vaerelse
- light.bedroom
- light.daniels_vaerelse
- light.forgang
rand_music: "{{ range(0,100) | random }}" rand_music: "{{ range(0,100) | random }}"
- choose: - choose:
# 🌅 Morgen # 🌅 MORGEN
- conditions: - conditions:
- condition: time - condition: time
after: "06:59:00" after: "06:59:00"
before: "12:00:00" before: "12:00:00"
sequence: sequence:
- service: light.turn_on - repeat:
target: for_each: "{{ lights_morning }}"
entity_id: sequence:
- light.livingroom - service: light.turn_on
- light.indkoersel_2 target:
- light.andreas_vaerelse entity_id: "{{ repeat.item }}"
- light.bedroom - delay:
- light.daniels_vaerelse seconds: "{{ range(30,180) | random }}"
- light.forgang
- delay: - delay:
seconds: "{{ rand_delay }}" minutes: "{{ range(10,30) | random }}"
- service: light.turn_off - repeat:
target: for_each: "{{ lights_morning | reverse }}"
entity_id: sequence:
- light.livingroom - service: light.turn_off
- light.indkoersel_2 target:
- light.andreas_vaerelse entity_id: "{{ repeat.item }}"
- light.bedroom - delay:
- light.daniels_vaerelse seconds: "{{ range(20,120) | random }}"
- light.forgang
- choose: - choose:
- conditions: - conditions:
@@ -64,37 +81,40 @@ action:
media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj" media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj"
- delay: - delay:
seconds: "{{ range(300,900) | random }}" minutes: "{{ range(5,15) | random }}"
- service: media_player.media_stop - service: media_player.media_stop
target: target:
entity_id: media_player.kokken entity_id: media_player.kokken
# 🌤️ Middag
# 🌤️ MIDDAG
- conditions: - conditions:
- condition: time - condition: time
after: "11:59:00" after: "11:59:00"
before: "18:00:00" before: "18:00:00"
sequence: sequence:
- service: light.turn_on - repeat:
target: for_each: "{{ lights_midday }}"
entity_id: sequence:
- light.kokken - service: light.turn_on
- light.indkoersel target:
entity_id: "{{ repeat.item }}"
- delay:
seconds: "{{ range(60,300) | random }}"
- delay: - delay:
seconds: "{{ rand_delay }}" minutes: "{{ range(5,20) | random }}"
- service: light.turn_off - repeat:
target: for_each: "{{ lights_midday | reverse }}"
entity_id: sequence:
- light.livingroom - service: light.turn_off
- light.indkoersel_2 target:
- light.andreas_vaerelse entity_id: "{{ repeat.item }}"
- light.bedroom - delay:
- light.daniels_vaerelse seconds: "{{ range(30,180) | random }}"
- light.forgang
- choose: - choose:
- conditions: - conditions:
@@ -109,42 +129,40 @@ action:
media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj" media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj"
- delay: - delay:
seconds: "{{ range(300,900) | random }}" minutes: "{{ range(5,15) | random }}"
- service: media_player.media_stop - service: media_player.media_stop
target: target:
entity_id: media_player.kokken entity_id: media_player.kokken
# 🌙 Aften
# 🌙 AFTEN
- conditions: - conditions:
- condition: time - condition: time
after: "17:59:00" after: "17:59:00"
before: "22:30:00" before: "22:30:00"
sequence: sequence:
- service: light.turn_on - repeat:
target: for_each: "{{ lights_evening }}"
entity_id: sequence:
- light.livingroom - service: light.turn_on
- light.indkoersel_2 target:
- light.andreas_vaerelse entity_id: "{{ repeat.item }}"
- light.bedroom - delay:
- light.daniels_vaerelse seconds: "{{ range(20,120) | random }}"
- light.forgang
- delay: - delay:
seconds: "{{ rand_delay }}" minutes: "{{ range(15,60) | random }}"
- service: light.turn_off - repeat:
target: for_each: "{{ lights_evening | reverse }}"
entity_id: sequence:
- light.livingroom - service: light.turn_off
- light.indkoersel_2 target:
- light.andreas_vaerelse entity_id: "{{ repeat.item }}"
- light.bedroom - delay:
- light.daniels_vaerelse seconds: "{{ range(20,120) | random }}"
- light.forgang
- choose: - choose:
- conditions: - conditions:
@@ -159,7 +177,7 @@ action:
media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj" media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj"
- delay: - delay:
seconds: "{{ range(300,1200) | random }}" minutes: "{{ range(10,20) | random }}"
- service: media_player.media_stop - service: media_player.media_stop
target: target: