|
| 1 | +# LLM Vision test package: checks the garage camera for garbage cans in the upper-right corner. |
| 2 | +# Trigger with input_button.llmvision_garbage_check to update input_boolean.garbage_cans_in. |
| 3 | + |
| 4 | +input_button: |
| 5 | + llmvision_garbage_check: |
| 6 | + name: "LLM Vision: Garage cans check" |
| 7 | + icon: mdi:delete-variant |
| 8 | + |
| 9 | +input_boolean: |
| 10 | + garbage_cans_in: |
| 11 | + name: "Garbage cans in upper right" |
| 12 | + icon: mdi:trash-can |
| 13 | + |
| 14 | +input_text: |
| 15 | + llmvision_garbage_last_response: |
| 16 | + name: "LLM Vision garage response" |
| 17 | + max: 255 |
| 18 | + llmvision_garbage_last_keyframe: |
| 19 | + name: "LLM Vision garage key frame" |
| 20 | + max: 255 |
| 21 | + |
| 22 | +input_datetime: |
| 23 | + llmvision_garbage_last_run: |
| 24 | + name: "LLM Vision garage last run" |
| 25 | + has_date: true |
| 26 | + has_time: true |
| 27 | + |
| 28 | +template: |
| 29 | + - binary_sensor: |
| 30 | + - name: "Garbage cans in" |
| 31 | + unique_id: llmvision_garbage_cans_in |
| 32 | + device_class: presence |
| 33 | + state: "{{ is_state('input_boolean.garbage_cans_in', 'on') }}" |
| 34 | + attributes: |
| 35 | + last_run: "{{ states('input_datetime.llmvision_garbage_last_run') }}" |
| 36 | + last_response: "{{ states('input_text.llmvision_garbage_last_response') }}" |
| 37 | + last_key_frame: "{{ states('input_text.llmvision_garbage_last_keyframe') }}" |
| 38 | + source_camera: camera.garagecam |
| 39 | + |
| 40 | +automation: |
| 41 | + - alias: LLM Vision - Garage cans upper right |
| 42 | + id: d88a2e6d-78f3-4bb7-9d9f-c4d06e6eb5a9 |
| 43 | + mode: restart |
| 44 | + trigger: |
| 45 | + - platform: state |
| 46 | + entity_id: input_button.llmvision_garbage_check |
| 47 | + variables: |
| 48 | + prompt_text: > |
| 49 | + Examine ONLY the upper-right quadrant of the image (top half + right half). Ignore everything else (car, floor text, door, bikes, bottles, bags). If you see a black garbage can in that upper-right quadrant, respond exactly "on". If none are present there, respond exactly "off". Do not add any other words. |
| 50 | + action: |
| 51 | + - service: llmvision.data_analyzer |
| 52 | + response_variable: llmvision_result |
| 53 | + data: |
| 54 | + provider: !secret llmvision_provider_entry |
| 55 | + model: gpt-4o-mini |
| 56 | + message: "{{ prompt_text }}" |
| 57 | + sensor_entity: input_boolean.garbage_cans_in |
| 58 | + image_entity: |
| 59 | + - camera.garagecam |
| 60 | + include_filename: false |
| 61 | + target_width: 1280 |
| 62 | + max_tokens: 16 |
| 63 | + expose_images: true |
| 64 | + - service: input_text.set_value |
| 65 | + target: |
| 66 | + entity_id: input_text.llmvision_garbage_last_response |
| 67 | + data: |
| 68 | + value: "{{ (llmvision_result.response_text | default('unknown'))[:250] }}" |
| 69 | + - choose: |
| 70 | + - conditions: "{{ llmvision_result is defined and llmvision_result.key_frame is defined }}" |
| 71 | + sequence: |
| 72 | + - service: input_text.set_value |
| 73 | + target: |
| 74 | + entity_id: input_text.llmvision_garbage_last_keyframe |
| 75 | + data: |
| 76 | + value: "{{ llmvision_result.key_frame }}" |
| 77 | + default: |
| 78 | + - service: input_text.set_value |
| 79 | + target: |
| 80 | + entity_id: input_text.llmvision_garbage_last_keyframe |
| 81 | + data: |
| 82 | + value: "" |
| 83 | + - service: input_datetime.set_datetime |
| 84 | + target: |
| 85 | + entity_id: input_datetime.llmvision_garbage_last_run |
| 86 | + data: |
| 87 | + datetime: "{{ now() }}" |
0 commit comments