public void SetColor(TrustColorRgb color) { var value = new TrustXyValue(color.ToXyz().ToYxy()); var result = value.ToValue(); var command = TrustCommand.SimpleCommand(Home.Mac, Home.AesKey, Convert.ToInt32(Id), 5, result); TrustHttp.SendCommand(Home.Mac, Hub.Email, Hub.Password, command); }
public static TrustCommand SimpleCommand(string mac, string aes, int entity, int function, long value) { var command = new TrustCommand(); command.SetMac(mac); command.SetType(128); command.SetMagic(); command.SetEntityId(entity); command.SetData("{\"module\":{\"id\":" + entity + ",\"function\":" + function + ",\"value\":" + value + "}}", aes); return(command); }
public static void SendCommand(string macAddress, string email, string password, TrustCommand command) { var trustParams = new TrustHttpParams { TrustHttpParamDictionary = { ["action"] = "add", ["email"] = email, ["device_unique_id"] = "android", ["mac"] = macAddress.Replace(":", ""), ["password_hash"] = password, ["command"] = command.GetCommand() } }; var(responseText, _, _) = MakeRequest("command.php", trustParams); Debug.WriteLine(responseText); //throw new TrustHttpError(codeDescription, code); }
public void TurnOff() { var command = TrustCommand.SimpleCommand(Home.Mac, Home.AesKey, Convert.ToInt32(Id), 3, 0); TrustHttp.SendCommand(Home.Mac, Hub.Email, Hub.Password, command); }