From c96d59d6b6379acb0fd899ad2e255a121ee6c8c6 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期五, 18 十二月 2020 10:45:20 +0800
Subject: [PATCH] 20201218-1

---
 HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
index ea6db63..39ecc10 100644
--- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
+++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
@@ -217,9 +217,26 @@
                 new System.Threading.Thread(() =>
                 {
                     function.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
-                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                    d.Add("on_off", function.trait_on_off.curValue.ToString());
-                    Control.Ins.SendWriteCommand(function, d);
+                    Dictionary<string, string> d = new Dictionary<string, string>();
+                    if (function.spk == SPK.LightDimming || function.spk == SPK.LightRGB)
+                    {
+                        var light = function as Light;
+                        d.Add(FunctionAttributeKey.OnOff, light.trait_on_off.curValue.ToString());
+                        if (btnSwitch.IsSelected)
+                        {
+                            d.Add(FunctionAttributeKey.Brightness, light.lastBrightness.ToString());
+                        }
+                        else
+                        {
+                            light.lastBrightness = light.brightness;
+                        }
+                        Control.Ins.SendWriteCommand(light, d);
+                    }
+                    else
+                    {
+                        d.Add("on_off", function.trait_on_off.curValue.ToString());
+                        Control.Ins.SendWriteCommand(function, d);
+                    }
                 })
                 { IsBackground = true }.Start();
             };
@@ -348,11 +365,8 @@
                                 {
                                     ShowMesBtnState(pushMessageInfoList[0], true);
                                 });
-                               
                             }
-
                         }
-
                     }
                     else
                     {
@@ -366,9 +380,7 @@
                 {
                     isGetting = false;
                 }
-
             });
-
         }
 
         /// <summary>

--
Gitblit v1.8.0