public TurnOffDeviceMessage TurnOffDevice(string deviceId) { CheckDevice(deviceId); var response = PimaticRestClient.PerformHttpGet("/api/device/" + deviceId + "/turnOff"); return(JsonConvert.DeserializeObject <TurnOffDeviceMessage>(GetResultMessage(response))); }
public Device RemoveDevice(string deviceId) { CheckDevice(deviceId); var response = PimaticRestClient.PerformHttpDelete("/api/device-config/" + deviceId); return(JsonConvert.DeserializeObject <Device>(GetResultMessage(response))); }
public void Restart() { var content = new StringContent(string.Empty, Encoding.UTF8, "application/json"); PimaticRestClient.Login() .PostAsync("http://" + PimaticSettings.Server + ":" + PimaticSettings.Port + "/api/restart", content); }
public RemoveDeviceFromPageMessage RemoveDeviceFromPage(string pageId, string deviceId) { _checkPage(pageId); var response = PimaticRestClient.PerformHttpDelete("/api/pages/" + pageId + "/devices/" + deviceId); return(JsonConvert.DeserializeObject <RemoveDeviceFromPageMessage>(GetResultMessage(response))); }
public AddDeviceToPageMessage AddDeviceToPage(string pageId, string deviceId) { _checkPage(pageId); var response = PimaticRestClient.PerformHttpPost("/api/pages/" + pageId + "/devices/" + deviceId); return(JsonConvert.DeserializeObject <AddDeviceToPageMessage>(GetResultMessage(response))); }
public GetDevicesMessage GetDevices() { var response = PimaticRestClient.PerformHttpGet("/api/devices"); var devices = JsonConvert.DeserializeObject <GetDevicesMessage>(GetResultMessage(response)); if (!devices.devices.Any() || devices.devices == null) { throw new PimaticException("E_PIM_SVC.003", "No devices found"); } return(devices); }
public GetDeviceByIdMessage GetDeviceById(string deviceId) { var response = PimaticRestClient.PerformHttpGet("/api/devices/" + deviceId); var device = JsonConvert.DeserializeObject <GetDeviceByIdMessage>(GetResultMessage(response)); if (device != null) { if (device.device == null) { throw new PimaticException("E_PIM_SVC.005", "Device could not be found for deviceId {0}", deviceId); } } return(device); }
public Device AddDeviceByConfig(Config config) { if (GetDevices().devices.Any(s => s.id == config.id)) { throw new PimaticException("E_PIM_SVC.001", "Device with id {0} already exists in config file", config.id); } var addDeviceByConfigMessage = new AddDeviceByConfigMessage { deviceConfig = config }; var response = PimaticRestClient.PerformHttpPost(addDeviceByConfigMessage, "/api/device-config"); return(JsonConvert.DeserializeObject <Device>(GetResultMessage(response))); }
public GetPageByIdMessage GetPageById(string pageId) { var response = PimaticRestClient.PerformHttpGet("/api/pages/" + pageId); var getPageByIdMessage = JsonConvert.DeserializeObject <GetPageByIdMessage>(GetResultMessage(response)); if (getPageByIdMessage != null) { if (getPageByIdMessage.page == null) { throw new PimaticException("E_PIM_SVC.004", "Page for pageId {0} could not be captured", pageId); } } return(getPageByIdMessage); }
public GetVariablesMessage GetVariables() { var response = PimaticRestClient.PerformHttpGet("/api/variables"); return(JsonConvert.DeserializeObject <GetVariablesMessage>(GetResultMessage(response))); }
public GetDeviceClassConfigSchemaMessage GetDeviceClassConfigSchema(string className) { var response = PimaticRestClient.PerformHttpGet("/api/device-class/" + className); return(JsonConvert.DeserializeObject <GetDeviceClassConfigSchemaMessage>(GetResultMessage(response))); }
public GetGuiSettingsMessage GetGuiSetttings() { var response = PimaticRestClient.PerformHttpGet("/api/config/settings/gui"); return(JsonConvert.DeserializeObject <GetGuiSettingsMessage>(GetResultMessage(response))); }
public GetConfigMessage GetConfig() { var response = PimaticRestClient.PerformHttpGet("/api/config?password=" + PimaticSettings.Password); return(JsonConvert.DeserializeObject <GetConfigMessage>(GetResultMessage(response))); }