blueprint:
  name: RealRobotOwners — Home Robot Tenure Check-In (Unconditional 6m / 12m)
  description: >-
    Track how long you have owned a home robot (litter box, robot vacuum, robot lawn mower,
    pool cleaner, or robot pet) in Home Assistant and receive one unconditional check-in prompt
    at 6 months or 12 months with a 1-click link to log your honest experience on RealRobotOwners
    (https://realrobotowners.com). Never cherry-picked on positive events. Strictly opt-in:
    nothing is ever submitted automatically.
  domain: automation
  source_url: https://realrobotowners.com/integrations/home-assistant/robot-tenure-checkin.yaml
  author: RealRobotOwners (https://realrobotowners.com)
  input:
    company_slug:
      name: Robot company slug
      description: >-
        Company slug from realrobotowners.com (e.g. whisker, petkit, neakasa, catlink,
        roborock, dreame, ecovacs, husqvarna, mammotion, segway-navimow, maytronics, sony).
      default: whisker
      selector:
        text: {}
    robot_slug:
      name: Robot model slug
      description: >-
        Model slug from realrobotowners.com (e.g. litter-robot-4, pura-max, neakasa-m1,
        automower-430x, luba-3-awd, aibo, vector).
      default: litter-robot-4
      selector:
        text: {}
    robot_label:
      name: Friendly robot name
      description: Name shown in your notification (e.g. Litter-Robot 4).
      default: Litter-Robot 4
      selector:
        text: {}
    purchase_date:
      name: Purchase or setup date (YYYY-MM-DD)
      description: Approximate date your robot started running at home.
      default: "2026-01-01"
      selector:
        date: {}
    milestone_months:
      name: Check-in milestone
      description: Unconditional calendar check-in after setup.
      default: "12"
      selector:
        select:
          options:
            - label: "6 months of ownership"
              value: "6"
            - label: "12 months of ownership"
              value: "12"
            - label: "24 months of ownership"
              value: "24"
    notify_device:
      name: Mobile app device to notify (optional)
      description: >-
        Optional Home Assistant mobile app device. A persistent Home Assistant dashboard
        notification is always created as well.
      default: ""
      selector:
        device:
          integration: mobile_app

mode: single
max_exceeded: silent

variables:
  company_slug: !input company_slug
  robot_slug: !input robot_slug
  robot_label: !input robot_label
  purchase_date: !input purchase_date
  milestone_months: !input milestone_months
  owned_param: >-
    {% set m = milestone_months | int(12) %}
    {% if m >= 24 %}Over 2 years{% elif m >= 12 %}1 to 2 years{% else %}6 to 12 months{% endif %}
  target_days: "{{ (milestone_months | int(12)) * 30 }}"
  review_url: >-
    https://realrobotowners.com/review/?company={{ company_slug | urlencode }}&robot={{ robot_slug | urlencode }}&owned={{ owned_param | urlencode }}&from=home-assistant

trigger:
  - platform: time
    at: "10:00:00"

condition:
  - condition: template
    value_template: >-
      {% set start = as_timestamp(purchase_date, 0) %}
      {% set elapsed_days = ((as_timestamp(now()) - start) / 86400) | int %}
      {{ start > 0 and elapsed_days == (target_days | int) }}

action:
  - service: persistent_notification.create
    data:
      notification_id: "rro_checkin_{{ robot_slug }}_{{ milestone_months }}m"
      title: "{{ milestone_months }}-month check-in: {{ robot_label }}"
      message: >-
        You have owned your **{{ robot_label }}** for about {{ milestone_months }} months.
        Want to share what held up, what broke, or whether you would buy it again on
        [RealRobotOwners]({{ review_url }})? (Takes ~60 seconds, 1 review per model, human-checked.)
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ notify_device | default('') != '' }}"
        sequence:
          - domain: mobile_app
            type: notify
            device_id: !input notify_device
            title: "{{ milestone_months }} months with your {{ robot_label }}"
            message: >-
              How is it holding up? Tap to log an independent owner review on RealRobotOwners (optional, ~60s).
            data:
              url: "{{ review_url }}"
              clickAction: "{{ review_url }}"
