예제 #1
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)));
        }
예제 #2
0
        public GetDeviceClassesMessage GetDeviceClasses()
        {
            var response = PimaticRestClient.PerformHttpGet("/api/device-class");

            return(JsonConvert.DeserializeObject <GetDeviceClassesMessage>(GetResultMessage(response)));
        }
예제 #3
0
        public GetDeviceByIdMessage GetDeviceById(string deviceId)
        {
            var response = PimaticRestClient.PerformHttpGet("/api/devices/" + deviceId);

            return(JsonConvert.DeserializeObject <GetDeviceByIdMessage>(GetResultMessage(response)));
        }
예제 #4
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);
        }
예제 #5
0
        public Device RemoveDevice(string deviceId)
        {
            var response = PimaticRestClient.PerformHttpDelete("/api/device-config/" + deviceId);

            return(JsonConvert.DeserializeObject <Device>(GetResultMessage(response)));
        }
예제 #6
0
        //TODO NICOLAS Create Object for GetConfig
        public GetConfigMessage GetConfig()
        {
            var response = PimaticRestClient.PerformHttpGet("/api/config?password=" + PimaticSettings.Password);

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