# Adapted example for the Home Assistant automation editor's YAML view.
# Replace both sensor entity IDs. No vacuum commands are sent.
alias: S2 needs attention
mode: queued
max: 5
triggers:
  - trigger: state
    entity_id: sensor.s2_operational_error
    to: null
    id: error
  - trigger: state
    entity_id: sensor.s2_operational_state
    to: seeking_charger
    for: "00:08:00"
    id: charger
conditions:
  - condition: template
    value_template: >-
      {{ trigger is defined and
         (trigger.id == 'charger' or
          (trigger.id == 'error' and trigger.to_state is not none and
           trigger.to_state.state not in ['no_error', 'unknown', 'unavailable'])) }}
actions:
  - action: persistent_notification.create
    data:
      notification_id: "s2_{{ trigger.id }}"
      title: S2 needs attention
      message: >-
        {% if trigger.id == 'charger' %}
          The S2 has been seeking its charger for eight minutes.
          Check the route to the dock and the vacuum itself.
        {% else %}
          The S2 reported: {{ trigger.to_state.state }}.
          Check the vacuum and its Eufy app before restarting a clean.
        {% endif %}
