I have several newly installed Aqara lumi.sensor_magnet.aq2
sensors. I created two triggers, open and close. Each trigger starts a timer for either open or closed state.
When I open window, both open and close events seem to fire and both timers start.
When closing, only close trigger fires, starting the closed timer
I have tested multiple sensors with the same results. I do not see anything in the logs the would indicate both states were sent on open.
Any idea what is gong on here?
Automation
alias: win_test
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.dining_area_window_4
id: DA4-Open
from: "off"
to: "on"
alias: Trigger - Dining Area Window 4 Open
- platform: state
entity_id:
- binary_sensor.dining_area_window_4
from: "on"
to: "off"
id: DA4-Closed
alias: Trigger - Dining Area Window 4 Closed
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: DA4-Open
alias: On Open Trigger
sequence:
- service: timer.start
data: {}
target:
entity_id: timer.windows_state_open
alias: Start Window Open Timer
- conditions:
- condition: trigger
id: DA4-Closed
alias: On Closed Trigger
sequence:
- service: timer.start
data: {}
target:
entity_id: timer.windows_state_closed
alias: Start Window Closed Timer
mode: single
Timer for open
windows_state_open:
name: Window Open 2 Minutes
duration: "00:02:00"
icon: mdi:timer
restore: true
Timer for closed
windows_state_closed:
name: Window Closed 2 Minutes
duration: "00:02:00"
icon: mdi:timer
restore: true
Trace for open
{
"trace": {
"last_step": "action/0/choose/0/sequence/0",
"run_id": "ffa0b59071cba7d77f52d360306449e8",
"state": "stopped",
"script_execution": "finished",
"timestamp": {
"start": "2023-04-23T20:45:05.144544+00:00",
"finish": "2023-04-23T20:45:05.167177+00:00"
},
"domain": "automation",
"item_id": "1682280204952",
"trigger": "state of binary_sensor.dining_area_window_4",
"trace": {
"trigger/0": [
{
"path": "trigger/0",
"timestamp": "2023-04-23T20:45:05.144754+00:00",
"changed_variables": {
"this": {
"entity_id": "automation.win_test",
"state": "on",
"attributes": {
"last_triggered": "2023-04-23T20:45:04.994425+00:00",
"mode": "single",
"current": 0,
"id": "1682280204952",
"friendly_name": "win_test"
},
"last_changed": "2023-04-23T20:36:16.098418+00:00",
"last_updated": "2023-04-23T20:45:05.018860+00:00",
"context": {
"id": "01GYQXSW319A8Q3RPBMR2CH8CF",
"parent_id": "01GYQXSW2TTVXDMMG1GXGT1H2G",
"user_id": null
}
},
"trigger": {
"id": "DA4-Open",
"idx": "0",
"alias": "Trigger - Dining Area Window 4 Open",
"platform": "state",
"entity_id": "binary_sensor.dining_area_window_4",
"from_state": {
"entity_id": "binary_sensor.dining_area_window_4",
"state": "off",
"attributes": {
"device_class": "window",
"friendly_name": "Dining Area Window 4",
"icon": "fapro:brands/windows"
},
"last_changed": "2023-04-23T20:45:04.986704+00:00",
"last_updated": "2023-04-23T20:45:04.986704+00:00",
"context": {
"id": "01GYQXSW2TTVXDMMG1GXGT1H2G",
"parent_id": null,
"user_id": null
}
},
"to_state": {
"entity_id": "binary_sensor.dining_area_window_4",
"state": "on",
"attributes": {
"device_class": "window",
"friendly_name": "Dining Area Window 4",
"icon": "fapro:brands/windows"
},
"last_changed": "2023-04-23T20:45:05.130088+00:00",
"last_updated": "2023-04-23T20:45:05.130088+00:00",
"context": {
"id": "01GYQXSW7ADSR49XMD4DH2K8F5",
"parent_id": null,
"user_id": null
}
},
"for": null,
"attribute": null,
"description": "state of binary_sensor.dining_area_window_4"
}
}
}
],
"action/0": [
{
"path": "action/0",
"timestamp": "2023-04-23T20:45:05.148937+00:00",
"changed_variables": {
"context": {
"id": "01GYQXSW7R8XA30HMF8GFEDYEY",
"parent_id": "01GYQXSW7ADSR49XMD4DH2K8F5",
"user_id": null
}
},
"result": {
"choice": 0
}
}
],
"action/0/choose/0": [
{
"path": "action/0/choose/0",
"timestamp": "2023-04-23T20:45:05.149130+00:00",
"result": {
"result": true
}
}
],
"action/0/choose/0/conditions/0": [
{
"path": "action/0/choose/0/conditions/0",
"timestamp": "2023-04-23T20:45:05.149205+00:00",
"result": {
"result": true
}
}
],
"action/0/choose/0/sequence/0": [
{
"path": "action/0/choose/0/sequence/0",
"timestamp": "2023-04-23T20:45:05.151772+00:00",
"result": {
"params": {
"domain": "timer",
"service": "start",
"service_data": {},
"target": {
"entity_id": [
"timer.windows_state_open"
]
}
},
"running_script": false,
"limit": 10
}
}
]
},
"config": {
"id": "1682280204952",
"alias": "win_test",
"description": "",
"trigger": [
{
"platform": "state",
"entity_id": [
"binary_sensor.dining_area_window_4"
],
"id": "DA4-Open",
"from": "off",
"to": "on",
"alias": "Trigger - Dining Area Window 4 Open"
},
{
"platform": "state",
"entity_id": [
"binary_sensor.dining_area_window_4"
],
"from": "on",
"to": "off",
"id": "DA4-Closed",
"alias": "Trigger - Dining Area Window 4 Closed"
}
],
"condition": [],
"action": [
{
"choose": [
{
"conditions": [
{
"condition": "trigger",
"id": "DA4-Open",
"alias": "On Open Trigger"
}
],
"sequence": [
{
"service": "timer.start",
"data": {},
"target": {
"entity_id": "timer.windows_state_open"
},
"alias": "Start Window Open Timer"
}
]
},
{
"conditions": [
{
"condition": "trigger",
"id": "DA4-Closed",
"alias": "On Closed Trigger"
}
],
"sequence": [
{
"service": "timer.start",
"data": {},
"target": {
"entity_id": "timer.windows_state_closed"
},
"alias": "Start Window Closed Timer"
}
]
}
]
}
],
"mode": "single"
},
"blueprint_inputs": null,
"context": {
"id": "01GYQXSW7R8XA30HMF8GFEDYEY",
"parent_id": "01GYQXSW7ADSR49XMD4DH2K8F5",
"user_id": null
}
},
"logbookEntries": [
{
"name": "win_test",
"message": "triggered by state of binary_sensor.dining_area_window_4",
"source": "state of binary_sensor.dining_area_window_4",
"entity_id": "automation.win_test",
"context_id": "01GYQXSW7R8XA30HMF8GFEDYEY",
"when": 1682282705.145026,
"domain": "automation"
}
]
}
Trace for closed
{
"trace": {
"last_step": "action/0/choose/1/sequence/0",
"run_id": "1b09c368f704a814e1f1913117f9d4f7",
"state": "stopped",
"script_execution": "finished",
"timestamp": {
"start": "2023-04-23T20:46:30.117579+00:00",
"finish": "2023-04-23T20:46:30.139441+00:00"
},
"domain": "automation",
"item_id": "1682280204952",
"trigger": "state of binary_sensor.dining_area_window_4",
"trace": {
"trigger/1": [
{
"path": "trigger/1",
"timestamp": "2023-04-23T20:46:30.117775+00:00",
"changed_variables": {
"this": {
"entity_id": "automation.win_test",
"state": "on",
"attributes": {
"last_triggered": "2023-04-23T20:45:05.145099+00:00",
"mode": "single",
"current": 0,
"id": "1682280204952",
"friendly_name": "win_test"
},
"last_changed": "2023-04-23T20:36:16.098418+00:00",
"last_updated": "2023-04-23T20:45:05.164020+00:00",
"context": {
"id": "01GYQXSW7R8XA30HMF8GFEDYEY",
"parent_id": "01GYQXSW7ADSR49XMD4DH2K8F5",
"user_id": null
}
},
"trigger": {
"id": "DA4-Closed",
"idx": "1",
"alias": "Trigger - Dining Area Window 4 Closed",
"platform": "state",
"entity_id": "binary_sensor.dining_area_window_4",
"from_state": {
"entity_id": "binary_sensor.dining_area_window_4",
"state": "on",
"attributes": {
"device_class": "window",
"friendly_name": "Dining Area Window 4",
"icon": "fapro:brands/windows"
},
"last_changed": "2023-04-23T20:45:05.130088+00:00",
"last_updated": "2023-04-23T20:45:05.130088+00:00",
"context": {
"id": "01GYQXSW7ADSR49XMD4DH2K8F5",
"parent_id": null,
"user_id": null
}
},
"to_state": {
"entity_id": "binary_sensor.dining_area_window_4",
"state": "off",
"attributes": {
"device_class": "window",
"friendly_name": "Dining Area Window 4",
"icon": "fapro:brands/windows"
},
"last_changed": "2023-04-23T20:46:30.108093+00:00",
"last_updated": "2023-04-23T20:46:30.108093+00:00",
"context": {
"id": "01GYQXWF6WYC0YBNCH3ASRAZE6",
"parent_id": null,
"user_id": null
}
},
"for": null,
"attribute": null,
"description": "state of binary_sensor.dining_area_window_4"
}
}
}
],
"action/0": [
{
"path": "action/0",
"timestamp": "2023-04-23T20:46:30.122008+00:00",
"changed_variables": {
"context": {
"id": "01GYQXWF755HFNRXZ88JJH49GM",
"parent_id": "01GYQXWF6WYC0YBNCH3ASRAZE6",
"user_id": null
}
},
"result": {
"choice": 1
}
}
],
"action/0/choose/0": [
{
"path": "action/0/choose/0",
"timestamp": "2023-04-23T20:46:30.122205+00:00",
"result": {
"result": false
}
}
],
"action/0/choose/0/conditions/0": [
{
"path": "action/0/choose/0/conditions/0",
"timestamp": "2023-04-23T20:46:30.122280+00:00",
"result": {
"result": false
}
}
],
"action/0/choose/1": [
{
"path": "action/0/choose/1",
"timestamp": "2023-04-23T20:46:30.122409+00:00",
"result": {
"result": true
}
}
],
"action/0/choose/1/conditions/0": [
{
"path": "action/0/choose/1/conditions/0",
"timestamp": "2023-04-23T20:46:30.122470+00:00",
"result": {
"result": true
}
}
],
"action/0/choose/1/sequence/0": [
{
"path": "action/0/choose/1/sequence/0",
"timestamp": "2023-04-23T20:46:30.124695+00:00",
"result": {
"params": {
"domain": "timer",
"service": "start",
"service_data": {},
"target": {
"entity_id": [
"timer.windows_state_closed"
]
}
},
"running_script": false,
"limit": 10
}
}
]
},
"config": {
"id": "1682280204952",
"alias": "win_test",
"description": "",
"trigger": [
{
"platform": "state",
"entity_id": [
"binary_sensor.dining_area_window_4"
],
"id": "DA4-Open",
"from": "off",
"to": "on",
"alias": "Trigger - Dining Area Window 4 Open"
},
{
"platform": "state",
"entity_id": [
"binary_sensor.dining_area_window_4"
],
"from": "on",
"to": "off",
"id": "DA4-Closed",
"alias": "Trigger - Dining Area Window 4 Closed"
}
],
"condition": [],
"action": [
{
"choose": [
{
"conditions": [
{
"condition": "trigger",
"id": "DA4-Open",
"alias": "On Open Trigger"
}
],
"sequence": [
{
"service": "timer.start",
"data": {},
"target": {
"entity_id": "timer.windows_state_open"
},
"alias": "Start Window Open Timer"
}
]
},
{
"conditions": [
{
"condition": "trigger",
"id": "DA4-Closed",
"alias": "On Closed Trigger"
}
],
"sequence": [
{
"service": "timer.start",
"data": {},
"target": {
"entity_id": "timer.windows_state_closed"
},
"alias": "Start Window Closed Timer"
}
]
}
]
}
],
"mode": "single"
},
"blueprint_inputs": null,
"context": {
"id": "01GYQXWF755HFNRXZ88JJH49GM",
"parent_id": "01GYQXWF6WYC0YBNCH3ASRAZE6",
"user_id": null
}
},
"logbookEntries": [
{
"name": "win_test",
"message": "triggered by state of binary_sensor.dining_area_window_4",
"source": "state of binary_sensor.dining_area_window_4",
"entity_id": "automation.win_test",
"context_id": "01GYQXWF755HFNRXZ88JJH49GM",
"when": 1682282790.118,
"domain": "automation"
},
{
"when": 1682282790.126901,
"state": "active",
"entity_id": "timer.windows_state_closed",
"icon": "mdi:timer",
"context_event_type": "automation_triggered",
"context_domain": "automation",
"context_name": "win_test",
"context_message": "triggered by state of binary_sensor.dining_area_window_4",
"context_source": "state of binary_sensor.dining_area_window_4",
"context_entity_id": "automation.win_test"
}
]
}