public object ZoneSwitch(int selecteId, int zoneId, ZoneStatus status) { var result = _client.ConnectAndSend(_atMessages.GetInitMsg()); var parser = new MessageResponseParser(); var at = parser.Parse(result); var zone = at.GetSelectedAircon().GetZoneById(zoneId); if (zone != null && zone.Status != status) { result = _client.ConnectAndSend(_atMessages.ToggleZone(zoneId)); at = parser.Parse(result); } else { if (zone == null) { throw new Exception("Failed to find selected zone"); } } var response = System.Text.Json.JsonSerializer.Serialize <AirTouchSystem>(at, _serializeOptions); Log.ForContext <VzduchDotekController>().Verbose("{@AirTouchSystem}", at); return(Content(response, "application/json")); }
public object Toggle() { var result = _client.ConnectAndSend(_atMessages.GetInitMsg()); var parser = new MessageResponseParser(); var at = parser.Parse(result); result = _client.ConnectAndSend(_atMessages.ToggleAcOnOff(at.SelectedAc)); at = parser.Parse(result); var response = System.Text.Json.JsonSerializer.Serialize <AirTouchSystem>(at, _serializeOptions); Log.ForContext <VzduchDotekController>().Verbose("{@AirTouchSystem}", at); return(Content(response, "application/json")); }
public object SetTemperature(int selecteId, AcTemperature incDec) { var result = _client.ConnectAndSend(_atMessages.GetInitMsg()); var parser = new MessageResponseParser(); var at = parser.Parse(result); var ac = at.GetSelectedAircon(); if (ac != null) { result = _client.ConnectAndSend(_atMessages.SetNewTemperature(at.SelectedAc, (int)incDec)); at = parser.Parse(result); } else { throw new Exception("Failed to find selected aircon unit"); } var response = System.Text.Json.JsonSerializer.Serialize <AirTouchSystem>(at, _serializeOptions); Log.ForContext <VzduchDotekController>().Verbose("{@AirTouchSystem}", at); return(Content(response, "application/json")); }