From cbeb832dd7d6e4db2e78bbd81ac46bc1742e5095 Mon Sep 17 00:00:00 2001 From: Claus Dethlefsen Date: Tue, 24 Mar 2026 18:22:52 +0100 Subject: [PATCH] presence simulation --- include/automations/presence_simulation.yaml | 127 ++++++++++++++++++ include/automations/start_vacation.yaml | 15 +++ include/automations/vacation_recovery.yaml | 26 ++++ include/automations/vacation_start.yaml | 19 +++ include/automations/vacation_stop_manual.yaml | 15 +++ include/input/boolean/timers.yaml | 6 + include/input/boolean/vacation.yaml | 6 + include/input/datetime/vacation.yaml | 5 + 8 files changed, 219 insertions(+) create mode 100644 include/automations/presence_simulation.yaml create mode 100644 include/automations/start_vacation.yaml create mode 100644 include/automations/vacation_recovery.yaml create mode 100644 include/automations/vacation_start.yaml create mode 100644 include/automations/vacation_stop_manual.yaml create mode 100644 include/input/boolean/timers.yaml create mode 100644 include/input/boolean/vacation.yaml create mode 100644 include/input/datetime/vacation.yaml diff --git a/include/automations/presence_simulation.yaml b/include/automations/presence_simulation.yaml new file mode 100644 index 0000000..738012e --- /dev/null +++ b/include/automations/presence_simulation.yaml @@ -0,0 +1,127 @@ +alias: Presence Simulation - Tidsblokke med rum +description: Simulerer tilstedeværelse i forskellige rum med musik +trigger: + - platform: time + at: "07:00:00" # Morgen + - platform: time + at: "12:00:00" # Middag + - platform: time + at: "18:00:00" # Aften +condition: + - condition: state + entity_id: input_boolean.presence_simulation + state: "on" + - condition: time + after: "07:00:00" + before: "22:30:00" +action: + - choose: + - conditions: + - condition: time + after: "07:00:00" + before: "12:00:00" + sequence: + # Morgen: Bad + forgang + - service: homeassistant.turn_on + target: + entity_id: + - binary_sensor.bad_motion_sensor_motion + - binary_sensor.forgang_sensor_motion + - delay: + seconds: "{{ range(5,20)|random }}" + - service: homeassistant.turn_off + target: + entity_id: + - binary_sensor.bad_motion_sensor_motion + - binary_sensor.forgang_sensor_motion + # Musik chance + - choose: + - conditions: + - condition: template + value_template: "{{ range(0,10)|random < 2 }}" # 20% chance + sequence: + - service: media_player.play_media + target: + entity_id: media_player.kokken + data: + media_content_type: music + media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj" + - delay: + minutes: "{{ range(5,15)|random }}" + - service: media_player.media_stop + target: + entity_id: media_player.kokken + + - conditions: + - condition: time + after: "12:00:00" + before: "18:00:00" + sequence: + # Middag: Køkken + indkørsel + - service: homeassistant.turn_on + target: + entity_id: + - binary_sensor.indkorsel_sensor_motion + - binary_sensor.hue_motion_sensor_2_motion + - delay: + seconds: "{{ range(5,20)|random }}" + - service: homeassistant.turn_off + target: + entity_id: + - binary_sensor.indkorsel_sensor_motion + - binary_sensor.hue_motion_sensor_2_motion + # Musik chance + - choose: + - conditions: + - condition: template + value_template: "{{ range(0,10)|random < 3 }}" # 30% chance + sequence: + - service: media_player.play_media + target: + entity_id: media_player.kokken + data: + media_content_type: music + media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj" + - delay: + minutes: "{{ range(5,15)|random }}" + - service: media_player.media_stop + target: + entity_id: media_player.kokken + + - conditions: + - condition: time + after: "18:00:00" + before: "22:30:00" + sequence: + # Aften: Stue + hue sensors + - service: homeassistant.turn_on + target: + entity_id: + - binary_sensor.stue_motion_bevaegelse + - binary_sensor.hue_motion_sensor_2_motion_2 + - binary_sensor.hue_motion_sensor_1_motion_2 + - delay: + seconds: "{{ range(5,20)|random }}" + - service: homeassistant.turn_off + target: + entity_id: + - binary_sensor.stue_motion_bevaegelse + - binary_sensor.hue_motion_sensor_2_motion_2 + - binary_sensor.hue_motion_sensor_1_motion_2 + # Musik chance + - choose: + - conditions: + - condition: template + value_template: "{{ range(0,10)|random < 5 }}" # 50% chance + sequence: + - service: media_player.play_media + target: + entity_id: media_player.kokken + data: + media_content_type: music + media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj" + - delay: + minutes: "{{ range(5,15)|random }}" + - service: media_player.media_stop + target: + entity_id: media_player.kokken diff --git a/include/automations/start_vacation.yaml b/include/automations/start_vacation.yaml new file mode 100644 index 0000000..e0c719a --- /dev/null +++ b/include/automations/start_vacation.yaml @@ -0,0 +1,15 @@ +alias: Start Vacation Mode +description: Aktiverer presence simulation ved feriestart og planlægger slutdato +trigger: + - platform: time + at: "2026-03-28 14:00:00" # Ferie start +action: + - service: input_boolean.turn_on + target: + entity_id: input_boolean.presence_simulation + # Planlæg slutdato automatisk + - delay: + days: 7 + - service: input_boolean.turn_off + target: + entity_id: input_boolean.presence_simulation diff --git a/include/automations/vacation_recovery.yaml b/include/automations/vacation_recovery.yaml new file mode 100644 index 0000000..6ab2a39 --- /dev/null +++ b/include/automations/vacation_recovery.yaml @@ -0,0 +1,26 @@ +alias: Vacation Mode - Recovery efter restart +trigger: + - platform: homeassistant + event: start + +condition: + - condition: state + entity_id: input_boolean.vacation_mode + state: "on" + +action: + - choose: + # Hvis slutdato allerede er passeret → sluk med det samme + - conditions: + - condition: template + value_template: "{{ now() >= states('input_datetime.vacation_end') | as_datetime }}" + sequence: + - service: input_boolean.turn_off + target: + entity_id: + - input_boolean.vacation_mode + - input_boolean.presence_simulation + + # Ellers → gør ingenting (time trigger tager over) + - conditions: [] + sequence: [] diff --git a/include/automations/vacation_start.yaml b/include/automations/vacation_start.yaml new file mode 100644 index 0000000..2ec2a47 --- /dev/null +++ b/include/automations/vacation_start.yaml @@ -0,0 +1,19 @@ +alias: Vacation Mode - Start +trigger: + - platform: state + entity_id: input_boolean.vacation_mode + to: "on" + +action: + # Sæt slutdato = nu + 7 dage + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.vacation_end + data: + datetime: > + {{ (now() + timedelta(days=7)).strftime('%Y-%m-%d %H:%M:%S') }} + + # Start presence simulation + - service: input_boolean.turn_on + target: + entity_id: input_boolean.presence_simulation diff --git a/include/automations/vacation_stop_manual.yaml b/include/automations/vacation_stop_manual.yaml new file mode 100644 index 0000000..f0b4c51 --- /dev/null +++ b/include/automations/vacation_stop_manual.yaml @@ -0,0 +1,15 @@ +alias: Vacation Mode - Manuel stop +trigger: + - platform: state + entity_id: input_boolean.vacation_mode + to: "off" + +action: + - service: input_boolean.turn_off + target: + entity_id: input_boolean.presence_simulation + + - service: media_player.media_stop + target: + entity_id: media_player.kokken + diff --git a/include/input/boolean/timers.yaml b/include/input/boolean/timers.yaml new file mode 100644 index 0000000..10ab9d3 --- /dev/null +++ b/include/input/boolean/timers.yaml @@ -0,0 +1,6 @@ +first_run: + initial: off +first_run_eve: + initial: off +first_run_stue: + initial: off diff --git a/include/input/boolean/vacation.yaml b/include/input/boolean/vacation.yaml new file mode 100644 index 0000000..dc45fd0 --- /dev/null +++ b/include/input/boolean/vacation.yaml @@ -0,0 +1,6 @@ +vacation_mode: + name: Vacation Mode + icon: mdi:beach + +presence_simulation: + name: Presence Simulation diff --git a/include/input/datetime/vacation.yaml b/include/input/datetime/vacation.yaml new file mode 100644 index 0000000..3c7d29c --- /dev/null +++ b/include/input/datetime/vacation.yaml @@ -0,0 +1,5 @@ +vacation_end: + name: Vacation End + has_date: true + has_time: true +