Compare commits

..

2 Commits

Author SHA1 Message Date
claus 79eb860711 Add forgang motion lighting automation 2026-04-05 17:41:10 +02:00
claus 14824b0ab7 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
2026-03-26 15:47:26 +01:00
2 changed files with 167 additions and 62 deletions
+87
View File
@@ -0,0 +1,87 @@
- id: forgang_motion_lys
alias: Forgang lys via bevægelse
mode: restart
trigger:
- platform: state
entity_id: binary_sensor.forgang_bevaegelse
to: "on"
condition:
- condition: numeric_state
entity_id: sensor.forgang_sensor_illuminance
below: 60
action:
- choose:
- conditions:
- condition: time
after: "06:00:00"
before: "23:59:00"
sequence:
- service: scene.turn_on
target:
entity_id: scene.forgang_bright
default:
- service: scene.turn_on
target:
entity_id: scene.forgang_dimmed
- id: forgang_motion_sluk_dag
alias: Sluk forgang lys efter 10 min uden bevægelse
mode: restart
trigger:
- platform: state
entity_id: binary_sensor.forgang_bevaegelse
to: "off"
condition:
- condition: time
after: "06:00:00"
before: "23:59:00"
action:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.forgang_bevaegelse
to: "on"
timeout: "00:10:00"
continue_on_timeout: true
- condition: state
entity_id: binary_sensor.forgang_bevaegelse
state: "off"
- service: light.turn_off
target:
entity_id: light.forgang
- id: forgang_motion_sluk_nat
alias: Sluk forgang lys efter 5 min uden bevægelse om natten
mode: restart
trigger:
- platform: state
entity_id: binary_sensor.forgang_bevaegelse
to: "off"
condition:
- condition: or
conditions:
- condition: time
before: "06:00:00"
- condition: time
after: "23:59:00"
action:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.forgang_bevaegelse
to: "on"
timeout: "00:05:00"
continue_on_timeout: true
- condition: state
entity_id: binary_sensor.forgang_bevaegelse
state: "off"
- service: light.turn_off
target:
entity_id: light.forgang
+68 -50
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:
- repeat:
for_each: "{{ lights_morning }}"
sequence:
- service: light.turn_on - service: light.turn_on
target: target:
entity_id: entity_id: "{{ repeat.item }}"
- light.livingroom - delay:
- light.indkoersel_2 seconds: "{{ range(30,180) | random }}"
- light.andreas_vaerelse
- light.bedroom
- light.daniels_vaerelse
- light.forgang
- delay: - delay:
seconds: "{{ rand_delay }}" minutes: "{{ range(10,30) | random }}"
- repeat:
for_each: "{{ lights_morning | reverse }}"
sequence:
- service: light.turn_off - service: light.turn_off
target: target:
entity_id: entity_id: "{{ repeat.item }}"
- light.livingroom - delay:
- light.indkoersel_2 seconds: "{{ range(20,120) | random }}"
- light.andreas_vaerelse
- light.bedroom
- light.daniels_vaerelse
- 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:
- repeat:
for_each: "{{ lights_midday }}"
sequence:
- service: light.turn_on - service: light.turn_on
target: target:
entity_id: entity_id: "{{ repeat.item }}"
- light.kokken - delay:
- light.indkoersel seconds: "{{ range(60,300) | random }}"
- delay: - delay:
seconds: "{{ rand_delay }}" minutes: "{{ range(5,20) | random }}"
- repeat:
for_each: "{{ lights_midday | reverse }}"
sequence:
- service: light.turn_off - service: light.turn_off
target: target:
entity_id: entity_id: "{{ repeat.item }}"
- light.livingroom - delay:
- light.indkoersel_2 seconds: "{{ range(30,180) | random }}"
- light.andreas_vaerelse
- light.bedroom
- light.daniels_vaerelse
- 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:
- repeat:
for_each: "{{ lights_evening }}"
sequence:
- service: light.turn_on - service: light.turn_on
target: target:
entity_id: entity_id: "{{ repeat.item }}"
- light.livingroom - delay:
- light.indkoersel_2 seconds: "{{ range(20,120) | random }}"
- light.andreas_vaerelse
- light.bedroom
- light.daniels_vaerelse
- light.forgang
- delay: - delay:
seconds: "{{ rand_delay }}" minutes: "{{ range(15,60) | random }}"
- repeat:
for_each: "{{ lights_evening | reverse }}"
sequence:
- service: light.turn_off - service: light.turn_off
target: target:
entity_id: entity_id: "{{ repeat.item }}"
- light.livingroom - delay:
- light.indkoersel_2 seconds: "{{ range(20,120) | random }}"
- light.andreas_vaerelse
- light.bedroom
- light.daniels_vaerelse
- 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: