Files
HomeAssistance/custom_components/ai_automation_suggester/automations/new-entity-automation.yaml
T
2026-06-05 22:34:31 -04:00

48 lines
1.7 KiB
YAML

########################################################################################
# AI Suggestions - New Entity Detection
########################################################################################
# This automation triggers the AI Automation Suggester whenever new entities are added to
# your Home Assistant instance.
#
# CUSTOMIZATION OPTIONS:
# 1. Trigger Events:
# - Currently monitors both 'create' and 'update' events
# - Remove the second trigger if you only want new entity detection
#
# 2. Throttling:
# - Uses a cooldown of 1 hour to prevent excessive API calls
# - Adjust the hours value in the condition template if needed
########################################################################################
alias: "AI Suggestions - New Entity Detection"
description: "Generates automation suggestions whenever new entities are registered in Home Assistant"
trigger:
# Trigger when a new entity is created
- platform: event
event_type: entity_registry_updated
event_data:
action: create
# Optional: Trigger when an entity is updated
- platform: event
event_type: entity_registry_updated
event_data:
action: update
condition:
# Simple throttling based on last trigger time
- condition: template
value_template: >-
{% set automation = states.automation.ai_suggestions_new_entity_detection %}
{% if automation and automation.attributes.last_triggered %}
{% set hours_since = ((now() - as_datetime(automation.attributes.last_triggered)).total_seconds() / 3600) | float %}
{{ hours_since > 1.0 }}
{% else %}
true
{% endif %}
action:
- service: ai_automation_suggester.generate_suggestions
target: {}
data: {}