Пример #1
0
        public static Temperature_Device ConvertToTemperatureDevice(ShellyCloudResponse objectToConvert)
        {
            Temperature_Device tempHygro = new Temperature_Device
            {
                Id            = 2,
                Name          = "Temperatur",
                Icon          = "~/content/images/thermo.png",
                TempInCelsius = objectToConvert.data.device_status.tmp.value + "°C",
                CelsiusValue  = objectToConvert.data.device_status.tmp.value
            };

            return(tempHygro);
        }
Пример #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!");
            }
        }