notif_gotify:
  alias: "\U0001F4E2 Notification Gotify"
  description: Envoie une notification via Gotify avec cooldown anti-spam global 10min
    (bypass si priorité ≥ 8)
  fields:
    title:
      description: Titre de la notification
      example: Doris
    message:
      description: Contenu du message
      example: Le réservoir doit être vidé
    priority:
      description: Priorité (1-10)
      example: 5
      default: 5
  sequence:
  - condition: template
    value_template: "{{ (priority | default(5) | int) >= 8\n   or (as_timestamp(now())
      - as_timestamp(states('input_datetime.last_notification'))) > 600 }}\n"
  - action: notify.gotify_notify
    data:
      title: '{{ title | default(''Home Assistant'') }}'
      message: '{{ message }}'
      data:
        priority: '{{ priority | default(5) }}'
  - action: input_datetime.set_datetime
    target:
      entity_id: input_datetime.last_notification
    data:
      datetime: '{{ now() }}'
incrementer_cycle_doris:
  alias: Incrémenter cycle Doris
  sequence:
  - action: counter.increment
    data: {}
    target:
      entity_id: counter.cycle_doris
  description: ''
reinitialiser_compteur_doris:
  alias: "\U0001F9F9 Réinitialiser compteur Doris"
  description: Remet le compteur à zéro après vidange du réservoir
  sequence:
  - action: counter.reset
    target:
      entity_id: counter.cycle_doris
  - action: script.notif_gotify
    data:
      title: "\U0001F9F9 Doris"
      message: Compteur remis à zéro après vidange
      priority: 3
  icon: mdi:refresh
mealie_semaine_precedente:
  alias: Mealie - Semaine précédente
  sequence:
  - action: input_datetime.set_datetime
    target:
      entity_id: input_datetime.mealie_semaine_ref
    data:
      date: '{% set ref = states(''input_datetime.mealie_semaine_ref'') %} {% set
        d = strptime(ref, ''%Y-%m-%d'') %} {{ (d.date() - timedelta(days=7)).strftime(''%Y-%m-%d'')
        }}

        '
  - action: automation.trigger
    target:
      entity_id: automation.mealie_sync_menus_semaine
    data:
      skip_condition: true
  mode: single
  description: ''
mealie_cette_semaine:
  alias: Mealie - Cette semaine
  sequence:
  - action: input_datetime.set_datetime
    target:
      entity_id: input_datetime.mealie_semaine_ref
    data:
      date: '{{ (now().date() - timedelta(days=now().weekday())).strftime(''%Y-%m-%d'')
        }}

        '
  - action: automation.trigger
    target:
      entity_id: automation.mealie_sync_menus_semaine
    data:
      skip_condition: true
  mode: single
  description: ''
mealie_semaine_suivante:
  alias: Mealie - Semaine suivante
  sequence:
  - action: input_datetime.set_datetime
    target:
      entity_id: input_datetime.mealie_semaine_ref
    data:
      date: '{% set ref = states(''input_datetime.mealie_semaine_ref'') %} {% set
        d = strptime(ref, ''%Y-%m-%d'') %} {{ (d.date() + timedelta(days=7)).strftime(''%Y-%m-%d'')
        }}

        '
  - action: automation.trigger
    target:
      entity_id: automation.mealie_sync_menus_semaine
    data:
      skip_condition: true
  mode: single
  description: ''
arreter_le_minuteur:
  alias: Arrêter le minuteur
  sequence:
  - action: input_boolean.turn_off
    target:
      entity_id: input_boolean.timer_actif
  - action: notify.mobile_app_tablette
    data:
      message: clear_notification
      data:
        tag: timer_alert
  description: ''
backup_git:
  alias: "\U0001F4BE Backup Git"
  description: Commit et push la config HA vers Gitea
  sequence:
  - action: shell_command.git_backup
