i’m trying to get an automation to work, but HA is failing a condition that clearly should be true – at least it looks like it to me. the 4th condition should be true. i’ve included the automation yaml, input json and the trace diagostics. anyone with an idea what is happening?
alias: test3
description: ""
trigger:
- platform: mqtt
topic: test
payload: front_gate
value_template: "{{ value_json[\"after\"][\"camera\"] }}"
variables:
id: "{{trigger.payload_json[\"after\"][\"id\"]}}"
label: "{{ trigger.payload_json[\"after\"][\"label\"] }}"
camera: "{{ trigger.payload_json[\"after\"][\"camera\"] }}"
condition:
- condition: and
conditions:
- condition: template
value_template: "{{ trigger.payload_json['after']['label'] == 'car' }}"
- condition: template
value_template: "{{'gate_exit_1' in trigger.payload_json['before']['entered_zones']}}"
- condition: template
value_template: >-
{{not 'gate_exit_2' in
trigger.payload_json['before']['entered_zones']}}
- condition: template
value_template: "\"{{'gate_exit_2' in trigger.payload_json['after']['entered_zones']}}\""
action:
- service: notify.gmail_notifier
data:
message: Car Leaving
title: Car Leaving
trace:
stored_traces: 50
mode: single
{
"before": {
"id": "1680829210.535921-tfy6lp",
"camera": "front_gate",
"frame_time": 1680829211.739332,
"snapshot_time": 1680829210.739683,
"label": "car",
"sub_label": null,
"top_score": 0.9425756335258484,
"false_positive": false,
"start_time": 1680829210.535921,
"end_time": null,
"score": 0.9425756335258484,
"box": [870, 326, 1529, 796],
"area": 309730,
"ratio": 1.402127659574468,
"region": [548, 0, 1676, 1128],
"stationary": false,
"motionless_count": 0,
"position_changes": 1,
"current_zones": ["gate_road", "gate_exit_1"],
"entered_zones": ["gate_house", "gate_exit_1", "gate_road"],
"has_clip": true,
"has_snapshot": true
},
"after": {
"id": "1680829210.535921-tfy6lp",
"camera": "front_gate",
"frame_time": 1680829212.139581,
"snapshot_time": 1680829210.739683,
"label": "car",
"sub_label": null,
"top_score": 0.9454288482666016,
"false_positive": false,
"start_time": 1680829210.535921,
"end_time": null,
"score": 0.9351314902305603,
"box": [1085, 341, 1648, 729],
"area": 218444,
"ratio": 1.4510309278350515,
"region": [875, 154, 1699, 978],
"stationary": false,
"motionless_count": 0,
"position_changes": 1,
"current_zones": ["gate_road", "gate_exit_2"],
"entered_zones": ["gate_house", "gate_exit_1", "gate_road", "gate_exit_2"],
"has_clip": true,
"has_snapshot": true
},
"type": "update"
}
this:
entity_id: automation.test3
state: 'on'
attributes:
last_triggered: '2023-04-03T18:28:13.946546+00:00'
mode: single
current: 0
id: '1680621739906'
friendly_name: test3
last_changed: '2023-04-07T14:55:03.673199+00:00'
last_updated: '2023-04-07T14:55:03.673199+00:00'
context:
id: 01GXE3DEZS1NG5N6BJPWYWZQYH
parent_id: null
user_id: null
trigger:
id: '0'
idx: '0'
alias: null
platform: mqtt
topic: test
payload: "{\"before\": {\"id\": \"1680829210.535921-tfy6lp\",\"camera\": \"front_gate\",\"frame_time\": 1680829211.739332,\"snapshot_time\": 1680829210.739683,\"label\": \"car\",\"sub_label\": null,\"top_score\": 0.9425756335258484,\"false_positive\": false,\"start_time\": 1680829210.535921,\"end_time\": null,\"score\": 0.9425756335258484,\"box\": [870, 326, 1529, 796],\"area\": 309730,\"ratio\": 1.402127659574468,\"region\": [548, 0, 1676, 1128],\"stationary\": false,\"motionless_count\": 0,\"position_changes\": 1,\"current_zones\": [\"gate_road\", \"gate_exit_1\"],\"entered_zones\": [\"gate_house\", \"gate_exit_1\", \"gate_road\"],\"has_clip\": true,\"has_snapshot\": true},\"after\": {\"id\": \"1680829210.535921-tfy6lp\",\"camera\": \"front_gate\",\"frame_time\": 1680829212.139581,\"snapshot_time\": 1680829210.739683,\"label\": \"car\",\"sub_label\": null,\"top_score\": 0.9454288482666016,\"false_positive\": false,\"start_time\": 1680829210.535921,\"end_time\": null,\"score\": 0.9351314902305603,\"box\": [1085, 341, 1648, 729],\"area\": 218444,\"ratio\": 1.4510309278350515,\"region\": [875, 154, 1699, 978],\"stationary\": false,\"motionless_count\": 0,\"position_changes\": 1,\"current_zones\": [\"gate_road\", \"gate_exit_2\"],\"entered_zones\": [\"gate_house\", \"gate_exit_1\", \"gate_road\", \"gate_exit_2\"],\"has_clip\": true,\"has_snapshot\": true},\"type\": \"update\"}\r\n"
qos: 0
description: mqtt topic test
payload_json:
before:
id: 1680829210.535921-tfy6lp
camera: front_gate
frame_time: 1680829211.739332
snapshot_time: 1680829210.739683
label: car
sub_label: null
top_score: 0.9425756335258484
false_positive: false
start_time: 1680829210.535921
end_time: null
score: 0.9425756335258484
box:
- 870
- 326
- 1529
- 796
area: 309730
ratio: 1.402127659574468
region:
- 548
- 0
- 1676
- 1128
stationary: false
motionless_count: 0
position_changes: 1
current_zones:
- gate_road
- gate_exit_1
entered_zones:
- gate_house
- gate_exit_1
- gate_road
has_clip: true
has_snapshot: true
after:
id: 1680829210.535921-tfy6lp
camera: front_gate
frame_time: 1680829212.139581
snapshot_time: 1680829210.739683
label: car
sub_label: null
top_score: 0.9454288482666016
false_positive: false
start_time: 1680829210.535921
end_time: null
score: 0.9351314902305603
box:
- 1085
- 341
- 1648
- 729
area: 218444
ratio: 1.4510309278350515
region:
- 875
- 154
- 1699
- 978
stationary: false
motionless_count: 0
position_changes: 1
current_zones:
- gate_road
- gate_exit_2
entered_zones:
- gate_house
- gate_exit_1
- gate_road
- gate_exit_2
has_clip: true
has_snapshot: true
type: update
id: 1680829210.535921-tfy6lp
label: car
camera: front_gate
Executed: April 7, 2023 at 7:55:39 AM
Result:
result: false
conditions/0
Executed: April 7, 2023 at 7:55:39 AM
Result:
result: true
entities: []
conditions/1
Executed: April 7, 2023 at 7:55:39 AM
Result:
result: true
entities: []
conditions/2
Executed: April 7, 2023 at 7:55:39 AM
Result:
result: true
entities: []
conditions/3
Executed: April 7, 2023 at 7:55:39 AM
Result:
result: false
entities: []
Triggered by the mqtt topic test at April 7, 2023 at 7:55:39 AM
Test if 4 conditions match
Stopped because a condition failed at April 7, 2023 at 7:55:39 AM (runtime: 0.00 seconds)