fix presence
This commit is contained in:
@@ -1,44 +1,60 @@
|
|||||||
alias: Presence Simulation - Tidsblokke med rum
|
alias: Presence Simulation - Tidsblokke (robust)
|
||||||
description: Simulerer tilstedeværelse i forskellige rum med musik
|
mode: restart
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
- platform: time
|
- platform: time
|
||||||
at: "07:00:00" # Morgen
|
at: "07:00:00"
|
||||||
- platform: time
|
- platform: time
|
||||||
at: "12:00:00" # Middag
|
at: "12:00:00"
|
||||||
- platform: time
|
- platform: time
|
||||||
at: "18:00:00" # Aften
|
at: "18:00:00"
|
||||||
|
|
||||||
condition:
|
condition:
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: input_boolean.presence_simulation
|
entity_id: input_boolean.presence_simulation
|
||||||
state: "on"
|
state: "on"
|
||||||
- condition: time
|
|
||||||
after: "07:00:00"
|
|
||||||
before: "22:30:00"
|
|
||||||
action:
|
action:
|
||||||
|
- variables:
|
||||||
|
rand_delay: "{{ range(300,1200) | random }}" # 5-20 min
|
||||||
|
rand_music: "{{ range(0,100) | random }}"
|
||||||
|
|
||||||
- choose:
|
- choose:
|
||||||
|
|
||||||
|
# 🌅 Morgen
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: time
|
- condition: time
|
||||||
after: "07:00:00"
|
after: "06:59:00"
|
||||||
before: "12:00:00"
|
before: "12:00:00"
|
||||||
sequence:
|
sequence:
|
||||||
# Morgen: Bad + forgang
|
|
||||||
- service: homeassistant.turn_on
|
- service: light.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id:
|
entity_id:
|
||||||
- binary_sensor.bad_motion_sensor_motion
|
- light.livingroom
|
||||||
- binary_sensor.forgang_sensor_motion
|
- light.indkoersel_2
|
||||||
|
- light.andreas_vaerelse
|
||||||
|
- light.bedroom
|
||||||
|
- light.daniels_vaerelse
|
||||||
|
- light.forgang
|
||||||
|
|
||||||
- delay:
|
- delay:
|
||||||
seconds: "{{ range(5,20)|random }}"
|
seconds: "{{ rand_delay }}"
|
||||||
- service: homeassistant.turn_off
|
|
||||||
|
- service: light.turn_off
|
||||||
target:
|
target:
|
||||||
entity_id:
|
entity_id:
|
||||||
- binary_sensor.bad_motion_sensor_motion
|
- light.livingroom
|
||||||
- binary_sensor.forgang_sensor_motion
|
- light.indkoersel_2
|
||||||
# Musik chance
|
- light.andreas_vaerelse
|
||||||
|
- light.bedroom
|
||||||
|
- light.daniels_vaerelse
|
||||||
|
- light.forgang
|
||||||
|
|
||||||
- choose:
|
- choose:
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ range(0,10)|random < 2 }}" # 20% chance
|
value_template: "{{ rand_music < 20 }}"
|
||||||
sequence:
|
sequence:
|
||||||
- service: media_player.play_media
|
- service: media_player.play_media
|
||||||
target:
|
target:
|
||||||
@@ -46,35 +62,44 @@ action:
|
|||||||
data:
|
data:
|
||||||
media_content_type: music
|
media_content_type: music
|
||||||
media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj"
|
media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj"
|
||||||
|
|
||||||
- delay:
|
- delay:
|
||||||
minutes: "{{ range(5,15)|random }}"
|
seconds: "{{ range(300,900) | random }}"
|
||||||
|
|
||||||
- service: media_player.media_stop
|
- service: media_player.media_stop
|
||||||
target:
|
target:
|
||||||
entity_id: media_player.kokken
|
entity_id: media_player.kokken
|
||||||
|
|
||||||
|
# 🌤️ Middag
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: time
|
- condition: time
|
||||||
after: "12:00:00"
|
after: "11:59:00"
|
||||||
before: "18:00:00"
|
before: "18:00:00"
|
||||||
sequence:
|
sequence:
|
||||||
# Middag: Køkken + indkørsel
|
|
||||||
- service: homeassistant.turn_on
|
- service: light.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id:
|
entity_id:
|
||||||
- binary_sensor.indkorsel_sensor_motion
|
- light.kokken
|
||||||
- binary_sensor.hue_motion_sensor_2_motion
|
- light.indkoersel
|
||||||
|
|
||||||
- delay:
|
- delay:
|
||||||
seconds: "{{ range(5,20)|random }}"
|
seconds: "{{ rand_delay }}"
|
||||||
- service: homeassistant.turn_off
|
|
||||||
|
- service: light.turn_off
|
||||||
target:
|
target:
|
||||||
entity_id:
|
entity_id:
|
||||||
- binary_sensor.indkorsel_sensor_motion
|
- light.livingroom
|
||||||
- binary_sensor.hue_motion_sensor_2_motion
|
- light.indkoersel_2
|
||||||
# Musik chance
|
- light.andreas_vaerelse
|
||||||
|
- light.bedroom
|
||||||
|
- light.daniels_vaerelse
|
||||||
|
- light.forgang
|
||||||
|
|
||||||
- choose:
|
- choose:
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ range(0,10)|random < 3 }}" # 30% chance
|
value_template: "{{ rand_music < 30 }}"
|
||||||
sequence:
|
sequence:
|
||||||
- service: media_player.play_media
|
- service: media_player.play_media
|
||||||
target:
|
target:
|
||||||
@@ -82,37 +107,49 @@ action:
|
|||||||
data:
|
data:
|
||||||
media_content_type: music
|
media_content_type: music
|
||||||
media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj"
|
media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj"
|
||||||
|
|
||||||
- delay:
|
- delay:
|
||||||
minutes: "{{ range(5,15)|random }}"
|
seconds: "{{ range(300,900) | random }}"
|
||||||
|
|
||||||
- service: media_player.media_stop
|
- service: media_player.media_stop
|
||||||
target:
|
target:
|
||||||
entity_id: media_player.kokken
|
entity_id: media_player.kokken
|
||||||
|
|
||||||
|
# 🌙 Aften
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: time
|
- condition: time
|
||||||
after: "18:00:00"
|
after: "17:59:00"
|
||||||
before: "22:30:00"
|
before: "22:30:00"
|
||||||
sequence:
|
sequence:
|
||||||
# Aften: Stue + hue sensors
|
|
||||||
- service: homeassistant.turn_on
|
- service: light.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id:
|
entity_id:
|
||||||
- binary_sensor.stue_motion_bevaegelse
|
- light.livingroom
|
||||||
- binary_sensor.hue_motion_sensor_2_motion_2
|
- light.indkoersel_2
|
||||||
- binary_sensor.hue_motion_sensor_1_motion_2
|
- light.andreas_vaerelse
|
||||||
|
- light.bedroom
|
||||||
|
- light.daniels_vaerelse
|
||||||
|
- light.forgang
|
||||||
|
|
||||||
|
|
||||||
- delay:
|
- delay:
|
||||||
seconds: "{{ range(5,20)|random }}"
|
seconds: "{{ rand_delay }}"
|
||||||
- service: homeassistant.turn_off
|
|
||||||
|
- service: light.turn_off
|
||||||
target:
|
target:
|
||||||
entity_id:
|
entity_id:
|
||||||
- binary_sensor.stue_motion_bevaegelse
|
- light.livingroom
|
||||||
- binary_sensor.hue_motion_sensor_2_motion_2
|
- light.indkoersel_2
|
||||||
- binary_sensor.hue_motion_sensor_1_motion_2
|
- light.andreas_vaerelse
|
||||||
# Musik chance
|
- light.bedroom
|
||||||
|
- light.daniels_vaerelse
|
||||||
|
- light.forgang
|
||||||
|
|
||||||
- choose:
|
- choose:
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ range(0,10)|random < 5 }}" # 50% chance
|
value_template: "{{ rand_music < 50 }}"
|
||||||
sequence:
|
sequence:
|
||||||
- service: media_player.play_media
|
- service: media_player.play_media
|
||||||
target:
|
target:
|
||||||
@@ -120,8 +157,10 @@ action:
|
|||||||
data:
|
data:
|
||||||
media_content_type: music
|
media_content_type: music
|
||||||
media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj"
|
media_content_id: "spotify:playlist:37i9dQZF1EVHGWrwldPRtj"
|
||||||
|
|
||||||
- delay:
|
- delay:
|
||||||
minutes: "{{ range(5,15)|random }}"
|
seconds: "{{ range(300,1200) | random }}"
|
||||||
|
|
||||||
- service: media_player.media_stop
|
- service: media_player.media_stop
|
||||||
target:
|
target:
|
||||||
entity_id: media_player.kokken
|
entity_id: media_player.kokken
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
alias: Vacation Mode - Stop ved slutdato
|
alias: Vacation Mode - Stop ved slutdato
|
||||||
trigger:
|
trigger:
|
||||||
- platform: time
|
- platform: time_pattern
|
||||||
at: input_datetime.vacation_end
|
minutes: "/1"
|
||||||
|
|
||||||
condition:
|
condition:
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: input_boolean.vacation_mode
|
entity_id: input_boolean.vacation_mode
|
||||||
state: "on"
|
state: "on"
|
||||||
|
|
||||||
|
- condition: template
|
||||||
|
value_template: >
|
||||||
|
{% set dt = states('input_datetime.vacation_end') %}
|
||||||
|
{{ dt not in ['unknown','unavailable',''] and
|
||||||
|
now() >= as_datetime(dt) }}
|
||||||
|
|
||||||
action:
|
action:
|
||||||
- service: input_boolean.turn_off
|
- service: input_boolean.turn_off
|
||||||
target:
|
target:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
alias: Vacation Mode - Recovery efter restart
|
alias: Vacation Mode - Recovery efter restart
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
- platform: homeassistant
|
- platform: homeassistant
|
||||||
event: start
|
event: start
|
||||||
@@ -10,17 +11,16 @@ condition:
|
|||||||
|
|
||||||
action:
|
action:
|
||||||
- choose:
|
- choose:
|
||||||
# Hvis slutdato allerede er passeret → sluk med det samme
|
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ now() >= states('input_datetime.vacation_end') | as_datetime }}"
|
value_template: >
|
||||||
|
{% set dt = states('input_datetime.vacation_end') %}
|
||||||
|
{{ dt not in ['unknown','unavailable',''] and
|
||||||
|
now() >= as_datetime(dt) }}
|
||||||
sequence:
|
sequence:
|
||||||
- service: input_boolean.turn_off
|
- service: input_boolean.turn_off
|
||||||
target:
|
target:
|
||||||
entity_id:
|
entity_id:
|
||||||
- input_boolean.vacation_mode
|
- input_boolean.vacation_mode
|
||||||
- input_boolean.presence_simulation
|
- input_boolean.presence_simulation
|
||||||
|
|
||||||
# Ellers → gør ingenting (time trigger tager over)
|
|
||||||
- conditions: []
|
|
||||||
sequence: []
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
- platform: template
|
||||||
|
sensors:
|
||||||
|
|
||||||
|
n22_dato:
|
||||||
|
friendly_name: "Dato"
|
||||||
|
value_template: >
|
||||||
|
{{ now().strftime('%A %d %B') | replace('Monday','Mandag')
|
||||||
|
| replace('Tuesday','Tirsdag')
|
||||||
|
| replace('Wednesday','Onsdag')
|
||||||
|
| replace('Thursday','Torsdag')
|
||||||
|
| replace('Friday','Fredag')
|
||||||
|
| replace('Saturday','Lørdag')
|
||||||
|
| replace('Sunday','Søndag') }}
|
||||||
|
|
||||||
|
n22_solopgang:
|
||||||
|
friendly_name: "Solopgang"
|
||||||
|
value_template: >
|
||||||
|
{% set t = state_attr('sun.sun','next_rising') %}
|
||||||
|
{{ as_timestamp(t) | timestamp_custom('%H:%M') if t else '-' }}
|
||||||
|
|
||||||
|
n22_solnedgang:
|
||||||
|
friendly_name: "Solnedgang"
|
||||||
|
value_template: >
|
||||||
|
{% set t = state_attr('sun.sun','next_setting') %}
|
||||||
|
{{ as_timestamp(t) | timestamp_custom('%H:%M') if t else '-' }}
|
||||||
Reference in New Issue
Block a user