protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context) { var currentAction = context.ReadParameter("CurrentAction").Value; var originalCommand = context.OriginalCommand; var commands = originalCommand.InnerCommands; var device = context.Device; var network = device.Network; var triggers = network.Context.Triggers; var history = network.Context.History; var threadPool = network.Context.ThreadPool; var trigger = new WhenTheCurrentActionChangesTrigger(device, currentAction, history.DeviceEvents); var action = new RunScriptTriggerAction(threadPool, commands); var triggerBundle = new TriggerBundle(trigger, action); triggers.Add(triggerBundle); }
protected override void Execture_HomeAutomationSingleDeviceDefinition(HomeAutomationSingleDeviceContext context) { var target = context.ReadParameter("Target").ToHumidity(); var originalCommand = context.OriginalCommand; var commands = originalCommand.InnerCommands; var device = context.Device; var network = device.Network; var triggers = network.Context.Triggers; var history = network.Context.History; var threadPool = network.Context.ThreadPool; var trigger = new WhenHumidityFallsBelowValueTrigger(device, target, history.DeviceEvents); var action = new RunScriptTriggerAction(threadPool, commands); var triggerBundle = new TriggerBundle(trigger, action); triggers.Add(triggerBundle); }