Exemplo n.º 1
0
        public static Humidity_Device ConvertToHumidityDevice(ShellyCloudResponse objectToConvert)
        {
            Humidity_Device tempHygro = new Humidity_Device
            {
                Id   = 6,
                Name = "Luftfeuchtigkeit",
                Icon = "~/content/images/humidity.png",
                HumidityInPercent = objectToConvert.data.device_status.hum.value + "%",
                HumidityValue     = objectToConvert.data.device_status.hum.value
            };

            return(tempHygro);
        }
Exemplo n.º 2
0
        private static void CollectData()
        {
            Console.WriteLine("CollectData...");
            bool collected = false;

            try
            {
                MyStromConnector licht     = new MyStromConnector("192.168.1.206");
                MyStromConnector umLuft    = new MyStromConnector("192.168.1.108");
                MyStromConnector abLuft    = new MyStromConnector("192.168.1.241");
                MyStromConnector watering  = new MyStromConnector("192.168.1.109");
                ShellyConnector  tempHygro = new ShellyConnector("192.168.1.187");

                Watering = DataConverter.ConvertToWateringDevice(watering.Get());
                Light    = DataConverter.ConvertToLightDevice(licht.Get());
                FanIn    = DataConverter.ConvertToFanDevice(umLuft.Get());
                Suction  = DataConverter.ConvertToSuctionDevice(abLuft.Get());

                var tempHygroValue = tempHygro.Get();
                Temperature = DataConverter.ConvertToTemperatureDevice(tempHygroValue);
                Humidity    = DataConverter.ConvertToHumidityDevice(tempHygroValue);

                collected = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("DATACOLLECTOR FAILED");
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }

            if (collected)
            {
                _gateway.AddData(5, Watering.Name, Watering.PowerValue.ToString(), DateTime.Now.ToString());
                _gateway.AddData(1, Light.Name, Light.PowerValue.ToString(), DateTime.Now.ToString());
                _gateway.AddData(3, FanIn.Name, FanIn.PowerValue.ToString(), DateTime.Now.ToString());
                _gateway.AddData(4, Suction.Name, Suction.PowerValue.ToString(), DateTime.Now.ToString());
                _gateway.AddData(2, Temperature.Name, Temperature.CelsiusValue.ToString(), DateTime.Now.ToString());
                _gateway.AddData(6, Humidity.Name, Humidity.HumidityValue.ToString(), DateTime.Now.ToString());

                Console.WriteLine("Collected & Insered!");
            }
            else
            {
                Console.WriteLine("Not collected & not insered!");
            }
        }