name: Cat litter box
products:
  - id: fgdeheqmt4mdhzr8
    manufacturer: Tonepie
    model: T1Pro MAX
  - id: 245oe8zmuebemjah
    manufacturer: Tonepie
    model: T1Pro
entities:
  # Controls (Primary Actions)
  # Initiates immediate cleaning cycle
  - entity: button
    name: Clean now
    icon: "mdi:shimmer"
    dps:
      - id: 3
        type: boolean
        name: button
  # Change Sand Control
  # Starts the sand replacement procedure
  - entity: button
    name: Change sand
    icon: "mdi:delete-empty"
    dps:
      - id: 111
        type: boolean
        name: button
  # Replace Bag Control
  # Initiates waste bag replacement process
  - entity: button
    name: Replace bag
    icon: "mdi:sack"
    dps:
      - id: 117
        type: boolean
        name: button
  # Sand Smoothing Control
  # Levels the litter surface
  - entity: button
    name: Smooth sand
    icon: "mdi:waves"
    dps:
      - id: 118
        type: boolean
        name: button
  # Deodorize Control
  # Controls odor elimination function
  - entity: switch
    name: Deodorize
    icon: "mdi:scent"
    dps:
      - id: 17
        type: boolean
        name: switch
  # Configuration Settings
  # Enables automatic cleaning after cat visits
  - entity: switch
    name: Auto clean
    icon: "mdi:shimmer"
    category: config
    dps:
      - id: 4
        type: boolean
        name: switch
  # Delay before starting auto-clean (1-60 minutes)
  - entity: number
    name: Clean wait time
    icon: "mdi:timer"
    category: config
    class: duration
    dps:
      - id: 5
        type: integer
        name: value
        unit: min
        range:
          min: 1
          max: 60
  # Time between scheduled cleanings (0-120 minutes)
  - entity: number
    name: Clean interval
    icon: "mdi:update"
    category: config
    class: duration
    dps:
      - id: 105
        type: integer
        name: value
        unit: min
        range:
          min: 0
          max: 120
  # Motion detection to prevent cleaning while cat is present
  - entity: switch
    name: Infrared detection
    icon: "mdi:motion-sensor"
    category: config
    dps:
      - id: 104
        type: boolean
        name: switch
        mapping:
          - dps_val: false
            value: true
          - dps_val: true
            value: false
  # Prevents operation during specified quiet hours
  - entity: button
    name: Do not disturb
    icon: "mdi:power-sleep"
    category: config
    dps:
      - id: 106
        type: boolean
        optional: true
        name: button
  - entity: button
    name: Do not disturb off
    icon: "mdi:power-sleep"
    category: config
    dps:
      - id: 119
        type: boolean
        optional: true
        name: button
  # Controls the device's LED lighting
  - entity: light
    name: Ambient light
    category: config
    dps:
      - id: 113
        type: string
        name: brightness
        mapping:
          - dps_val: "led_on"
            value: 255
          - dps_val: "led_dim"
            value: 128
          - dps_val: "led_off"
            value: 0
  # Prevents accidental button presses
  - entity: lock
    translation_key: child_lock
    category: config
    dps:
      - id: 103
        type: boolean
        name: lock
  # Adjusts litter level detection (0-6)
  - entity: number
    name: Litter calibration
    icon: "mdi:grain"
    category: config
    dps:
      - id: 110
        type: integer
        name: value
        range:
          min: 0
          max: 6
  # Adjusts waste bin capacity detection (0-15)
  - entity: number
    name: Bin capacity calibration
    icon: "mdi:trash-can"
    category: config
    dps:
      - id: 109
        type: integer
        name: value
        range:
          min: 0
          max: 15
  # Adjusts cleaning rake angle (0-5)
  - entity: number
    name: Clean angle calibration
    icon: "mdi:angle-acute"
    category: config
    dps:
      - id: 114
        type: integer
        name: value
        range:
          min: 0
          max: 5
  # Diagnostic Tools and Sensors
  # Resets the weight sensor calibration
  - entity: button
    name: Weight reset
    icon: "mdi:scale-off"
    category: diagnostic
    dps:
      - id: 112
        type: boolean
        name: button
  # Resets device after error or maintenance
  - entity: button
    name: Self-check reset
    icon: "mdi:refresh"
    category: diagnostic
    dps:
      - id: 115
        type: boolean
        name: button
  # Reports device malfunctions and errors
  - entity: binary_sensor
    class: problem
    category: diagnostic
    dps:
      - id: 22
        type: bitfield
        name: sensor
        mapping:
          - dps_val: 0
            value: false
          - value: true
      - id: 22
        type: bitfield
        name: fault_code
      - id: 22
        type: bitfield
        name: description
        mapping:
          - dps_val: 1
            value: "Motor malfunction"
          - dps_val: 2
            value: "Program error"
          - dps_val: 4
            value: "Weight sensor malfunction"
          - dps_val: 8
            value: "Fan malfunction"
          - dps_val: 16
            value: "Ozone generator malfunction"
          - dps_val: 32
            value: "Ball bunker not installed"
  # Counts total number of cat visits
  - entity: sensor
    name: Total visits
    icon: "mdi:counter"
    class: measurement
    category: diagnostic
    dps:
      - id: 7
        type: integer
        name: sensor
        unit: visits
  # Status Monitoring
  # Last recorded cat weight in kg
  - entity: sensor
    icon: "mdi:cat"
    name: Cat weight
    class: weight
    dps:
      - id: 6
        type: integer
        name: sensor
        unit: kg
        class: measurement
        mapping:
          - scale: 1000
  # Duration of cat's last visit in seconds
  - entity: sensor
    name: Visit duration
    class: duration
    dps:
      - id: 8
        type: integer
        name: sensor
        unit: s
        class: measurement
  # Current weight reading in kg
  - entity: sensor
    class: weight
    dps:
      - id: 116
        type: integer
        name: sensor
        unit: kg
        class: measurement
        mapping:
          - scale: 1000
  # Internal temperature of device
  - entity: sensor
    class: temperature
    dps:
      - id: 101
        type: integer
        name: sensor
        unit: °C
  # Internal humidity level
  - entity: sensor
    class: humidity
    dps:
      - id: 102
        type: integer
        name: sensor
        unit: "%"
  # Detects if cat is currently in the box
  - entity: binary_sensor
    icon: "mdi:cat"
    class: occupancy
    dps:
      - id: 116
        type: integer
        name: sensor
        mapping:
          - dps_val: 0
            value: false
          - value: true
  # Event Notifications
  # Various device status and activity notifications
  - entity: event
    name: Notification
    icon: "mdi:bell"
    dps:
      - id: 21
        type: bitfield
        name: event
        persist: false
        mapping:
          - dps_val: 1
            value: "Garbage Box Full"
          - dps_val: 2
            value: "Excessive Clean Times"
          - dps_val: 4
            value: "Cleaning In Progress"
          - dps_val: 8
            value: "No Weight Detected"
          - dps_val: 16
            value: "Cat Left Box"
          - dps_val: 32
            value: "Cat Approaching Box"
          - dps_val: 64
            value: "Smart Clean Started"
          - dps_val: 128
            value: "Smart Clean Completed"
          - dps_val: 256
            value: "Cleaning Started"
          - dps_val: 512
            value: "Cleaning Completed"
          - dps_val: 1024
            value: "Sand Change Started"
          - dps_val: 2048
            value: "Sand Change Completed"
          - dps_val: 4096
            value: "Deodorizing Started"
          - dps_val: 8192
            value: "Deodorizing Completed"
          - dps_val: 16384
            value: "IR Sensor Triggered - Paused"
          - dps_val: 32768
            value: "IR Sensor Normal - Running"
          - dps_val: 65536
            value: "Weight Increased - Stopped"
          - dps_val: 131072
            value: "Weight Normal - Running"
          - dps_val: 262144
            value: "Bag Replacement Started"
          - dps_val: 524288
            value: "Bag Replacement Completed"
          - dps_val: 1048576
            value: "Sand Smoothing Started"
          - dps_val: 2097152
            value: "Sand Smoothing Completed"
  - entity: sensor
    translation_key: status
    class: enum
    category: diagnostic
    dps:
      - id: 24
        type: string
        optional: true
        name: sensor
        mapping:
          - dps_val: "off"
            value: "off"
          - dps_val: standby
            value: standby
          - dps_val: waiting_cluster
            value: caking
          - dps_val: cleaning
            value: cleaning
          - dps_val: uv
            value: sterilizing
          - dps_val: deodorization
            value: deodorizing
          - dps_val: sleep
            value: sleep
