public async Task TestThermostats() { var(result, status) = await _zipato.DataReadThermostatsAsync(); Assert.Equal(DataValue.Good, status); Assert.NotEmpty(result); }
public async Task <IActionResult> GetThermostatsAsync(bool update = false) { try { _logger?.LogDebug("GetThermostatsAsync()..."); if (!_zipato.IsLocked) { return(StatusCode(StatusCodes.Status406NotAcceptable, "Locked: update not yet finished.")); } if (update) { var(thermostats, status) = await _zipato.DataReadThermostatsAsync(); if (status.IsGood) { return(Ok(thermostats)); } else { return(StatusCode(StatusCodes.Status502BadGateway, status)); } } else { var thermostats = _zipato.Data.Thermostats.Select(s => s.ToThermostatData()).ToList(); return(Ok(thermostats)); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }