示例#1
0
        public IOBrokerJSONSet SetIOBrokerValue(string objectId, int zielwert)
        {
            try
            {
                if (DNSHelper.GetIP(IOBrokerHost) == null)
                {
                    return(null);
                }

                string zielwertString = zielwert.ToString();


                //zwave2.0.Node_003.Multilevel_Sensor.humidity
                using (WebClient wc = new WebClient())
                {
                    IOBrokerJSONSet ioJson = new IOBrokerJSONSet();

                    string downString = IOBrokerSetApi() + System.Web.HttpUtility.UrlEncode(objectId) + "?value=" + System.Web.HttpUtility.UrlEncode(zielwertString);
                    Console.WriteLine("Download String '{0}'", downString);

                    var json = wc.DownloadString(downString);
                    ioJson = JsonConvert.DeserializeObject <IOBrokerJSONSet>(json);
                    return(ioJson);
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine("Fehler beim schreiben von IOBroker Microservice", ex);
                throw;
            }
        }
示例#2
0
        public IOBrokerJSONGet GetIOBrokerValue(string objectId)
        {
            try
            {
                if (DNSHelper.GetIP(IOBrokerGetHost) == null)
                {
                    return(null);
                }

                //zwave2.0.Node_003.Multilevel_Sensor.humidity
                using (WebClient wc = new WebClient())
                {
                    IOBrokerJSONGet ioJson = new IOBrokerJSONGet();

                    string downString = IOBrokerGetApi() + System.Web.HttpUtility.UrlEncode(objectId);
                    //Console.WriteLine("Download String '{0}'", downString);

                    var json = wc.DownloadString(downString);
                    ioJson = JsonConvert.DeserializeObject <IOBrokerJSONGet>(json);
                    //Console.WriteLine("result value {0}", ioJson.val);
                    Console.WriteLine("Download String '{0}', Result: {1}", downString, ioJson.val);
                    return(ioJson);
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine("Fehler beim lesen von IOBroker", ex);
                throw;
            }
        }