diff --git a/.ha_mcp/backups/automation.automation.3d_print_complete_snapshot.20261003_151622.yaml b/.ha_mcp/backups/automation.automation.3d_print_complete_snapshot.20261003_151622.yaml new file mode 100644 index 00000000..6bd17d5a --- /dev/null +++ b/.ha_mcp/backups/automation.automation.3d_print_complete_snapshot.20261003_151622.yaml @@ -0,0 +1,39 @@ +# ha_mcp_backup +schema_version: 1 +domain: automation +entity_id: automation.3d_print_complete_snapshot +captured: '2026-10-03T15:16:22.651698+00:00' +tool: ha_config_set_automation +config: + id: '1787462132503' + alias: 3D Print Complete Snapshot - Telegram + description: Sends a Telegram photo with a SparkX i7 camera snapshot when a print + finishes successfully. Mobile completion notifications are handled by the Creality + integration. + triggers: + - entity_id: sensor.sparkx_i7_print_status + from: printing + to: completed + trigger: state + actions: + - variables: + completion_message: '{% set file = trigger.to_state.attributes.get(''file'', + '''') %} {% set name = ''Print'' if file in ['''', none, ''unknown'', ''unavailable''] + else file.split(''/'')[-1].replace(''.gcode'', '''') %} {% set seconds = trigger.to_state.attributes.get(''job_time_s'', + 0) | int(0) %} {{ name }} finished successfully at {{ now().strftime(''%I:%M + %p'').lstrip(''0'') }}. Total time: {% if seconds >= 3600 %}{{ seconds // + 3600 }}h {{ ((seconds % 3600) // 60) }}m {% else %}{{ ((seconds % 3600) // + 60) }}m{% endif %}' + - action: camera.snapshot + data: + filename: /config/www/sparkx_i7_complete_snapshot.jpg + target: + entity_id: camera.sparkx_i7_printer_camera + - action: telegram_bot.send_photo + data: + caption: '{{ completion_message }}' + file: /config/www/sparkx_i7_complete_snapshot.jpg + parse_mode: plain_text + target: + entity_id: notify.franco + mode: single diff --git a/.ha_mcp/logs/mcp_usage.jsonl b/.ha_mcp/logs/mcp_usage.jsonl index b68b8e03..3496b1a8 100644 --- a/.ha_mcp/logs/mcp_usage.jsonl +++ b/.ha_mcp/logs/mcp_usage.jsonl @@ -3833,3 +3833,4 @@ {"timestamp": "2026-10-03T15:12:21.997427+00:00", "tool_name": "ha_search", "parameters": {"query": "3D Print Complete Snapshot", "domain_filter": "automation", "area_filter": null, "search_types": null, "limit": 5, "offset": 0, "exact_match": true, "include_hidden": true, "include_config": false, "group_by_domain": false, "per_domain_limit": null, "state_filter": null, "result_fields": null, "fields": null, "config_time_budget": null, "ctx": {"_STATE_TTL_SECONDS": 86400}}, "execution_time_ms": 173.38085174560547, "success": true, "error_message": null, "response_size_bytes": 888, "user_context": null} {"timestamp": "2026-10-03T15:12:24.884766+00:00", "tool_name": "ha_config_get_automation", "parameters": {"identifier": "automation.3d_print_complete_snapshot"}, "execution_time_ms": 359.71951484680176, "success": true, "error_message": null, "response_size_bytes": 1447, "user_context": null} {"timestamp": "2026-10-03T15:12:38.440661+00:00", "tool_name": "ha_get_entity", "parameters": {"entity_id": ["camera.sparkx_i7_printer_camera", "camera.endercamera_duckdns_org", "camera.endercamera2_duckdns_org", "light.sparkx_i7_light", "light.bedroom_lamp_2"], "unique_id": null, "domain": null, "platform": null}, "execution_time_ms": 10.793209075927734, "success": true, "error_message": null, "response_size_bytes": 2923, "user_context": null} +{"timestamp": "2026-10-03T15:16:23.999457+00:00", "tool_name": "ha_config_set_automation", "parameters": {"config": null, "identifier": "automation.3d_print_complete_snapshot", "python_transform": "config['actions'][2:2] = [{'variables': {'sparkx_needs_light': \"{{ not is_state('light.sparkx_i7_light', 'on') }}\", 'bedroom_needs_light': \"{{ not is_state('light.bedroom_lamp_2', 'on') }}\"}}, {'if': [{'condition': 'template', 'value_template': '{{ sparkx_needs_light }}'}], 'then': [{'action': 'light.turn_on', 'continue_on_error': True, 'target': {'entity_id': 'light.sparkx_i7_light'}}]}, {'if': [{'condition': 'template', 'value_template': '{{ bedroom_needs_light }}'}], 'then': [{'action': 'light.turn_on', 'continue_on_error': True, 'target': {'entity_id': 'light.bedroom_lamp_2'}}]}, {'delay': {'seconds': 3}}]; config['actions'][6:6] = [{'delay': {'seconds': 2}}, {'if': [{'condition': 'template', 'value_template': '{{ sparkx_needs_light }}'}], 'then': [{'action': 'light.turn_off', 'continue_on_error': True, 'target': {'entity_id': 'light.sparkx_i7_light'}}]}, {'if': [{'condition': 'template', 'value_template': '{{ bedroom_needs_light }}'}], 'then': [{'action': 'light.turn_off', 'continue_on_error': True, 'target': {'entity_id': 'light.bedroom_lamp_2'}}]}]", "config_hash": "c556c12c1113197d", "take_control_of_blueprint": false, "category": null, "wait": true, "enabled": null, "run_actions": false, "MandatoryBPS": true, "BestPracticeKey": null}, "execution_time_ms": 1338.163137435913, "success": true, "error_message": null, "response_size_bytes": 80044, "user_context": null} diff --git a/automations.yaml b/automations.yaml index a0386d3b..a37398fe 100644 --- a/automations.yaml +++ b/automations.yaml @@ -3530,6 +3530,45 @@ filename: /config/www/sparkx_i7_complete_snapshot.jpg target: entity_id: camera.sparkx_i7_printer_camera + - variables: + sparkx_needs_light: '{{ not is_state(''light.sparkx_i7_light'', ''on'') }}' + bedroom_needs_light: '{{ not is_state(''light.bedroom_lamp_2'', ''on'') }}' + - if: + - condition: template + value_template: '{{ sparkx_needs_light }}' + then: + - action: light.turn_on + continue_on_error: true + target: + entity_id: light.sparkx_i7_light + - if: + - condition: template + value_template: '{{ bedroom_needs_light }}' + then: + - action: light.turn_on + continue_on_error: true + target: + entity_id: light.bedroom_lamp_2 + - delay: + seconds: 3 + - delay: + seconds: 2 + - if: + - condition: template + value_template: '{{ sparkx_needs_light }}' + then: + - action: light.turn_off + continue_on_error: true + target: + entity_id: light.sparkx_i7_light + - if: + - condition: template + value_template: '{{ bedroom_needs_light }}' + then: + - action: light.turn_off + continue_on_error: true + target: + entity_id: light.bedroom_lamp_2 - action: telegram_bot.send_photo data: caption: '{{ completion_message }}'