var module = Modules.WithName("Light 1").Get(); // Create the UPnP device to control the 'module' var localDevice = UPnPDevice.CreateRootDevice(120, 2, "web\\"); localDevice.FriendlyName = "WeMo Switch"; localDevice.Manufacturer = "Belkin International Inc."; localDevice.ManufacturerURL = "http://www.belkin.com"; localDevice.ModelName = "Socket"; localDevice.ModelDescription = "Belkin Emulated Plugin Socket 1.0"; localDevice.Major = 1; localDevice.Minor = 0; localDevice.ModelNumber = "1234"; localDevice.StandardDeviceType = "urn:Belkin:device:controllee"; //localDevice.UniqueDeviceName = "uniqueDeviceName"; // Create an instance of the BasicEvent service dynamic serviceInstance = new ExpandoObject(); serviceInstance.GetBinaryState = new Func<int>(() => { return module.IsOn ? 1 : 0; }); serviceInstance.SetBinaryState = new Func<int, int>((binaryState) => { if (binaryState == 1) module.On(); else module.Off(); return binaryState; }); // this is just a test method could be removed serviceInstance.Echo = new Func<string, string>((message) => { return message; }); // Declare the "BasicEvent1" service var service = new UPnPService( // Version 1.0, // Service ID "urn:Belkin:serviceId:basicevent1", // Service Type "urn:Belkin:service:basicevent:1", // Standard Service? true, // Service Object Instance serviceInstance ); // Add the methods service.AddMethod("Echo"); service.AddMethod("GetBinaryState"); service.AddMethod("SetBinaryState"); // Add the service localDevice.AddService(service); // Start the WeMo switch device UPnP simulator localDevice.StartDevice(); When.ProgramStopping(()=>{ localDevice.StopDevice(); return true; }); Program.GoBackground(); [] HomeAutomation.HomeGenie.Automation
1000
UPnP Test for Alexa Emulates a Belkin Switch so that it can be discovered by Alexa. Demo false CSharp false