Motion detection in the hallway, new lamp in the living room.

This commit is contained in:
2026-02-14 14:58:06 +01:00
parent fda6e6abff
commit fdbbbb5300
4 changed files with 307 additions and 322 deletions

View File

@@ -1,17 +1,26 @@
- id: '1623153060369' - id: '1623153060369'
alias: Licht bei Sonnenuntergang einschalten alias: Licht bei Sonnenuntergang einschalten
description: '' description: ''
trigger: triggers:
- platform: sun - event: sunset
event: sunset
offset: '-1:00' offset: '-1:00'
condition: trigger: sun
conditions:
- condition: state - condition: state
entity_id: person.marcus_scholz entity_id: person.marcus_scholz
state: home state: home
action: actions:
- service: script.moodlight_orange_plasma - data: {}
data: {} action: script.moodlight_orange_plasma
- action: light.turn_on
metadata: {}
target:
entity_id:
- light.kuche_anrichte
- light.kajplats_e14_cws_globe_806lm
data:
brightness_pct: 75
color_temp_kelvin: 3035
mode: single mode: single
- id: '1623224198352' - id: '1623224198352'
alias: TV Anti-Reflexion alias: TV Anti-Reflexion
@@ -33,14 +42,13 @@
- id: '1623526683767' - id: '1623526683767'
alias: Licht bei Sonnenaufgang ausschalten alias: Licht bei Sonnenaufgang ausschalten
description: '' description: ''
trigger: triggers:
- platform: sun - event: sunrise
event: sunrise
offset: '+1:00' offset: '+1:00'
condition: [] trigger: sun
action: conditions: []
- service: light.turn_off actions:
target: - target:
area_id: area_id:
- schlafzimmer - schlafzimmer
device_id: device_id:
@@ -52,9 +60,10 @@
- 98a9eef603f8c8ae6200c4834a3dbf4f - 98a9eef603f8c8ae6200c4834a3dbf4f
- 32d15eec63fe68d5770813d47da53657 - 32d15eec63fe68d5770813d47da53657
- 9f42805af5b7e423023595390342b9ac - 9f42805af5b7e423023595390342b9ac
- 063e41329df7b29bbaa8df2f508ee6cb entity_id: light.kajplats_e14_cws_globe_806lm
data: data:
transition: 2 transition: 2
action: light.turn_off
mode: single mode: single
- id: '1623673821789' - id: '1623673821789'
alias: Gute Nacht! alias: Gute Nacht!
@@ -464,35 +473,28 @@
- id: '1632477389492' - id: '1632477389492'
alias: Licht beim Heimkommen einschalten alias: Licht beim Heimkommen einschalten
description: Nur während Dunkelphase description: Nur während Dunkelphase
trigger: triggers:
- platform: state - entity_id: person.marcus_scholz
entity_id: person.marcus_scholz
to: home to: home
from: not_home from: not_home
condition: trigger: state
- condition: or conditions:
conditions:
- condition: sun
before: sunrise
before_offset: '+1'
- condition: sun
after_offset: '-1'
after: sunset
enabled: false
- condition: sun - condition: sun
before: sunrise before: sunrise
before_offset: '+1' before_offset: '+1'
after: sunset after: sunset
after_offset: '-1' after_offset: '-1'
action: actions:
- service: script.moodlight_orange_plasma - data: {}
data: {} action: script.moodlight_orange_plasma
- service: light.turn_on - target:
target:
device_id: device_id:
- 32d15eec63fe68d5770813d47da53657
- 53a27edf581fcf40f3bc8b253b1ee369 - 53a27edf581fcf40f3bc8b253b1ee369
data: {} - 5abbb43e5d015ee75c7c900240b4329e
data:
brightness_pct: 75
color_temp_kelvin: 2992
action: light.turn_on
mode: single mode: single
- id: '1648485179021' - id: '1648485179021'
alias: Schalte den Fernseher mit WoL ein alias: Schalte den Fernseher mit WoL ein
@@ -825,13 +827,20 @@
actions: actions:
- data: {} - data: {}
action: script.moodlight_xmas action: script.moodlight_xmas
- target:
device_id:
- 53a27edf581fcf40f3bc8b253b1ee369
- 5abbb43e5d015ee75c7c900240b4329e
data:
brightness_pct: 75
color_temp_kelvin: 2992
action: light.turn_on
- action: switch.turn_on - action: switch.turn_on
metadata: {} metadata: {}
data: {} data: {}
target: target:
device_id: device_id:
- 1f3c4b5de4aea99bac83688ceb22293b - 1f3c4b5de4aea99bac83688ceb22293b
- 48dafb7f4a8ed6ccbb046758cb660c23
mode: single mode: single
- id: '1700483035319' - id: '1700483035319'
alias: Licht bei Sonnenaufgang ausschalten (XMas) alias: Licht bei Sonnenaufgang ausschalten (XMas)
@@ -854,7 +863,7 @@
- 98a9eef603f8c8ae6200c4834a3dbf4f - 98a9eef603f8c8ae6200c4834a3dbf4f
- 32d15eec63fe68d5770813d47da53657 - 32d15eec63fe68d5770813d47da53657
- 9f42805af5b7e423023595390342b9ac - 9f42805af5b7e423023595390342b9ac
- 063e41329df7b29bbaa8df2f508ee6cb - 5abbb43e5d015ee75c7c900240b4329e
data: data:
transition: 2 transition: 2
action: light.turn_off action: light.turn_off
@@ -864,7 +873,6 @@
target: target:
device_id: device_id:
- 1f3c4b5de4aea99bac83688ceb22293b - 1f3c4b5de4aea99bac83688ceb22293b
- 48dafb7f4a8ed6ccbb046758cb660c23
mode: single mode: single
- id: '1701774106609' - id: '1701774106609'
alias: IKEA STYRBAR Wohnzimmer alias: IKEA STYRBAR Wohnzimmer
@@ -1328,3 +1336,30 @@
entity_id: a57a56132635ff48a6d2ae8df322b385 entity_id: a57a56132635ff48a6d2ae8df322b385
domain: switch domain: switch
mode: single mode: single
- id: '1771012833905'
alias: Bewegungssteuerung Flurlicht
description: ''
use_blueprint:
path: aledziko/ikea-myggspray-e2494-matter-motion-sensor.yaml
input:
motion_entity: binary_sensor.myggspray_wrlss_mtn_sensor_belegung
no_motion_wait: 0
illuminance_entity: sensor.myggspray_wrlss_mtn_sensor_beleuchtungsstarke
battery_entity: sensor.myggspray_wrlss_mtn_sensor_batterie
motion_on_action:
- action: light.turn_on
metadata: {}
target:
entity_id:
- light.schreibtisch_deko
data: {}
motion_off_action:
- action: light.turn_off
metadata: {}
target:
entity_id:
- light.schreibtisch_deko
data: {}
motion_cutoff: 10
illuminance_low_threshold: 10
battery_low_threshold: 20

View File

@@ -0,0 +1,232 @@
blueprint:
name: IKEA MYGGSPRAY E2494 Motion Sensor (Matter) v2.1
description: 'Full-featured automation for the IKEA MYGGSPRAY E2494 Matter motion
sensor. Supports independent actions for motion, illuminance (high/low), and battery
alerts. '
domain: automation
source_url: https://github.com/aledziko/HA-blueprints/blob/main/IKEA/Matter/ikea-myggspray-e2494/ikea-myggspray-e2494-matter-motion-sensor.yaml
author: aledziko
input:
motion_entity:
name: MYGGSPRAY Motion Sensor
description: Select the MYGGSPRAY motion sensor (binary_sensor).
selector:
entity:
filter:
- device_class:
- occupancy
domain:
- binary_sensor
- device_class:
- motion
domain:
- binary_sensor
reorder: false
multiple: false
use_time_window:
name: Enable Active Hours?
description: Restrict automation to a specific time window.
default: false
selector:
boolean: {}
active_start_time:
name: Active Start Time
description: Automation starts working at this time (if enabled).
default: 08:00:00
selector:
time: {}
active_end_time:
name: Active End Time
description: Automation stops working at this time (if enabled).
default: '22:00:00'
selector:
time: {}
no_motion_wait:
name: Wait time (Motion)
description: Time to wait after last motion is detected before running the "off"
action.
default: 120
selector:
number:
min: 0.0
max: 3600.0
unit_of_measurement: seconds
step: 1.0
mode: slider
motion_on_action:
name: 'Action: Motion Detected'
description: Run when motion is detected (and dark enough).
default: []
selector:
action: {}
motion_off_action:
name: 'Action: Motion Stopped'
description: Run after the sensor stops detecting motion and wait time elapsed.
default: []
selector:
action: {}
illuminance_entity:
name: (Optional) Illuminance Sensor
description: Select the light sensor (sensor.illuminance).
default: []
selector:
entity:
filter:
- domain:
- sensor
device_class:
- illuminance
reorder: false
multiple: false
motion_cutoff:
name: (Optional) Motion Light Cutoff
description: Only trigger "Motion Detected" action if LUX is BELOW this value
(0 to disable).
default: 0
selector:
number:
min: 0.0
max: 3000.0
unit_of_measurement: lux
step: 1.0
mode: slider
illuminance_high_threshold:
name: (Optional) Light High Threshold
description: Trigger "High Action" when LUX goes ABOVE this value (e.g. 500
lx).
default: 500
selector:
number:
min: 0.0
max: 3000.0
unit_of_measurement: lux
step: 1.0
mode: slider
high_action:
name: 'Action: Light High'
description: Run when light exceeds threshold (e.g. close curtains).
default: []
selector:
action: {}
illuminance_low_threshold:
name: (Optional) Light Low Threshold
description: Trigger "Low Action" when LUX goes BELOW this value (e.g. 5 lx).
default: 5
selector:
number:
min: 0.0
max: 3000.0
unit_of_measurement: lux
step: 1.0
mode: slider
low_action:
name: 'Action: Light Low'
description: Run when light drops below threshold (e.g. open curtains).
default: []
selector:
action: {}
battery_entity:
name: (Optional) Battery Sensor
description: Select the battery level sensor (sensor.battery).
default: []
selector:
entity:
filter:
- domain:
- sensor
device_class:
- battery
reorder: false
multiple: false
battery_low_threshold:
name: (Optional) Battery Low Level
description: Threshold for battery alert (%).
default: 30
selector:
number:
min: 0.0
max: 100.0
unit_of_measurement: '%'
step: 1.0
mode: slider
battery_low_action:
name: 'Action: Battery Low'
description: Run when battery drops below threshold.
default: []
selector:
action: {}
mode: parallel
max_exceeded: silent
trigger_variables:
motion_entity_input: !input motion_entity
illuminance_entity_input: !input illuminance_entity
motion_cutoff_input: !input motion_cutoff
high_threshold_input: !input illuminance_high_threshold
low_threshold_input: !input illuminance_low_threshold
battery_entity_input: !input battery_entity
battery_threshold_input: !input battery_low_threshold
use_time_window_input: !input use_time_window
triggers:
- trigger: state
entity_id: !input motion_entity
from: 'off'
to: 'on'
id: motion_on
- trigger: state
entity_id: !input motion_entity
from: 'on'
to: 'off'
for:
seconds: !input no_motion_wait
id: motion_off
- trigger: template
value_template: "{{ illuminance_entity_input != none and \n states(illuminance_entity_input)
| is_number and \n states(illuminance_entity_input) | float(0) > high_threshold_input
| float(100000) }}\n"
id: light_high
- trigger: template
value_template: "{{ illuminance_entity_input != none and \n states(illuminance_entity_input)
| is_number and \n states(illuminance_entity_input) | float(100000) < low_threshold_input
| float(-1) }}\n"
id: light_low
- trigger: template
value_template: "{{ battery_entity_input != none and \n states(battery_entity_input)
| is_number and \n states(battery_entity_input) | float(100) < battery_threshold_input
| float(-1) }}\n"
id: battery_low
condition:
- condition: or
conditions:
- condition: template
value_template: '{{ not use_time_window_input }}'
- condition: time
after: !input active_start_time
before: !input active_end_time
actions:
- choose:
- conditions:
- condition: trigger
id: motion_on
sequence:
- delay: 1.5
- condition: template
value_template: "{% set cutoff = motion_cutoff_input | float(0) %} {% if cutoff
== 0 %}\n true\n{% else %}\n {% set lux = states(illuminance_entity_input)
| float(-1) %}\n {{ lux == -1 or lux <= cutoff }}\n{% endif %}\n"
- sequence: !input motion_on_action
- conditions:
- condition: trigger
id: motion_off
sequence: !input motion_off_action
- conditions:
- condition: trigger
id: light_high
sequence: !input high_action
- conditions:
- condition: trigger
id: light_low
sequence: !input low_action
- conditions:
- condition: trigger
id: battery_low
sequence: !input battery_low_action

View File

@@ -1,283 +0,0 @@
substitutions:
name: "sleepingroom"
friendly_name: "Luftqualität Schlafzimmer"
esphome:
name: ${name}
friendly_name: ${friendly_name}
name_add_mac_suffix: false
project:
name: sensor.${name}
version: "1.0"
min_version: 2021.9.0
on_boot:
then:
- light.turn_on:
id: co2_light
red: 0%
green: 100%
blue: 9%
- delay: 1.5s
- light.turn_on:
id: co2_light
red: 100%
green: 75%
blue: 0%
- delay: 1.5s
- light.turn_on:
id: co2_light
red: 100%
green: 0%
blue: 0%
- delay: 1.5s
- light.turn_on:
id: co2_light
red: 100%
green: 75%
blue: 0%
- delay: 1.5s
- light.turn_on:
id: co2_light
red: 0%
green: 100%
blue: 9%
- text_sensor.template.publish:
id: co2_warn
state: "grün"
- text_sensor.template.publish:
id: pm25_warn
state: "grün"
esp32:
board: nodemcu-32s
framework:
type: esp-idf
wifi:
ssid: "Voltage-legacy"
password: !secret voltage_legacy_psk
use_address: ${name}.home
power_save_mode: high
fast_connect: on
min_auth_mode: WPA2
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Schlafzimmer Fallback Hotspot"
password: !secret fallback_psk
captive_portal:
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
encryption:
key: !secret apikey
# Enable over-the-air updates
ota:
platform: esphome
password: !secret ota
# Initialize I²C
i2c:
- id: bus_a
sda: 13
scl: 16
scan: true
# Initialize LEDC GPIOs
output:
- platform: ledc
pin: GPIO17
id: led_red
- platform: ledc
pin: GPIO18
id: led_green
max_power: 50%
- platform: ledc
pin: GPIO19
id: led_blue
# Define RGB mode for LED
light:
- platform: rgb
id: co2_light
name: "CO2 Status LED"
red: led_red
green: led_green
blue: led_blue
internal: true
# Initialize UART for Vindriktning sensor
uart:
id: uartPM
rx_pin: GPIO26
baud_rate: 9600
# Create text sensor to represent CO2 LED warn state (somewhat redundant)
text_sensor:
- platform: template
name: "Schlafzimmer CO2 Warnstufe"
id: co2_warn
- platform: template
name: "Schlafzimmer Feinstaub Warnstufe"
id: pm25_warn
sensor:
# WiFi signal strength
- platform: wifi_signal
name: "WiFi Signalstärke"
update_interval: 60s
# SCD30 CO2 + temperature + humidity sensor
# * air quality category 0: LED is purple, sensor needs calibration (<380ppm)
# • air quality category 1: LED is green (380-800ppm)
# • air quality category 2: LED is yellow (900-1200ppm)
# • air quality category 3: LED is orange/amber (1200 bis 1600ppm)
# • air quality category 4: LED is red (1600-2000ppm)
- platform: scd30
i2c_id: bus_a
co2:
name: "Schlafzimmer CO2"
id: co2_value
accuracy_decimals: 1
on_value_range:
- below: 380
then:
- text_sensor.template.publish:
id: co2_warn
state: "Kalibrierung nötig"
- light.turn_on:
id: co2_light
red: 75%
green: 0%
blue: 100%
- above: 380
below: 800
then:
- text_sensor.template.publish:
id: co2_warn
state: "grün"
- light.turn_on:
id: co2_light
red: 0%
green: 100%
blue: 0%
- above: 800
below: 1200
then:
- text_sensor.template.publish:
id: co2_warn
state: "gelb"
- light.turn_on:
id: co2_light
red: 100%
green: 100%
blue: 0%
- above: 1200
below: 1600
then:
- text_sensor.template.publish:
id: co2_warn
state: "orange"
- light.turn_on:
id: co2_light
red: 100%
green: 75%
blue: 0%
- above: 1600
then:
- text_sensor.template.publish:
id: co2_warn
state: "rot"
- light.turn_on:
id: co2_light
red: 100%
green: 0%
blue: 0%
temperature:
name: "Schlafzimmer Temperatur"
accuracy_decimals: 2
filters:
- offset: -2.5
humidity:
name: "Schlafzimmer Luftfeuchtigkeit"
accuracy_decimals: 1
# SCD30 temp sensor is a bit off
ambient_pressure_compensation: 1
automatic_self_calibration: True
address: 0x61
update_interval: 10s
# Vindriktning particulate matter sensor
- platform: pm1006
uart_id: uartPM
pm_2_5:
name: "Feinstaub PM 2.5µm"
on_value_range:
- above: 0
below: 35
then:
- text_sensor.template.publish:
id: pm25_warn
state: "grün"
- above: 35
below: 85
then:
- text_sensor.template.publish:
id: pm25_warn
state: "orange"
- above: 85
then:
- text_sensor.template.publish:
id: pm25_warn
state: "rot"
# Analog photo diode voltage
- platform: adc
pin: 32
name: "Spannung Photodiode"
attenuation: 12db
update_interval: 1s
internal: true
on_value_range:
- below: 0.25
then:
light.turn_on:
id: co2_light
brightness: 30%
- above: 0.5
then:
light.turn_on:
id: co2_light
brightness: 60%
# IR Receiver, dumps all received values into serial
remote_receiver:
pin:
number: 23
inverted: True
dump: all
# IR Transmitter
remote_transmitter:
non_blocking: True
pin: GPIO22
# Infrared remotes use a 50% carrier signal
carrier_duty_percent: 50%
# Temporary test switches
switch:
- platform: template
name: Yamaha Power Button
turn_on_action:
- remote_transmitter.transmit_nec:
address: 0x7E81
command: 0x54AB
- platform: template
name: Samsung Power Button
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E040BF
nbits: 32

View File

@@ -72,7 +72,8 @@
{% set waeschetrockner = states('sensor.waschetrockner_leistung') | float %} {% set waeschetrockner = states('sensor.waschetrockner_leistung') | float %}
{% set waschmaschine = states('sensor.waschmaschine_leistung') | float %} {% set waschmaschine = states('sensor.waschmaschine_leistung') | float %}
{% set arcade = states('sensor.arcade_automat_leistung') | float %} {% set arcade = states('sensor.arcade_automat_leistung') | float %}
{{ (total + solar - raumduft - keller - musik - bett - heimkino_sz - deko - schreibtisch - serverraum - heimkino_wz - spieleschrank - kuehlschrank - kaffeemaschine - waeschetrockner - waschmaschine - arcade) | round(1) }} {% set spuelmaschine = states('sensor.spulmaschine_leistung') | float %}
{{ (total + solar - raumduft - keller - musik - bett - heimkino_sz - deko - schreibtisch - serverraum - heimkino_wz - spieleschrank - kuehlschrank - kaffeemaschine - waeschetrockner - waschmaschine - arcade - spuelmaschine) | round(1) }}
device_class: power device_class: power
state_class: measurement state_class: measurement
attributes: attributes: