using System; using Newtonsoft.Json.Linq; namespace HDL_ON.Entity { public class A_Protocol_Command { string vendor_code = "HDL"; public A_Protocol_Command() { } /* *5.1.1 *请求参数 *{ * "vendor_code":"HDL", * "command":"search" *} *返回值 json格式;网关设备信息 *例子 *{ * "vendor_code": "HDL", * "command": "get_gateway_info_respond", * "objects": * { * "name": "hdl_bus_gateway", * "version": "20191220", * "gateway_ipmac": "1200450600", * "gateway_ip": "192.168.10.2", * "mask": "255.255.255.0", * "dns_server1": "114.114.114.114", * "dns_server2": "114.114.114.114", * "server_addr": "t1-smarthome.ec-founder.com", * "mqtt": "true" * } *} */ /// /// 搜索在线网关 /// public void SearchGateway() { } /// ///5.1.2 修改在线网关基本信息 ///请求参数 /// { /// "vendor_code": "HDL", /// "command": "modify_gateway_info", /// "objects": { /// "name": "hdl_bus_gateway", /// "version": "20191220", /// "gateway_ip": "192.168.10.2", /// "mask": "255.255.255.0", /// "dns_server1": "114.114.114.114", /// "dns_server2": "114.114.114.114", /// "server_addr": "t1-smarthome.ec-founder.com", /// "mqtt":" true" /// } /// } /// 返回值 json格式 ///例子 { /// "vendor_code": "HDL", /// "command": “modity_gateway_info_respond ", /// "value": "success" ///} /// public void EidtGatewayInfo(string name, string version, string gateway_ip, string mask, string dns_server1, string dns_server2, string server_addr, bool mqtt) { var sendJob = new JObject { { "vendor_code", vendor_code }, { "Command", "modify_gateway_info" } }; var data = new JObject { { "name", name },{"version", version},{ "gateway_ip",gateway_ip},{ "mask",mask}, { "dns_server1",dns_server1 } ,{ "dns_server2",dns_server2},{ "server_addr",server_addr},{ "mqtt",mqtt}}; sendJob.Add("objects", data); } /// /// 5.1.3获取设备oid列表 /// 请求参数 /// { /// "vendor_code": "HDL", /// "type": "device_oid", /// "command": "get_list" /// } /// 返回值 json格式;oid 列表数据 /// 例子 { /// "vendor_code": "HDL", /// "command": "get_list_respond", /// "type": "device_oid", /// "objects": [{ /// "oid": "0001011910120900002567010001", /// "status": "online", /// "auto_id": "0001", /// "name": "light", /// "machine_id": "1234567890-abcdefaabd-1234567890", /// "net_id":"02", /// "dev_id":"00" /// }, { /// "oid": "0001011910120900002567020002", /// "status": "online", /// "auto_id": "0002", /// "name": "curtain", /// "machine_id": "1234567890-abcdefaabd-1234567890", /// "net_id":"02", /// "dev_id":"01" /// }] /// } /// public void GetDevcieOidList() { var sendJob = new JObject { { "vendor_code", vendor_code },{"type","device_oid" }, { "Command", "get_list" } }; } //5.1.4 添加oid到设备oid列表 //请求参数 //{ // "vendor_code": "HDL", // "type": "device_oid", // "command": "add", // "objects": [{ // "oid": "0001011910120900002567010001", // "name": "light", //"auto_id": "0001", // "machine_id": "1234567890-abcdefaabd-1234567890", //"net_id":"02", //"dev_id":"00" // }, { // "oid": "0001011910120900002567020002", // "name": "light", //"auto_id": "0002", // "machine_id": "1234567890-abcdefaabd-1234567890", //"net_id":"02", //"dev_id":"00" // }] //} //返回值 json格式; //例子 { // "vendor_code": "HDL", // "command": "add_respond", // "type": "device_oid", // "oid": "0001011910120900002567010001", // "value": "success" //} //5.1.5 删除设备oid列表中的oid //请求参数 //{ // "vendor_code": "HDL", // "type": "device_oid", // "command": "delete", // "objects": [{ // "oid": "0001011910120900002567010001" // }, { // "oid": "0001011910120900002567010002" // }] //} //返回值 json格式 //例子 { // "vendor_code": "HDL", // "command": "delete_respond", // "type": "device_oid", // "oid": "0001011910120900002567010001", // "value": "success" //} //5.1.6 获取功能(物模型)列表 //请求参数 //{ // "vendor_code": "HDL", // "type": "device_sid", // "command": "get_list" //} //返回值 json格式;sid和name //例子 //{ // "vendor_code": "HDL", // "command": "get_list_respond", // "type": "device_sid", // "objects": [{ // "sid": "00010119101209000025670300010001", //"device_type": "light", //"name": "客厅灯光1" // }, { // "sid": "00010019101209000025670100010003", //"device_type": "airconditioner", //"name": "客厅空调1" // }] //} //说明 获取功能(物模型)sid列表 //5.1.7 获取功能(物模型)属性值列表 //请求参数 //{ // "vendor_code": "HDL", // "command": "get_proxy", // "type": "device_sid", // "objects": [{ // "sid": "00010119101209000025670100010001" // }, { // "sid": "00010019101209000025670300020001" // }] //} //返回值 json格式;sid和属性列表 //例子 //{ // "vendor_code": "HDL", // "command": "get_proxy_respond ", // "type": "device_sid", // "objects": [{ // "sid": "00010119101209000025670300020001", //"name": "", // "function": [{ // "attri": "switch", // "value": ["on ", "off "], // "max": 1, // "min": 0 // }, { // "attri": "mode", // "value": ["auto", "heat", "cool"], // "max": 2, // "min": 0 // }, { // "attri": "fan", // "value": ["low", "mid", "high"], // "max": 2, // "min": 0 // }, // { // "attri": "temperature", // "value": ["up", "down"], // "max": 32, // "min": 16 // } // ] // }, // { // "sid": "00010019101209000025670400010001", //"name": "开合帘", // "function": [{ // "attri": "switch", // "value": ["on ", "off "], // "max": 1, // "min": 0 // },{ // "attri": "openLevel", // "value": ["percent"], // "max": 100, // "min": 0 // }] // } // ] //} //说明 属性字段解析:attri :属性内容,value 属性的值,max 最大值 min 最小值 //具体设备功能属性列表如下: //灯光类:trait: [switch, brightness, color, cct, delay, fadeTime] //属性 描述 //switch on/off; //brightness 0-100; //color int (red (0-255) green(0-255) blue(0-255)) //cct int (warm light(0-255) cold light(0-255) ) //delay 0-3600s //fadetime 0-3600s //窗帘属性列表:trait: [switch, openLevel] //属性 描述 //switch on/off/stop; //openLevel 0-100; //lock boolean(Lock锁定控制) //空调:trait: [switch, mode, fan, temperature, swing, lock] //属性 描述 //switch on/off //mode mode: auto, cool, heat, dry, fan //fan high, medium, low, auto //temperature up,down,value //swing up/down/left/right //lock boolean(Lock锁定控制) //地热:trait: [switch, mode, temperature, lock] //属性 描述 //switch on/off //mode day, night,away, vacation, timer //temperature up,down,value //lock boolean(Lock锁定控制) //新风:trait: trait: [switch, mode, fan, lock] //属性 描述 //switch on/off //mode auto, manual, timer //fan high, ,medium, low, auto //lock boolean(Lock锁定控制) //5.1.8 设备sid控制命令 //请求参数 //{ // "vendor_code": "HDL", // "command": "write", // "type": "device_sid", // "objects": [{ // "sid": "00010019101209000025670100010001", // "function": [{ // "attri": "switch", // "data_type": "string ", // "value": "on" // }, { // "attri": "brightness ", //"data_type": "int", // "value": 100 // }] // }] //}} //返回值 json格式;sid和控制结果输出 //例子 //{ // "vendor_code": "HDL", // "command": "write_respond", // "type": "device_sid", // "sid": "00010019101209000025670100010001", // "value": "success" //} //说明 用户控制相应设备, 控制成功后会有另外接口再次更新最终状态 //5.1.9读取设备sid状态 //请求参数 //{ // "vendor_code": "HDL", // "command": "read", // "type": "device_sid", // "objects": [{ // "trait": ["switch", "brightness"], // "sid": "00010019101209000025670100010001" // }] //} //返回值 json格式;sid和状态返回 //例子 //{ // "vendor_code": "HDL", // "type": "device_sid", // "command": "read_respond", // "objects": [{ // "sid": "00010019101209000025670100010001", // "function": [{ // "attri": "switch", //"data_type": "string ", // "value": "on" // }, { // "attri": "brightness", //"data_type": "int", // "value": 100 // }] // }] //} //说明 用户获取设备状态 //5.1.10 设备sid上报状态变化主动广播数据 //发送参数 //{ // "vendor_code": "HDL", // "command": "update", // "type": "device_sid", // "objects": [{ // "sid": "00010019101209000025670100010001", // "function": [{ // "attri": "switch", //"data_type": "string ", // "value": "on" // }] // }, { // "sid": "00010019101209000025670100010002", // "function": [{ // "attri": "switch", //"data_type": "string ", // "value": "on" // }, { // "attri": "brightness", //"data_type": "int", // "value": 100 // }] // }] //} //返回值 无返回 //说明 驱动主动更新设备状态 //5.1.11 删除设备sid //请求参数 //{ // "vendor_code": "HDL", // "command": "delete", // "type": "device_sid", // "objects": [{ // "sid": "00010019101209000025670100010001" // }] //} //返回值 json格式;sid和结果输出 //返回例子 //{ // "vendor_code": "HDL", // "command": "delete_respond", // "type": "device_sid", // "sid": "00010019101209000025670100010001", // "value": "success " //} //说明 用户获取设备状态 //5.1.12添加设备 sid 及属性 //请求参数 //{ // "vendor_code": "HDL", // "command": "add", // "type": "device_sid", // "objects": [{ // "sid": "00010019101209000025670100050001", // "device_type": "light", // "name": "dinning light", // "function": [{ // "attri": "switch", // "value": ["on ", "off "], // "max": 1, // "min": 0 // }] // }] //} //返回值 json格式;sid和结果输出 //返回例子 //{ // "vendor_code": "HDL", // "command": "add_respond", // "type": "device_sid", // "sid": "00010019101209000025670100010001", // "value": "success " //} //5.1.13设备上线离线通知 //请求参数 //{ // "vendor_code": "HDL", // "command": "device_line", // "type": "device_sid", // "objects": [{ // "sid": "00010019101209000025670100010001", // "value": "online " // }, // { // "sid": "00010019101209000025670100010002", // "value": "offline" // } // ] //} //返回值 无返回 //说明 驱动主动更新设备状态 //5.1.14获取场景列表 //请求参数 //{ // "vendor_code": "HDL", // "type": "scene", // "command": "get_list" //} //返回值 json格式 所有场景id及场景里执行的目标数据 //返回例子 //{ // "vendor_code": "HDL", // "command": "get_list_respond", // "type": "scene", // "number": [{ // "scene_id": "0001", // "scene_name": "dinner", // "objects": [{ // "sid": "00010019101209000025670100010001", //"data_type": "string ", // "value": "on" // }] // }] //} //说明 获取场景列表和属性,只开,只关,既开又关 //5.1.15创建场景 //请求参数 //{ // "vendor_code": "HDL", // "command": "create", // "type": "scene", // "objects": [{ // "name": "Away ", // "status": "single_off" // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "create_respond", // "type": "scene", // "objects": [{ // "scene_id": "0004", // "name": "Away", // "status": "single_off", // ‘” // }] //} //说明 创建场景 //5.1.16添加目标到场景 //请求参数 //{ // "vendor_code": "HDL", // "command": "add_member", // "type": "scene", // "number": [{ // "scene_id": "0001", // "objects": [{ // "sid": "00010019101209000025670100010001", // "function": [{ // "attri": "switch", //"data_type": "string ", // "value": "on" // }] // }] // }, { // "scene_id": "0002", // "objects": [{ // "sid": "00010019101209000025670200010001", // "function": [{ // "attri": "brightness", //"data_type": "int", // "value": 50 // }] // }] // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "add_member_respond", // "type": "scene", // "scene_id": "0001", // "value": "success" //} //说明 成功添加目标的场景列表 //5.1.17删除场景命令 //请求参数 //{ // "vendor_code": "HDL", // "command": "delete", // "type": "scene", // "objects": [{ // "scene_id": "0001" // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "delete_respond", // "type": "scene", // "scene_id": "0001", // "value": "success" //} //说明 删除场景 //5.1.18删除场景里的目标 //请求参数 //{ // "vendor_code": "HDL", // "Command": "delete_member", // "type": "scene", // "number": [{ // "scene_id": "0001", // "objects": [{ // "sid": "00010019101209000025670100010001" // }, { // "sid": "00010019101209000025670100010002" // }] // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "delete_member_respond", // "type": "scene", // "scenesid": "0001", // "sid": "00010019101209000025670100010001", // "value": "success" //} //说明 删除场景内设备 //5.1.19配置场景分组(足内场景状态自动记录最后一次记录) //请求参数 { // "vendor_code": "HDL", // "command": "group", // "type": "scene", // "objects": [{ // "group_id": 1, // "scene_ids": [{ // "scene_id": "0001" // }, { // "scene_id": "0002" // }] // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "group_respond", // "type": "scene", // "group_id": "0001", // "value": "success" //} //说明 控制场景 //5.1.20读取场景分组 //请求参数 //{ // "vendor_code": "HDL", // "command": "read_group", // "type": "scene", // "objects": [{ // "group_id": 1 // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "read_group_respond", // "type": "scene", // "objects": [{ // "group_id": 1, // "scene_ids": [{ // "scene_id": "0001" // }, { // "scene_id": "0002" // }] // }] //} //说明 控制场景 //5.1.21控制场景 //请求参数 //{ // "vendor_code": "HDL", // "command": "contrl", // "type": "scene", // "objects": [{ // "scene_id": "0001", // "value": “on” // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "contrl_respond", // "type": "scene", // "scene_id": "0001", // "value": "success" //} //说明 控制场景 //5.1.22自动化 //输入条件 数值 //时间点条件,在某个时间发生 1 //设备状态变化条件 2 //时间段条件 3 //安防条件 4 //用户位置条件 5 //云端天气条件 6 //某个逻辑的输出条件 7 //地理围栏 8 //5.1.23获取自动化列表 //请求参数 //{ // "vendor_code": "HDL", // "command": "get_list", // "type": "logic" //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "get_list_respond", // "type": "logic", // "objects": [{ // "logic_id": "0001", // "logic_relation": "and", // "input": [{ // "sid": "00010019101209000025670400010002", // "condtion_type": 2, // "function": [{ // "attri": "brightness", // "data_type": "int", // "value": 50 // }] // }, // { // "sid": "00010019101209000025670B00020001", // "condtion_type": 2, // "function": [{ // "attri": "temperature", // "data_type": "int", // "value": 23 // }] // } // ], // "output": [{ // "sid": "00010019101209000025670400010003", // "function": [{ // "attri": "brightness", // "data_type": "int", // "value": 50 // }] // }] // }] //} //说明 获取自动化列表 //5.1.24增加逻辑 //请求参数 //{ // "vendor_code": "HDL", // "command": "add", // "type": "logic" //} //返回值 json格式 //返回例子 { //"vendor_code": "HDL", // "command": "add_respond", //"type”:”logic”, //"logic_id": "0001", //} //说明 增加逻辑 //5.1.25 添加目标到逻辑 //请求参数 //{ // "vendor_code": "HDL", // "command": "add_member", // "type": "logic", // "objects": [{ // "logic_id": "0001", // "logic_relation": "and", // "input": [{ // "sid": "00010019101209000025670400010002", // "condtion_type": 2, // "function": [{ // "attri": "brightness", // "data_type": "int", // "value": 50 // }] // }, // { // "sid": "00010019101209000025670B00020001", // "condtion_type": 2, // "function": [{ // "attri": "temperature", // "data_type": "int", // "value": 23 // }] // } // ], // "output": [{ // "sid": "00010019101209000025670400010003", // "function": [{ // "attri": "brightness", // "data_type": "int", // "value": 50 // }] // }] // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "type": "logic", // "command": "add_member_respond", // "logic_id": "0001", // "value": "success" //} //说明 增加设备到逻辑 //5.1.26删除逻辑表里的条件 //请求参数 //{ // "vendor_code": "HDL", // "command": "delete_member", // "type": "logic", // "objects": [{ // "logic_id": "0001", // "input": [{ // "sid": "00010019101209000025670400010002" // }], // "output": [{ // "sid": "00010019101209000025670400010003" // }, // { // "sid": "00010019101209000025670100020001" // } // ] // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "delete_member_respond", // "type": "logic", // "logic_id": "0001", // "value": "success" //} //说明 删除逻辑表里的条件 //5.1.27删除逻辑 //请求参数 //{ // "vendor_code": "HDL", // "command": "delete", // "type": "logic", // "objects": [{ // "logic_id": "0001" // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "delete_respond", // "type": "logic", // "logic_id": "0001", // "value": "success" //} //说明 删除逻辑 //5.1.28读取逻辑状态: //请求参数 { // "vendor_code": "HDL", // "command": "read", // "type": "logic", // "loigic_id": "0001" //} //返回值 json格式, 状态value包括start,stop,pause //返回例子 //{ // "vendor_code": "HDL", // "command": "enable_respond", // "logic_id": "0001", // "value": "start" //} //5.1.29使能逻辑命令: //请求参数 { // "vendor_code": "HDL", // "command": "enable", // "objects": [{ // "logic_id": "0001", // "value": "start" // }] //} //返回值 json格式 value包括start,stop,pause //返回例子 //{ // "vendor_code": "HDL", // "command": "enable_respond", //"logic_id": "0001", //"status" : "success" //} //5.1.30安防 //模式 数值 //在家布防 1 //离家布防 2 //安防区域 数值 //24小时防区 1 //24小时静音防区 2 //出入防区 3 //内部防区 4 //周界防区 5 //5.1.31获取安防列表 //请求参数 //{ // "vendor_code": "HDL", // "command": "get_list", //"type”:”security” //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "get_list_respond", // "objects": [{ // "security_id": 1, //防区类型 //"delay_time”:10 s // "input”:[ //{ //"sid”:”00010019101209000025670400010002”, // "function": [{ // "attri": "contact", //"data_type": "int", // "value": 1 // }] //}, //{"sid”:”00010019101209000025670B00020001”, //"function": [{ // "attri": "temperature", //"data_type": "int", // "value": 24 // }] //}], //"output”:[ //{"sid”:”00010019101209000025670400010003”, //"function": [{ // "attri": "brightness", //"data_type": "int", // "value": 100 // }] //} //] //}] //} //说明 获取安防列表 //5.1.32增加安防命令 //请求参数 //{ // "vendor_code": "HDL", // "command": "create", //"type”:”security”, //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "create_respond", //"type”:”security”, // "security_id":1, // "value” : "success” //} //说明 删除逻辑 //5.1.33添加目标到安防区域 //请求参数 //{ // "vendor_code": "HDL", // "command": "add_member", //"type":"security", // "objects": [{ // "securityId": 1, //"runTime":10 s // "input":[ //{"sid":"00010019101209000025670400010002", // "function": [{ //"attri":"contact", //"value":"on" //}]}, //{"sid":"00010019101209000025670B00020001", // "function": [{ //"attri":"humity", //"value":200 //}]}] //"output":[ //{"sid":"00010019101209000025670400010003", // "function": [{ //"attri":"switch", //"value": "on" //}] //}] //}] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "add_member_respond", //"type":"security", // "security_id":1, // "value" : "success" //} //说明 添加目标到安防 //5.1.34删除安防区域 //请求参数 //{ // "vendor_code": "HDL", // "command": "delete", //"type":"security", // "objects": [{ // "security_id": 1, // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "delete_respond", //"Type":"security", // "security_id": 1", // "value" : "success" //} //5.1.35删除安防区域目标 //请求参数 //{ // "vendor_code": "HDL", // "command": "delete_member", //"type”:”security”, // "objects": [{ // "security_id":1, "input”:[ //{"sid”:”00010019101209000025670400010002”, //}, //{"sid”:”00010019101209000025670B00020001”, //}] //"output”:[ //{"sid”:”00010019101209000025670400010003”, //} //] //}] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "delete_member_respond", //"type”:”security”, // "security_id": 1, // "value” : "success” //} //说明 删除安防内相关条件或者输出 //5.1.36安防控制 //请求参数 //{ // "vendor_code": "HDL", // "type”:”security”, // "command": "write”, // "objects": [{ // "security_id":3, //"mode”:1 // }] //} //返回值 json格式 //返回例子 { // "vendor_code": "HDL", // "command": "write_respond", //"type”:”security”, //"objects": [{ // "security_id":3, // "value” : "success” // }] //} //5.1.37透传数据格式 //请求参数 //{ // "vendor_code": "HDL", // "type": "gate_way", // "command": "through", // “frame”:”C0 A8 01 31 48 44 4C 4D 49 52 41 43 4C 45 AA AA 0C 02 06 02 D6 E3 E7 01 5A 01 2E 18” //} //返回值 json格式 //返回例子 { //"vendor_code": "HDL", //"type": "gate_way", // "command": "through_respond", //"value": "sucess", //} //说明 云端透传数据给网关 //5.1.38网关透传数据给云端 //反馈数据 //{ // "vendor_code": "HDL", //"type": "gate_way", // "command": "through", // “frame”:”C0 A8 01 31 48 44 4C 4D 49 52 41 43 4C 45 AA AA 0C 02 06 02 D6 E3 E7 01 5A 01 2E 18” //} //说明 数据透传,网关本身不做处理 } }