Skip to content

Commit ea43c5d

Browse files
committed
Adds automations examples.
1 parent 0096b7e commit ea43c5d

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

automations/add_to_cart.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
alias: Scan Barcode to Add to Cart
2+
description: Adds product to Rohlik.cz cart based on scanned barcode
3+
triggers:
4+
- entity_id: sensor.atom_qrcode_scanner_barcode_scanner # Entity name for the barcode scanner
5+
trigger: state
6+
actions:
7+
- action: shell_command.lookup_product_id # Looks up product ID based on barcode, you need to add this command in your Home Assistant configuration (see configuration.yaml)
8+
data:
9+
barcode: "{{ scanned_barcode }}"
10+
response_variable: product_lookup
11+
- if:
12+
- condition: template
13+
value_template: >-
14+
{{ product_lookup['stdout'] != 'unknown' and product_lookup['stdout']
15+
!= 'null' }}
16+
then:
17+
- action: shell_command.lookup_product_name # Looks up product name based on barcode, you need to add this command in your Home Assistant configuration (see configuration.yaml)
18+
data:
19+
barcode: "{{ scanned_barcode }}"
20+
response_variable: name_lookup
21+
- action: rohlikcz.add_to_cart # Calls action to add product to cart
22+
metadata: {}
23+
data:
24+
product_id: "{{ int(product_lookup['stdout']) }}"
25+
quantity: 1
26+
config_entry_id: XXXXXXXXXXXXXXXX # Replace with your Rohlik.cz config entry ID
27+
response_variable: cart_response
28+
- action: tts.speak # Announces successful addition to cart (optional, you may remove this if not needed)
29+
metadata: {}
30+
data:
31+
cache: true
32+
media_player_entity_id: media_player.xxxxxxxxxxxx # Replace with your media player entity ID
33+
message: Přidala jsem do košíku položku {{name_lookup['stdout'] }}.
34+
language: cs
35+
target:
36+
entity_id: tts.elevenlabs
37+
else:
38+
- action: tts.speak # Announces failure to find product (optional, you may remove this if not needed)
39+
metadata: {}
40+
data:
41+
cache: true
42+
media_player_entity_id: media_player.xxxxxxxxxxx # Replace with your media player entity ID
43+
message: Omlouvám se, ale tento výrobek nemám v databázi.
44+
language: cs
45+
target:
46+
entity_id: tts.elevenlabs # Replace with your TTS entity ID
47+
mode: parallel
48+
max: 10
49+
variables:
50+
scanned_barcode: "{{ trigger.to_state.state }}"

automations/update_data.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
alias: Update Barcode Mapping File
2+
description: Download updated barcode mapping from GitHub
3+
triggers:
4+
- at: "03:00:00" # Runs daily at 3 AM
5+
trigger: time
6+
- event: start # Runs on Home Assistant startup
7+
trigger: homeassistant
8+
actions:
9+
- action: shell_command.download_barcode_mapping # Downloads the barcode mapping file from GitHub, you need to add this command in your Home Assistant configuration (see configuration.yaml)
10+
data: {}
11+
- delay:
12+
seconds: 3
13+
- action: persistent_notification.create # Creates a notification about the update (optional)
14+
data:
15+
title: Product list updated
16+
message: Product list file updated at {{ now().strftime('%Y-%m-%d %H:%M') }}
17+
mode: single

0 commit comments

Comments
 (0)