private async Task UserConnected(string payload) { //TODO try catch serializer can crash LightPoint lightPointSwitch = JsonConvert.DeserializeObject <LightPoint>(payload); try { var lightPoint = await _restClient.GetLightPoints(Guid.Parse(lightPointSwitch.Id)); if (lightPoint.CustomName == null) { var lightBulb = new List <LightBulbDto>(); foreach (var id in lightPointSwitch.BulbsId) { lightBulb.Add(new LightBulbDto() { Id = Guid.Parse(id) }); } var lightPointDto = new LightPointDto() { CustomName = lightPointSwitch.CustomName, Id = Guid.Parse(lightPointSwitch.Id), LightBulbs = lightBulb }; //TODO auto generation of guid and saving to memeory of rPi await _restClient.AddLightPoint(Guid.Parse(_settings.HomeAutomationLightingSystemId), lightPointDto); } else { await _restClient.EnableLightPoint(Guid.Parse(lightPointSwitch.Id)); } } catch (Exception ex) { Console.WriteLine(ex); } }