-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-automation.yaml
35 lines (35 loc) · 1.34 KB
/
example-automation.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
alias: "Example Barcode Automation"
description: "An example automation that demonstrates how to trigger on the HA event fired by the ESPHome barcode scanner, passing the barcode to the python script to lookup the product and if its found adding the product to a HA to-do list. It also posts back the product to the ESPHome device for display on a screen."
triggers:
- trigger: event
event_type: esphome.barcode_scan
conditions: []
actions:
- action: pyscript.barcode_lookup
metadata: {}
data:
barcode: "{{ trigger.event.data.barcode }}"
response_variable: product
enabled: true
- action: esphome.barcode_scanner_product_identified
metadata: {}
data:
product: >-
{% if product.result == 'success' %}{% if product.brand | length >0
%}{{product.brand}} {% endif %}{{product.title}} {% else %}Unknown{%
endif %}
- alias: If the barcode was found
if:
- condition: template
value_template: "{% if product.result == \"success\" %}true{% endif %}"
then:
- action: todo.add_item
metadata: {}
data:
item: >-
{% if product.result == 'success' %}{% if product.brand | length >0
%}{{product.brand}} {% endif %}{{product.title}}{% endif %}
target:
entity_id: todo.mealie_supermarket
enabled: true
mode: single