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