public void Check_DoorWindowSensor_Raised_Closed_Event() { // Arrange var cmd = Helpers .CreateCommand("heartbeat", "magnet", "158d0001233529", 64996, new Dictionary <string, object> { { "voltage", 2985 } }); // Act DoorWindowSensor device = _deviceFactory.GetDeviceByCommand <DoorWindowSensor>(cmd); bool closedRaised = false; device.OnClose += (_, __) => closedRaised = true; cmd = Helpers .CreateCommand("report", "magnet", "158d0001233529", 64996, new Dictionary <string, object> { { "status", "close" } }); device.ParseData(ResponseCommand.FromString(cmd).Data); // Assert Assert.True(closedRaised); }
public void Check_DoorWindowSensor_Report_Data() { // Arrange var cmd = Helpers .CreateCommand("report", "magnet", "158d0001233529", 64996, new Dictionary <string, object> { { "voltage", 2985 }, { "status", "open" }, }); // Act DoorWindowSensor device = _deviceFactory.GetDeviceByCommand <DoorWindowSensor>(cmd); // Assert Assert.Equal("magnet", device.Type); Assert.Equal("158d0001233529", device.Sid); Assert.Equal(2.985f, device.Voltage); Assert.Equal("open", device.Status); }
public static void Initialize(MiLightGateway miLightGateway) { //Sonoff Switches ChristmasLights = new SonoffSwitch("192.168.10.84"); KitchenLights = new SonoffSwitch("192.168.10.81"); GlobusLight = new SonoffSwitch("192.168.10.81"); //TODO IP BedLightBalls = new SonoffSwitch("192.168.10.81"); //TODO IP //Yee Light Devices LightHallway = new YeelightDevice("192.168.10.77", "0x000000000361df8b", false, 0, "mono"); StripeA = new YeelightDevice("192.168.10.75", "0x000000000361afc3", false, 0, "stripe"); StripeB = new YeelightDevice("192.168.10.74", "0x0000000004555e6d", false, 0, "stripe"); //Mi Light Devices BulbA = new MiBulb(miLightGateway, 1); BulbB = new MiBulb(miLightGateway, 2); BulbC = new MiBulb(miLightGateway, 3); //Mi Home Devices DoorBathroom = new DoorWindowSensor("158d0001e037e5") { CustomName = "Badezimmertür" }; ApartmentDoor = new DoorWindowSensor("158d0001a5db48") { CustomName = "Wohnungstür" }; SwitchA = new SimpleSwitch("158d00019dbac7") { CustomName = "Switch A" }; SwitchB = new SimpleSwitch("158d00016da2ed") { CustomName = "Switch B" }; MotionBathroom = new MotionSensor("158d0001d87940") { CustomName = "Motion Bathroom" }; MotionHall = new MotionSensor("158d0001d47c2f") { CustomName = "Motion Hall" }; MotionLivingRoom = new MotionSensor("158d00014dc328") { CustomName = "Motion Living Room" }; SwitchC = new SensorSwitch("158d0001b86fed") { CustomName = "Switch C" }; SwitchD = new SensorSwitch("158d0001b86f59") { CustomName = "SwitchD" }; WaterLeakBathroom = new WaterLeakSensor("158d0001bb89e9") { CustomName = "Water Leak" }; TempSensorLivingRoom = new TempSensor("158d0001b7edbb") { CustomName = "Temperatur Wohnzimmer" }; SwitchE = new DoubleKeySwitch("158d0001718576") { CustomName = "Switch Wandregal" }; }