protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var networks = context.Networks; var streamStore = context.StreamStore; var ip = context.ReadParameter("IP").Value; var appDataRepository = new AppDataRepository(streamStore); var appData = appDataRepository.Load(); if (string.IsNullOrEmpty(ip)) { interpreter.WriteEvent("Searching for Hue bridge..."); ip = FindIp(); interpreter.WriteEvent("Found " + ip); } var networkContext = new HomeAutomationNetworkContext(context.Engine, context.ThreadPool); var network = new Q42HueNetwork(networkContext, ip, appData, () => interpreter.WriteEvent("Press the link button on the Hue bridge.")); networks.Add(network); appDataRepository.Save(appData); interpreter.WriteEvent("Done."); }
protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context) { var network = context.Network; var interpreter = context.Interpreter; var history = network.Context.History; WriteHistory(history, interpreter); }
protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var network = context.Network as WeMoNetwork; var ip = context.ReadParameter("IP").Value; network.Connect(ip); }
protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context) { var network = context.Network; foreach (var device in network.Devices) { device.Poll(); } }
protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context) { var network = context.Network as Q42HueNetwork; foreach (var device in network.Devices) { PushName(device as Q42HueDevice); } }
protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var network = context.Network; var poll = context.ReadParameter("Poll").ToBoolean(); //TODO: list all devices on all networks. //TODO: add type const string addressLabel = "Address"; const string typeLabel = "Type"; const string connectedLabel = "Connected"; const string statusLabel = "Status"; var addressLength = addressLabel.Length; var typeLength = typeLabel.Length; var connectedLength = connectedLabel.Length; var statusLength = statusLabel.Length; foreach (var device in network.Devices) { addressLength = Math.Max(addressLength, device.BuildVirtualAddress(false, false).Length); typeLength = Math.Max(typeLength, device.Type.Name.Length); statusLength = Math.Max(statusLength, device.Describe().Length); } var tableBuilder = new TextTable(new[] { addressLength, typeLength, connectedLength, statusLength }); interpreter.WriteEvent(tableBuilder.StartOfTable(addressLabel, typeLabel, connectedLabel, statusLabel)); foreach (var device in network.Devices) { var address = device.BuildVirtualAddress(false, false); if (poll) { try { device.Poll(); } catch { } } var status = device.Describe(); var connected = (device.IsConnected == true)?"Yes":" - "; interpreter.WriteEvent(tableBuilder.ContentLine(address, device.Type, connected, status)); } interpreter.WriteEvent(tableBuilder.EndOfTable()); }
protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var networks = context.Networks; foreach (var network in networks) { interpreter.WriteEvent("Saving " + network.Name); network.Save(); } }
protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var network = context.Network as OpenZWaveNetwork; interpreter.WriteEvent("Resetting Network " + network); network.Reset(); interpreter.WriteEvent("Done"); }
protected override void Execute_Definition(RoomieCommandContext context) { var homeAutomationContext = new HomeAutomationCommandContext(context); var zWaveNetworks = homeAutomationContext.Networks.OfType <ZWaveNetwork>(); var workQueues = zWaveNetworks.Select(x => x.WorkQueue); foreach (var workQueue in workQueues) { workQueue.ShutDown(); } }
protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var networks = context.Networks; var networkContext = new HomeAutomationNetworkContext(context.Engine, context.ThreadPool); var network = new WeMoNetwork(networkContext); networks.Add(network); interpreter.WriteEvent("Done."); }
protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var network = context.Network as OpenZWaveNetwork; var returnRoute = context.ReadParameter(ReturnRouteKey).ToBoolean(); interpreter.WriteEvent("Optimizing " + network); network.OptimizePaths(returnRoute); interpreter.WriteEvent("Done"); }
protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var networks = context.Networks; interpreter.WriteEvent("Searching for Z-Wave network adapater..."); var network = new ZWaveNetwork(new HomeAutomationNetworkContext(context.Engine, context.ThreadPool)); networks.Add(network); interpreter.WriteEvent("Done."); }
protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var networks = context.Networks; var address = context.ReadParameter("Address").Value; interpreter.WriteEvent("Searching for PiEngineering devices"); var network = new PiEngineeringNetwork(new HomeAutomationNetworkContext(context.Engine, context.ThreadPool), address); networks.Add(network); interpreter.WriteEvent("Done."); }
protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var threads = context.ThreadPool; interpreter.WriteEvent("shutting down Home Automation..."); threads.ShutDown(); var subinterpreter = interpreter.GetSubinterpreter(); var saveDataScriptCommand = context.GetBlankCommand(typeof(SaveData)); subinterpreter.CommandQueue.Add(saveDataScriptCommand); subinterpreter.ProcessQueue(); interpreter.WriteEvent("done shutting down home automation."); }
protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var network = context.Network; interpreter.WriteEvent("Waiting for device. Press its button to remove it from its network."); var device = network.RemoveDevice(); interpreter.WriteEvent("Device removed: " + device); if (WebHookConnector.WebHookPresent(context)) { context.AddSyncWithCloud(); } }
protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var network = context.Network; interpreter.WriteEvent("Syncing Home Automation Devices with the cloud..."); Message request = buildRequest(network); Message response = WebHookConnector.SendMessage(context, request); //TODO: use LINQ? foreach (var deviceElement in response.Payload) { if (deviceElement.Name.LocalName != "HomeAutomationDevice") { throw new RoomieRuntimeException("Received unexpected data while gettings tasks. XML node named \"" + deviceElement.Name + "\""); } string networkAddress = deviceElement.Attribute("Address").Value; if (network.Devices.ContainsAddress(networkAddress)) { var device = network.Devices.GetDevice(networkAddress); if (deviceElement.Attribute("Name") != null) { device.Name = deviceElement.Attribute("Name").Value; } //TODO: improve this if (deviceElement.Attribute("Location") != null) device.Location.Update(deviceElement.Attribute("Location").Value); //TODO: type checking if(deviceElement.Attribute("Type") != null) device.Type = DeviceType.GetTypeFromString(deviceElement.Attribute("Type").Value); } else { interpreter.WriteEvent("**WebHook returned a device (network address=" + networkAddress + ") that does not exist.**"); } } interpreter.WriteEvent("...done"); }
protected override void Execute_HomeAutomationDefinition(HomeAutomationCommandContext context) { var interpreter = context.Interpreter; var networks = context.Networks; var port = context.ReadParameter("Port").Value; if (port.StartsWith("COM", StringComparison.InvariantCultureIgnoreCase)) { port = @"\\.\" + port; } interpreter.WriteEvent("Searching for Z-Wave network adapater at " + port + "..."); var network = new OpenZWaveNetwork(new HomeAutomationNetworkContext(context.Engine, context.ThreadPool), port); networks.Add(network); interpreter.WriteEvent("Done."); }
public HomeAutomationSingleDeviceContext(HomeAutomationCommandContext context) : base(context) { }
protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context) { context.AddSyncWithCloud(); }
protected override void Execute_HomeAutomationNetworkDefinition(HomeAutomationCommandContext context) { var network = context.Network as Q42HueNetwork; network.UpdateList(); }