# Zigbee2MQTT Cover Mappings
# Handles window coverings, blinds, curtains, and shades

version: "1.0"

transformers:
  # Cover state to status (read direction)
  # Z2M state values -> spec status values
  cover_status:
    type: map
    direction: read_only
    read:
      OPEN: "opened"
      CLOSE: "closed"
      STOP: "stopped"
      open: "opened"
      close: "closed"
      stop: "stopped"
      opening: "opening"
      closing: "closing"

  # Cover command (write direction)
  # spec command values -> Z2M state values
  cover_command:
    type: map
    direction: write_only
    write:
      open: "OPEN"
      close: "CLOSE"
      stop: "STOP"

mappings:
  # Standard Zigbee cover (blinds, curtains, shades)
  - name: cover
    description: "Zigbee window covering, blind, or curtain"
    priority: 100
    match:
      expose_type: cover
    device_category: WINDOW_COVERING
    channels:
      - identifier: window_covering
        name: Window Covering
        category: WINDOW_COVERING
        features:
          # Status (read-only) - current state of the cover
          # Z2M state: OPEN/CLOSE/STOP -> spec status: opened/closed/stopped
          - z2m_feature: state
            direction: read_only
            panel:
              identifier: STATUS
              name: Status
              data_type: ENUM
              format: ["opened", "closed", "opening", "closing", "stopped"]
              settable: false
            transformer: cover_status

          # Command (write-only) - send open/close/stop commands
          # Uses same Z2M state property but for writing commands
          - z2m_feature: state
            direction: write_only
            panel:
              identifier: COMMAND
              name: Command
              data_type: ENUM
              format: ["open", "close", "stop"]
              settable: true
            transformer: cover_command

          # Position (0-100%)
          # Z2M normalizes different position commands (position, lift_percentage,
          # goto_lift_percentage) through its adapter layer. The position_command
          # behavior is handled internally by Z2M based on the device's capabilities.
          - z2m_feature: position
            panel:
              identifier: POSITION
              name: Position
              data_type: UCHAR
              format: [0, 100]
              unit: "%"

          # Tilt (0-100%, for venetian blinds)
          # Z2M normalizes different tilt commands (tilt, tilt_percentage)
          # through its adapter layer. The tilt_command behavior is handled
          # internally by Z2M based on the device's capabilities.
          - z2m_feature: tilt
            panel:
              identifier: TILT
              name: Tilt
              data_type: UCHAR
              format: [0, 100]
              unit: "%"

          # Motor fault indicator
          - z2m_feature: motor_fault
            direction: read_only
            panel:
              identifier: FAULT
              name: Motor Fault
              data_type: BOOL
              settable: false

        # Static type property - covers are typically curtains
        static_properties:
          - identifier: TYPE
            name: Cover Type
            data_type: ENUM
            format: ["curtain", "blind", "roller", "outdoor_blind"]
            value: "curtain"
