| | |
| | | /// </summary> |
| | | public void ControlScene(Scene scene) |
| | | { |
| | | //体验模式 |
| | | if(MainPage.NoLoginMode) |
| | | { |
| | | foreach(var sceneFunction in scene.functions) |
| | | { |
| | | var revString = ""; |
| | | var upDataObj = new AlinkFunctionStatusObj(); |
| | | upDataObj.id = "999"; |
| | | upDataObj.objects = new List<AlinkStatusData>(); |
| | | var asd = new AlinkStatusData() { deviceId = sceneFunction.localFunction.deviceId, sid = sceneFunction.sid }; |
| | | var status1 = new List<AttributesStatus>(); |
| | | foreach (var dic in sceneFunction.status) |
| | | { |
| | | status1.Add(new AttributesStatus() { key = dic.key, value = dic.value }); |
| | | } |
| | | asd.status = status1; |
| | | upDataObj.objects.Add(asd); |
| | | revString = Newtonsoft.Json.JsonConvert.SerializeObject(upDataObj); |
| | | UpdataFunctionStatus(revString, null, true); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | //远程或者控制link网关场景 |
| | | if (!Ins.GatewayOnline_Local || DB_ResidenceData.Instance.GatewayType == 1) |
| | | { |
| | | new System.Threading.Thread(() => |
| | |
| | | } |
| | | } |
| | | |
| | | ///dome控制 |
| | | if (MainPage.NoLoginMode) |
| | | { |
| | | var revString = ""; |
| | | var upDataObj = new AlinkFunctionStatusObj(); |
| | | upDataObj.id = "999"; |
| | | upDataObj.objects = new List<AlinkStatusData>(); |
| | | var asd = new AlinkStatusData() { deviceId = function.deviceId, sid = function.sid }; |
| | | var status1 = new List<AttributesStatus>(); |
| | | foreach (var dic in commandDictionary) |
| | | { |
| | | status1.Add(new AttributesStatus() { key = dic.Key, value = dic.Value }); |
| | | } |
| | | asd.status = status1; |
| | | upDataObj.objects.Add(asd); |
| | | revString = Newtonsoft.Json.JsonConvert.SerializeObject(upDataObj); |
| | | UpdataFunctionStatus(revString, null, true); |
| | | return; |
| | | } |
| | | |
| | | |
| | | //MainPage.Log($"发送数据:{Newtonsoft.Json.JsonConvert.SerializeObject(commandDictionary)}"); |
| | | |
| | | ///第三方涂鸦设备统一使用远程控制 |
| | | switch(function.spk) |
| | | switch (function.spk) |
| | | { |
| | | case SPK.ElectricTuyaAirCleaner: |
| | | case SPK.ElectricTuyaFan: |
| | |
| | | /// </summary> |
| | | public void SwtichFunctions(bool open,List<Function> functions) |
| | | { |
| | | //dome模式控制 |
| | | if(MainPage.NoLoginMode) |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | foreach (var temp in functions) |
| | | { |
| | | Dictionary<string, string> d1 = new Dictionary<string, string>(); |
| | | d1.Add(FunctionAttributeKey.OnOff, open ? "on" : "off"); |
| | | SendWriteCommand(temp, d1); |
| | | System.Threading.Thread.Sleep(100); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | return; |
| | | } |
| | | |
| | | var count = 0; |
| | | var logString = open ? "打开\r\n" : "关闭\r\n"; |
| | | List<ApiAlinkControlActionObj> actionObjs = new List<ApiAlinkControlActionObj>(); |
| | |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 转换通讯数据 |
| | | /// 转换发送数据 |
| | | /// </summary> |
| | | public byte[] ConvertSendBodyData(string topic, string bodyDataString) |
| | | { |
| | |
| | | /// <param name="updateBytes"></param> |
| | | public void UpdataFunctionStatus(string revString, byte[] usefulBytes,bool isCloudData = false) |
| | | { |
| | | |
| | | if (Ins.GatewayOnline_Local && isCloudData)//本地链接,除了涂鸦设备数据之外的云端数据不处理 |
| | | { |
| | | if (FunctionList.List.GetDeviceFunctionList(SPK.BrandType.Tuya).Count == 0) |
| | | { |
| | | //MainPage.Log($"A协议更新状态:本地链接,除了涂鸦设备数据之外的云端数据不处理..."); |
| | | return; |
| | | } |
| | | } |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString); |
| | | if (temp != null) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | if (Ins.GatewayOnline_Local && isCloudData)//本地链接,除了涂鸦设备数据之外的云端数据不处理 |
| | | { |
| | | if (FunctionList.List.OtherBrandFunction.Count != 0) |
| | | { |
| | | if (FunctionList.List.OtherBrandFunction.Find((obj) => obj.sid == updateTemp.sid) == null) |
| | | { |
| | | //MainPage.Log($"A协议更新状态:本地链接,除了涂鸦设备数据之外的云端数据不处理..."); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | var localFunction = allLocalFuntion.Find((obj) => obj.sid == updateTemp.sid); |
| | | if (localFunction == null) |
| | | { |