name: Pet feeder
products:
  - id: 8vwr6rfoaaxncjwj
    manufacturer: Petoneer
    model: Nutri Mini
  - id: pxwlmmdodfppms3a
    manufacturer: GiotoHun
  - id: ojqmjnoxqygqldsp
    manufacturer: Puppy Kitty
  - id: s3rvixmeqx62vud5
    manufacturer: Catit
    model: Pixi Smart Feeder
    model_id: "43752"
entities:
  - entity: button
    name: Quick feed
    icon: "mdi:food-drumstick"
    dps:
      # Feeds the meal size, regardless of dps value
      - id: 2
        type: boolean
        name: button
        optional: true
  - entity: text
    name: Meal plan
    category: config
    hidden: true
    dps:
      # Not thought to be used with Catit 43752
      - id: 1
        type: base64
        name: value
        optional: true
  - entity: sensor
    icon: "mdi:paw"
    name: Feed report
    category: diagnostic
    dps:
      - id: 15
        name: sensor
        type: integer
        # Only present after feeding on Catit 43752
        optional: true
  - entity: button
    translation_key: factory_reset
    category: config
    dps:
      - id: 9
        type: boolean
        name: button
        optional: true
  - entity: number
    icon: "mdi:paw"
    name: Manual feed
    dps:
      - id: 3
        name: value
        type: integer
        range:
          min: 1
          max: 12
        # Only present after feeding on Catit 43752
        optional: true
  - entity: binary_sensor
    name: Food shortage
    class: problem
    category: diagnostic
    dps:
      - id: 14
        type: bitfield
        name: sensor
        optional: true
        mapping:
          - dps_val: 2
            value: true
          - value: false
  - entity: binary_sensor
    name: Food blockage
    class: problem
    category: diagnostic
    dps:
      - id: 14
        type: bitfield
        name: sensor
        optional: true
        mapping:
          - dps_val: 4
            value: true
          - value: false
  - entity: binary_sensor
    name: Feeding
    class: running
    icon: "mdi:paw"
    category: diagnostic
    dps:
      # Not observed in Catit 43752
      - id: 4
        type: string
        name: sensor
        optional: true
        mapping:
          - dps_val: feeding
            value: true
          - dps_val: null
            value: null
          - value: false
  - entity: sensor
    name: Last meal details
    category: diagnostic
    dps:
      # Takes value such as `R:0  C:1  T:1761264924`,
      # where `R=result`, `C=meal_size`, `T=unix_time`.
      # Extracting the timestamp with Tuya Local is not currently
      # possible - use a template sensor:
      # ```
      # template:
      #   sensor:
      #     - name: last meal time
      #       state: >
      #         {% set s = states("sensor.your_last_meal_details") %}
      #         {% if s in [""] %}
      #           unknown
      #         {% else %}
      #           {% set ts = namespace(val=None) %}
      #           {% for p in s.split() %}
      #             {% if p.startswith("T:") %}
      #               {% set ts.val = (p[2:]|int) %}
      #             {% endif %}
      #           {% endfor %}
      #           {% if ts.val is none %}
      #             unknown
      #           {% else %}
      #             {{ (ts.val | int) | timestamp_utc }}
      #           {% endif %}
      #         {% endif %}
      #       device_class: timestamp
      # ```
      # Value persists until next feed, or device power off
      - id: 104
        name: sensor
        type: string
        optional: true
  - entity: sensor
    name: IP address
    category: diagnostic
    dps:
      - id: 107
        name: sensor
        type: string
        # Present at all times on Catit 43752 but unsure about other products
        optional: true
  - entity: binary_sensor
    category: diagnostic
    class: plug
    dps:
      - id: 105
        type: bitfield
        name: sensor
        mapping:
          - dps_val: 1
            value: false
          - value: true
        # Present at all times on Catit 43752 but unsure about other products
        optional: true
  - entity: switch
    name: Sound enabled
    category: config
    dps:
      - id: 103
        name: switch
        type: boolean
        # Present at all times on Catit 43752 but unsure about other products
        optional: true
  - entity: switch
    name: Feed button enabled
    category: config
    dps:
      - id: 102
        name: switch
        type: boolean
        # Present at all times on Catit 43752 but unsure about other products
        optional: true
  - entity: number
    name: Meal size
    category: config
    dps:
      - id: 101
        name: value
        type: integer
        # Present at all times on Catit 43752 but unsure about other products
        optional: true
        range:
          min: 1
          max: 12
