Ejemplo n.º 1
0
        public TurnOffDeviceMessage TurnOffDevice(string deviceId)
        {
            CheckDevice(deviceId);
            var response = PimaticRestClient.PerformHttpGet("/api/device/" + deviceId + "/turnOff");

            return(JsonConvert.DeserializeObject <TurnOffDeviceMessage>(GetResultMessage(response)));
        }
Ejemplo n.º 2
0
        public Device RemoveDevice(string deviceId)
        {
            CheckDevice(deviceId);
            var response = PimaticRestClient.PerformHttpDelete("/api/device-config/" + deviceId);

            return(JsonConvert.DeserializeObject <Device>(GetResultMessage(response)));
        }
Ejemplo n.º 3
0
        public void Restart()
        {
            var content = new StringContent(string.Empty, Encoding.UTF8, "application/json");

            PimaticRestClient.Login()
            .PostAsync("http://" + PimaticSettings.Server + ":" + PimaticSettings.Port + "/api/restart", content);
        }
Ejemplo n.º 4
0
        public RemoveDeviceFromPageMessage RemoveDeviceFromPage(string pageId, string deviceId)
        {
            _checkPage(pageId);
            var response = PimaticRestClient.PerformHttpDelete("/api/pages/" + pageId + "/devices/" + deviceId);

            return(JsonConvert.DeserializeObject <RemoveDeviceFromPageMessage>(GetResultMessage(response)));
        }
Ejemplo n.º 5
0
        public AddDeviceToPageMessage AddDeviceToPage(string pageId, string deviceId)
        {
            _checkPage(pageId);
            var response = PimaticRestClient.PerformHttpPost("/api/pages/" + pageId + "/devices/" + deviceId);

            return(JsonConvert.DeserializeObject <AddDeviceToPageMessage>(GetResultMessage(response)));
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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)));
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        public GetVariablesMessage GetVariables()
        {
            var response = PimaticRestClient.PerformHttpGet("/api/variables");

            return(JsonConvert.DeserializeObject <GetVariablesMessage>(GetResultMessage(response)));
        }
Ejemplo n.º 11
0
        public GetDeviceClassConfigSchemaMessage GetDeviceClassConfigSchema(string className)
        {
            var response = PimaticRestClient.PerformHttpGet("/api/device-class/" + className);

            return(JsonConvert.DeserializeObject <GetDeviceClassConfigSchemaMessage>(GetResultMessage(response)));
        }
Ejemplo n.º 12
0
        public GetGuiSettingsMessage GetGuiSetttings()
        {
            var response = PimaticRestClient.PerformHttpGet("/api/config/settings/gui");

            return(JsonConvert.DeserializeObject <GetGuiSettingsMessage>(GetResultMessage(response)));
        }
Ejemplo n.º 13
0
        public GetConfigMessage GetConfig()
        {
            var response = PimaticRestClient.PerformHttpGet("/api/config?password=" + PimaticSettings.Password);

            return(JsonConvert.DeserializeObject <GetConfigMessage>(GetResultMessage(response)));
        }