private void ParseCmnd(string topic, string message) { var entity = BuildEntity <SonoffTasmodaEvent>(); var splittedTele = topic.Split("/"); entity.Name = splittedTele[1]; entity = IoTService.GetEntityByType <SonoffTasmodaEvent>(entity.Name, entity.EntityType); if (entity != null) { var entry = entity.PowerStatuses.FirstOrDefault(e => e.PowerName == splittedTele[2]); if (entry != null) { entry.Status = message; } else { entity.PowerStatuses.Add(new SonoffTasmodaPowerStatus() { PowerName = splittedTele[2], Status = message }); } entity.PowerCount = entity.PowerStatuses.Count; PublishEntity(entity); } }
//static void Main(string[] args) //{ // //Main2(new[] {"-w", "0.1", "-f", "0.5", "-z", "sleep"}); // Main2(Console.ReadLine().Split(' ')); //} static void Main(string[] args) { if (args.Length == 1 && args[0] == "stop") { ZeroVolumeFader.Stop(); } var options = GetOptions(args); ZeroVolumeFader.OnVolumeFaderWaitFinished += async(sender, @event) => await IoTService.TurnOffLightsAsync(); ZeroVolumeFader.OnVolumeFaderEnded += async(sender, @event) => { if ([email protected]) { return; } await IoTService.TurnOffSpeakersAsync(); switch (options.ZeroVolumeAction) { case "sleep": SleepComputer(); break; case "shutdown": ShutdownComputer(); break; } }; ZeroVolumeFader.Run(options.WaitTimeMinutes, options.FadeTimeMinutes); }
/// <summary> /// 初始化IoTObj的動作 /// </summary> /// <param name="strIoTUrl"></param> /// <param name="strDeviceId"></param> /// <param name="strDeviceKey"></param> public IoTObj(string strIoTUrl, string strDeviceId, string strDeviceKey) { this.IoTUrl = strIoTUrl; this.DeviceId = strDeviceId; this.DeviceKey = strDeviceKey; objIoT = new IoTService() { IoTUrl = this.IoTUrl, DeviceId = this.DeviceId, DeviceKey = this.DeviceKey, TransType = Microsoft.Azure.Devices.Client.TransportType.Amqp, }; objIoT.Received += ObjIoT_Received; }
public async Task <bool> SendCommandGroup(string groupName, bool status) { //_localHueClient.SendGroupCommandAsync(new }) var lights = IoTService.GetEntitiesByType <PhilipHueLightEvent>(); lights = lights.Where(p => p.GroupName == groupName).ToList(); if (lights.Any()) { var hueResult = await _localHueClient.SendCommandAsync(new LightCommand() { On = status }, lights.Select(p => p.LightId)); return(true); } return(false); }
public IActionResult OnPostDoorAction(string data) { var device = new IoTService(serviceConnStr); switch (data) { case "up": device.DoorUp(); break; case "down": device.DoorDown(); break; case "stop": device.DoorStop(); break; default: return(BadRequest()); } return(Page()); }
public Startup(IoTService _IoTService, IGPIOControlService _GPIOControlService) { IoTService = _IoTService; GPIOControlService = _GPIOControlService; }
public void DoorStop() { var iotService = new IoTService(ConnStr); iotService.DoorStop(); }
public ValuesController(IoTService ioTService) { _ioTService = ioTService; }
protected async void PublishEntity <T>(T entity) where T : class, INeonIoTEntity { await IoTService.PersistEntity(entity); }