{
  "schema": "devcap1.schema.json",
  "manufacturername": "ubisys",
  "modelid": "J1-R (5602)",
  "vendor": "ubisys",
  "product": "J1-R (5602) cover controller",
  "sleeper": false,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_WINDOW_COVERING_DEVICE",
      "restapi": "/lights",
      "uuid": [
        "$address.ext",
        "0x01"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "state/bri",
          "parse": {
            "at": "0x0008",
            "cl": "0x0102",
            "ep": 1,
            "eval": "Item.val = (254 * Attr.val) / 100;",
            "fn": "zcl:attr"
          },
          "read": {
            "fn": "none"
          }
        },
        {
          "name": "state/lift"
        },
        {
          "name": "state/on",
          "parse": {
            "at": "0x0008",
            "cl": "0x0102",
            "ep": 1,
            "eval": "if (Attr.val == 100) { Item.val = true; } else { Item.val = false; }",
            "fn": "zcl:attr"
          },
          "read": {
            "fn": "none"
          }
        },
        {
          "name": "state/open",
          "parse": {
            "at": "0x0008",
            "cl": "0x0102",
            "ep": 1,
            "eval": "Item.val = Attr.val < 100",
            "fn": "zcl:attr"
          },
          "read": {
            "fn": "none"
          }
        },
        {
          "name": "state/tilt"
        },
        {
          "name": "state/reachable"
        }
      ]
    },
    {
      "type": "$TYPE_SWITCH",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x02",
        "0x0102"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0203",
        "endpoint": "0x02",
        "in": [
          "0x0000"
        ],
        "out": [
          "0x0005",
          "0x0102"
        ]
      },
      "meta": {
        "values": {
          "config/mode": {"momentary": 0, "rocker": 1, "custom": 2}
        }
      },
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/group",
          "default": "auto"
        },
        {
          "name": "config/mode",
          "refresh.interval": 3660,
          "read": {
            "at": "0x0001",
            "cl": "0xFC00",
            "ep": "0xE8",
            "fn": "zcl:attr"
          },
          "parse": {
            "cl": "0xFC00",
            "cmd": "0x01",
            "ep": "0xE8",
            "eval": "let m = ''; for (var i = 4; i < ZclFrame.payloadSize; i++) { m += ('00' + ZclFrame.at(i).toString(16)).slice(-2); } m = m.toUpperCase(); if ( m == '41040006000D020201000600070202010206010D0202010106010702020102') { Item.val = 'momentary'; } else if ( m == '41040006000D020201000600030202010206010D0202010106010302020102') { Item.val = 'rocker'; } else { Item.val = 'custom_' + m; }",
            "fn": "zcl:cmd"
          },
          "write": {
            "fn": "zcl:cmd",
            "ep": "0xE8",
            "cl": "0xFC00",
            "cmd": "0x02",
            "eval": "if (Item.val == 'momentary') { '01004841040006000D020201000600070202010206010D0202010106010702020102' } else if (Item.val == 'rocker') { '01004841040006000D020201000600030202010206010D0202010106010302020102' } else if (Item.val.slice(0,7) == 'custom_') { '010048' + Item.val.slice(7, Item.val.length) }",
            "fc": "0x10"
          },
          "default" : "momentary",
          "values": [
            ["\"momentary\"", "All inputs in momentary mode"],
            ["\"rocker\"", "All inputs in rocker mode"],
            ["\"custom_010048....\"", "Custom mode"]
          ]
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "config/windowcoveringtype"
        },
        {
          "name": "state/buttonevent"
        },
        {
          "name": "state/lastupdated"
        }
      ]
    },
    {
      "type": "$TYPE_POWER_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x03",
        "0x0b04"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0501",
        "endpoint": "0x03",
        "in": [
          "0x0B04"
        ]
      },
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/current",
          "refresh.interval": 10
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/power",
          "refresh.interval": 10
        },
        {
          "name": "state/voltage",
          "refresh.interval": 10
        }
      ]
    },
    {
      "type": "$TYPE_CONSUMPTION_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x03",
        "0x0702"
      ],
      "fingerprint": {
        "profile": "0x0104",
        "device": "0x0501",
        "endpoint": "0x03",
        "in": [
          "0x0702"
        ]
      },
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion"
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/consumption",
          "refresh.interval": 10
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/power",
          "read": {
            "at": "0x0400",
            "cl": "0x0702",
            "ep": 3,
            "fn": "zcl:attr"
          },
          "parse": {
            "at": "0x0400",
            "cl": "0x0702",
            "ep": 3,
            "eval": "Item.val = Attr.val",
            "fn": "zcl:attr"
          }
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0102",
      "report": [
        {
          "at": "0x0008",
          "dt": "0x20",
          "min": 1,
          "max": 300,
          "change": "0x00000001"
        },
        {
          "at": "0x0009",
          "dt": "0x20",
          "min": 1,
          "max": 300,
          "change": "0x00000001"
        },
        {
          "at": "0x000A",
          "dt": "0x18",
          "min": 1,
          "max": 600
        }
      ]
    },
    {
      "bind": "groupcast",
      "config.group": 0,
      "src.ep": 2,
      "cl": "0x0102"
    },
    {
      "bind": "unicast",
      "src.ep": 3,
      "cl": "0x0702",
      "report": [
        {
          "at": "0x0400",
          "dt": "0x2A",
          "min": 1,
          "max": 300,
          "change": "0x00000001"
        }
      ]
    }
  ]
}
