/// <summary> /// Execute a function on a device /// </summary> /// <param name="context">The user context.</param> /// <param name="deviceData">The device data.</param> /// <param name="function">The function to execute.</param> /// <param name="argument">The argument to the function</param> /// <returns> /// A task. /// </returns> public Task ExecuteFunction(UserContext context, DeviceImport deviceData, DeviceFunction function, object argument) { // Get the device meta for execute var meta = LifxMetaData.FromString(deviceData.MetaData); return(Handlers.ExecuteFunction(context, meta, function, argument)); }
/// <summary> /// Check if two devices are the same devices within griddle /// </summary> /// <param name="a">The a.</param> /// <param name="b">The b.</param> /// <returns> /// True if the devices are the same physical device. False otherwise. /// </returns> public bool Compare(DeviceImport a, DeviceImport b) { var aData = LifxMetaData.FromString(a.MetaData); var bData = LifxMetaData.FromString(b.MetaData); return(string.Equals(aData.Id, bData.Id, StringComparison.Ordinal) && string.Equals(aData.UUID, bData.UUID, StringComparison.Ordinal)); }
/// <summary> /// Load a device from the json return /// </summary> /// <param name="json">The json string</param> /// <returns>A device import object</returns> public static DeviceImport LoadFromJson(JToken json) { var name = json["label"].ToString(); var descriptor = json["product"]["identifier"].ToString(); var meta = new LifxMetaData(json["id"].ToString(), json["uuid"].ToString()); var state = Helpers.LoadDeviceState(json); return(new DeviceImport(name, descriptor, meta.GetXmlString(), state)); }