Created
July 11, 2025 06:18
-
-
Save peyanski/af4d4fa7e296ae851c38a094b8789663 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is OPTIONAL, you can comment the next 2 lines below if you don't want web servre | |
web_server: | |
port: 80 | |
i2c: | |
sda: 21 | |
scl: 22 | |
scan: true | |
sensor: | |
- platform: bmp3xx_i2c | |
temperature: | |
name: "Room Temperature" | |
oversampling: 32x | |
pressure: | |
name: "Room Pressure" | |
id: room_pressure | |
iir_filter: 32x | |
update_interval: 2s | |
text_sensor: | |
- platform: template | |
name: "Pressure Status" | |
id: pressure_status | |
binary_sensor: | |
- platform: template | |
name: "Pressure Change Event" | |
id: pressure_event | |
device_class: opening | |
interval: | |
- interval: 2s | |
then: | |
- lambda: |- | |
static float last = 0.0; | |
static int consecutive_changes = 0; | |
float current = id(room_pressure).state; | |
float delta = current - last; | |
last = current; | |
if (abs(delta) >= 0.0009) { | |
consecutive_changes += 1; | |
} else { | |
consecutive_changes = 0; | |
} | |
if (consecutive_changes >= 2) { | |
id(pressure_event).publish_state(true); | |
id(pressure_status).publish_state("Event Detected"); | |
} else { | |
id(pressure_event).publish_state(false); | |
id(pressure_status).publish_state("Stable"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment