diff --git a/dashboards/views/05b_lys.yaml b/dashboards/views/05b_lys.yaml index 0ba98f0..9103b9d 100644 --- a/dashboards/views/05b_lys.yaml +++ b/dashboards/views/05b_lys.yaml @@ -3,7 +3,7 @@ path: lys icon: mdi:lightbulb-multiple type: sections -max_columns: 2 +max_columns: 3 sections: - type: grid @@ -150,7 +150,7 @@ sections: data: entity_id: script.raketloop - type: grid - columns: 2 + columns: 3 square: false cards: - type: custom:mushroom-light-card @@ -464,7 +464,7 @@ sections: - light.spejl2 - light.badevaerelse_2 - type: grid - columns: 2 + columns: 3 square: false cards: - type: custom:mushroom-light-card @@ -569,7 +569,7 @@ sections: show_color_temp_control: true collapsible_controls: true - type: grid - columns: 2 + columns: 3 square: false cards: - type: custom:mushroom-light-card @@ -647,7 +647,7 @@ sections: data: entity_id: script.have_color_scene - type: grid - columns: 2 + columns: 3 square: false cards: - type: custom:mushroom-light-card @@ -711,7 +711,7 @@ sections: show_brightness_control: true collapsible_controls: true - type: grid - columns: 2 + columns: 3 square: false cards: - type: custom:mushroom-light-card @@ -756,7 +756,7 @@ sections: - type: heading heading: Ovrige - type: grid - columns: 2 + columns: 3 square: false cards: - type: custom:mushroom-light-card @@ -779,3 +779,64 @@ sections: use_light_color: true show_brightness_control: true collapsible_controls: true + + - type: grid + cards: + - type: heading + heading: Motion-indstillinger + - type: entities + title: Gang + entities: + - entity: input_number.gang_lux_threshold + name: Lux grænse + - entity: input_number.gang_timeout_day + name: Timeout dag + - entity: input_number.gang_timeout_night + name: Timeout nat + - type: entities + title: Badeværelse + entities: + - entity: input_number.badevaerelse_timeout_day + name: Timeout dag + - entity: input_number.badevaerelse_timeout_night + name: Timeout nat + - type: entities + title: Andreas + entities: + - entity: input_number.andreas_lux_threshold + name: Lux grænse + - entity: input_number.andreas_timeout + name: Timeout + - entity: input_number.andreas_brightness + name: Lysstyrke + - type: entities + title: Daniel + entities: + - entity: input_number.daniel_lux_threshold + name: Lux grænse + - entity: input_number.daniel_timeout + name: Timeout + - entity: input_number.daniel_brightness + name: Lysstyrke + - type: entities + title: Kontor + entities: + - entity: input_number.kontor_lux_threshold + name: Lux grænse + - entity: input_number.kontor_timeout_day + name: Timeout dag + - entity: input_number.kontor_timeout_night + name: Timeout nat + - type: entities + title: Stue + entities: + - entity: input_number.stue_lux_threshold + name: Lux grænse + - entity: input_number.stue_timeout_morgen + name: Timeout morgen (06-16) + - entity: input_number.stue_timeout_eftermiddag + name: Timeout eftermiddag (16-19) + - entity: input_number.stue_timeout_aften + name: Timeout aften/TV off (19-00) + - entity: input_number.stue_timeout_nat + name: Timeout nat (00-06) diff --git a/include/automations/lys_stue.yaml b/include/automations/lys_stue.yaml index f5abdb2..5bd4648 100644 --- a/include/automations/lys_stue.yaml +++ b/include/automations/lys_stue.yaml @@ -1,157 +1,112 @@ - id: stue_motion_lys - alias: Stue lys via bevægelse + alias: Stue lys via bevaegelse mode: restart trigger: - platform: state entity_id: binary_sensor.stue_bevaegelse to: "on" + id: motion_on - condition: - - condition: numeric_state - entity_id: sensor.stue_belysningsstyrke - below: 60 + - platform: state + entity_id: binary_sensor.stue_bevaegelse + to: "off" + id: motion_off + + - platform: state + entity_id: media_player.samsung_s95ca_55_3 + to: "off" + id: tv_off + + variables: + lux_limit: "{{ states('input_number.stue_lux_threshold') | int }}" + dagperiode: > + {% set t = now().strftime('%H%M') | int %} + {% if 600 <= t < 1600 %}morgen + {% elif 1600 <= t < 1900 %}eftermiddag + {% elif 1900 <= t %}aften + {% else %}nat{% endif %} + timeout_min: > + {% set t = now().strftime('%H%M') | int %} + {% if 600 <= t < 1600 %} + {{ states('input_number.stue_timeout_morgen') | int }} + {% elif 1600 <= t < 1900 %} + {{ states('input_number.stue_timeout_eftermiddag') | int }} + {% elif 1900 <= t %} + {{ states('input_number.stue_timeout_aften') | int }} + {% else %} + {{ states('input_number.stue_timeout_nat') | int }} + {% endif %} action: - choose: + + # Motion on: taend lys hvis lux lavt - conditions: - - condition: time - after: "06:00:00" - before: "16:00:00" + - condition: trigger + id: motion_on + - condition: template + value_template: > + {{ states('sensor.stue_belysningsstyrke') | int < lux_limit }} sequence: - - service: scene.turn_on - target: - entity_id: scene.stue_bright + - choose: + - conditions: + - condition: template + value_template: "{{ dagperiode == 'morgen' }}" + sequence: + - service: scene.turn_on + target: + entity_id: scene.stue_bright + - conditions: + - condition: template + value_template: "{{ dagperiode == 'eftermiddag' }}" + sequence: + - service: scene.turn_on + target: + entity_id: scene.stue_annes_favorit + default: + - service: scene.turn_on + target: + entity_id: scene.stue_relax_minus_syd + + # Motion off: vent timeout, sluk hvis stadig ingen bevaegelse + # Aften: springer over hvis TV er taendt (TV-off trigger haandterer det) - conditions: - - condition: time - after: "16:00:00" - before: "22:00:00" + - condition: trigger + id: motion_off + - condition: template + value_template: > + {{ dagperiode != 'aften' or + is_state('media_player.samsung_s95ca_55_3', 'off') }} sequence: - - service: scene.turn_on + - delay: + minutes: "{{ timeout_min }}" + - condition: state + entity_id: binary_sensor.stue_bevaegelse + state: "off" + - condition: template + value_template: > + {{ dagperiode != 'aften' or + is_state('media_player.samsung_s95ca_55_3', 'off') }} + - service: light.turn_off target: - entity_id: scene.stue_annes_favorit - default: - - service: scene.turn_on - target: - entity_id: scene.stue_relax_minus_syd + entity_id: light.livingroom -- id: stue_motion_sluk_morgen - alias: Sluk stue lys efter 60 min uden bevægelse om morgenen - mode: restart - - trigger: - - platform: state - entity_id: binary_sensor.stue_bevaegelse - to: "off" - - condition: - - condition: time - after: "06:00:00" - before: "16:00:00" - - action: - - wait_for_trigger: - - platform: state - entity_id: binary_sensor.stue_bevaegelse - to: "on" - timeout: "01:00:00" - continue_on_timeout: true - - condition: state - entity_id: binary_sensor.stue_bevaegelse - state: "off" - - service: light.turn_off - target: - entity_id: light.livingroom - -- id: stue_motion_sluk_eftermiddag_aften - alias: Sluk stue lys efter 120 min uden bevægelse mellem 16 og 19 - mode: restart - - trigger: - - platform: state - entity_id: binary_sensor.stue_bevaegelse - to: "off" - - condition: - - condition: time - after: "16:00:00" - before: "19:00:00" - - action: - - wait_for_trigger: - - platform: state - entity_id: binary_sensor.stue_bevaegelse - to: "on" - timeout: "02:00:00" - continue_on_timeout: true - - condition: state - entity_id: binary_sensor.stue_bevaegelse - state: "off" - - service: light.turn_off - target: - entity_id: light.livingroom - -- id: stue_motion_sluk_aften_tv - alias: Sluk stue lys efter 10 min uden bevægelse når TV er slukket mellem 19 og 00 - mode: restart - - trigger: - - platform: state - entity_id: binary_sensor.stue_bevaegelse - to: "off" - - platform: state - entity_id: media_player.samsung_s95ca_55_3 - to: "off" - - condition: - - condition: time - after: "19:00:00" - before: "00:00:00" - - action: - - condition: state - entity_id: media_player.samsung_s95ca_55_3 - state: "off" - - wait_for_trigger: - - platform: state - entity_id: binary_sensor.stue_bevaegelse - to: "on" - timeout: "00:10:00" - continue_on_timeout: true - - condition: state - entity_id: binary_sensor.stue_bevaegelse - state: "off" - - condition: state - entity_id: media_player.samsung_s95ca_55_3 - state: "off" - - service: light.turn_off - target: - entity_id: light.livingroom - -- id: stue_motion_sluk_nat - alias: Sluk stue lys efter 30 min uden bevægelse om natten - mode: restart - - trigger: - - platform: state - entity_id: binary_sensor.stue_bevaegelse - to: "off" - - condition: - - condition: time - after: "00:00:00" - before: "06:00:00" - - action: - - wait_for_trigger: - - platform: state - entity_id: binary_sensor.stue_bevaegelse - to: "on" - timeout: "00:30:00" - continue_on_timeout: true - - condition: state - entity_id: binary_sensor.stue_bevaegelse - state: "off" - - service: light.turn_off - target: - entity_id: light.livingroom \ No newline at end of file + # TV slukket om aftenen: vent 10 min, sluk hvis ingen bevaegelse + - conditions: + - condition: trigger + id: tv_off + - condition: template + value_template: "{{ dagperiode == 'aften' }}" + sequence: + - delay: + minutes: "{{ timeout_min }}" + - condition: state + entity_id: binary_sensor.stue_bevaegelse + state: "off" + - condition: state + entity_id: media_player.samsung_s95ca_55_3 + state: "off" + - service: light.turn_off + target: + entity_id: light.livingroom diff --git a/include/input/number/stue.yaml b/include/input/number/stue.yaml new file mode 100644 index 0000000..f6b6160 --- /dev/null +++ b/include/input/number/stue.yaml @@ -0,0 +1,39 @@ +stue_lux_threshold: + name: Stue lux grænse + min: 0 + max: 500 + step: 5 + unit_of_measurement: lux + initial: 60 + +stue_timeout_morgen: + name: Stue timeout morgen (06-16) + min: 10 + max: 180 + step: 5 + unit_of_measurement: min + initial: 60 + +stue_timeout_eftermiddag: + name: Stue timeout eftermiddag (16-19) + min: 10 + max: 240 + step: 5 + unit_of_measurement: min + initial: 120 + +stue_timeout_aften: + name: Stue timeout aften (19-00, TV slukket) + min: 1 + max: 60 + step: 1 + unit_of_measurement: min + initial: 10 + +stue_timeout_nat: + name: Stue timeout nat (00-06) + min: 5 + max: 120 + step: 5 + unit_of_measurement: min + initial: 30