67 lines
2.0 KiB
YAML
67 lines
2.0 KiB
YAML
- alias: Scan Barcode to Add to Cart
|
|
description: Adds product to Rohlik.cz cart based on scanned barcode
|
|
triggers:
|
|
- entity_id: sensor.atom_qrcode_scanner_barcode_scanner
|
|
trigger: state
|
|
actions:
|
|
- action: shell_command.lookup_product_id
|
|
data:
|
|
barcode: '{{ scanned_barcode }}'
|
|
response_variable: product_lookup
|
|
- if:
|
|
- condition: template
|
|
value_template: '{{ product_lookup[''stdout''] != ''unknown'' and product_lookup[''stdout'']
|
|
!= ''null'' }}'
|
|
then:
|
|
- action: shell_command.lookup_product_name
|
|
data:
|
|
barcode: '{{ scanned_barcode }}'
|
|
response_variable: name_lookup
|
|
- action: rohlikcz.add_to_cart
|
|
metadata: {}
|
|
data:
|
|
product_id: '{{ int(product_lookup[''stdout'']) }}'
|
|
quantity: 1
|
|
config_entry_id: XXXXXXXXXXXXXXXX
|
|
response_variable: cart_response
|
|
- action: tts.speak
|
|
metadata: {}
|
|
data:
|
|
cache: true
|
|
media_player_entity_id: media_player.xxxxxxxxxxxx
|
|
message: Přidala jsem do košíku položku {{name_lookup['stdout'] }}.
|
|
language: cs
|
|
target:
|
|
entity_id: tts.elevenlabs
|
|
else:
|
|
- action: tts.speak
|
|
metadata: {}
|
|
data:
|
|
cache: true
|
|
media_player_entity_id: media_player.xxxxxxxxxxx
|
|
message: Omlouvám se, ale tento výrobek nemám v databázi.
|
|
language: cs
|
|
target:
|
|
entity_id: tts.elevenlabs
|
|
mode: parallel
|
|
max: 10
|
|
variables:
|
|
scanned_barcode: '{{ trigger.to_state.state }}'
|
|
- alias: Update Barcode Mapping File
|
|
description: Download updated barcode mapping from GitHub
|
|
triggers:
|
|
- at: 03:00:00
|
|
trigger: time
|
|
- event: start
|
|
trigger: homeassistant
|
|
actions:
|
|
- action: shell_command.download_barcode_mapping
|
|
data: {}
|
|
- delay:
|
|
seconds: 3
|
|
- action: persistent_notification.create
|
|
data:
|
|
title: Product list updated
|
|
message: Product list file updated at {{ now().strftime('%Y-%m-%d %H:%M') }}
|
|
mode: single
|