I have a UniFi AI Pro camera located at my gate to detect license plates entering my property. However, my automation is triggered twice: once for a detected plate and again when the state changes to ‘Clear.’ I’ve tried changing the trigger from ‘Clear’ to ‘Any state,’ but I don’t receive any triggers at all. Ideally, I’d like the automation to trigger only once when any license plate is detected. Any help would be appreciated. Thank you.
Post you automation config yaml.
You can set the state to trigger on detect add/or add a condition if the state is clear.
condition:
- condition: not
conditions:
- condition: state
entity_id: "front gate license plate entity"
state: "Clear" (case sensitive)
Here is my yaml.
alias: Plate Detected All Outside Gate
description: Send to Telegram
trigger:
- platform: state
entity_id:
- sensor.front_gate_outside_license_plate_detected
to: null
condition: []
action:
- service: telegram_bot.send_photo
metadata: {}
data:
authentication: digest
caption: "Delmar Notification: Any License Plate Detected!! Front Gate Outside"
url: http://192.168.3.210:5000/api/Front_Gate_Outside/latest.jpg?fps=10&h=720
mode: single
are you choosing “clear” from the ui? or are you specifying “clear” in yaml? for my motion binary_sensor, the friendly name is “clear” but the corresponding real state is “off”… so the yaml needs to be “off”. if you’re doing it all in the ui, then it’ll figure this out for you.
i would remove your “to” state and add:
not_to: "off"
to your trigger block… with the presumption that you never want to get notified when things go to ‘clear’/off .
you’ll need to do this in yaml mode. so it’s important to get the right underlying value, not the friendly name.
i’m guessing a bit… if this doesn’t work for you, please go to the history of this entity and post what that history looks like.
my post crossed yours. how about the below. best to fix the “not_to” to be correct, however since you can have multiple, i threw in different permutations…
alias: Plate Detected All Outside Gate
description: Send to Telegram
trigger:
- platform: state
entity_id:
- sensor.front_gate_outside_license_plate_detected
not_to:
- "off"
- "clear"
- "Clear"
condition: []
action:
- service: telegram_bot.send_photo
metadata: {}
data:
authentication: digest
caption: "Delmar Notification: Any License Plate Detected!! Front Gate Outside"
url: http://192.168.3.210:5000/api/Front_Gate_Outside/latest.jpg?fps=10&h=720
mode: single
fixed per edwin_d… teach me to make last sec mods.
What is the state history for “sensor.front_gate_outside_license_plate_detected”
This should be:
not_to:
- "off"
- "clear"
- "Clear"
History shows translated states, you should look in developer tools for the real value.
Yes, click on more info and check the state history.
I don’t have a Unifi AI, but it should look similar to the image below with variable states.
Ok, now check the state history for License Plate Detected
Just noticed the log, you can use any of the initial suggestions posted earlier by me or @armedad
Try it like this.
alias: Plate Detected All Outside Gate
description: Send to Telegram
trigger:
- platform: state
entity_id:
- sensor.front_gate_outside_license_plate_detected
condition:
- condition: not
conditions:
- condition: state
entity_id: sensor.front_gate_outside_license_plate_detected
state: "Clear"
action:
- service: telegram_bot.send_photo
metadata: {}
data:
authentication: digest
caption: "Delmar Notification: Any License Plate Detected!! Front Gate Outside"
url: http://192.168.3.210:5000/api/Front_Gate_Outside/latest.jpg?fps=10&h=720
mode: single
I found this unifiprotect_blueprint, and they have the trigger configure like this.
trigger:
- platform: state
entity_id: !input licenseplate_sensor
from: "none"
not_to: "unavailable"
I will give this a try also.
Thank you Coolie1101, and Everyone
Still curious as to the state history for License Plate Detected sensor though
Then the blueprint is correct.