Example #1
0
        public Scheduler.Classes.DeviceClass getHSDevice(EnOceanDeviceType type, string id = "")
        {
            Scheduler.Classes.clsDeviceEnumeration devenum = HS.GetDeviceEnumerator() as Scheduler.Classes.clsDeviceEnumeration;

            while (!devenum.Finished)
            {
                Scheduler.Classes.DeviceClass dev = devenum.GetNext();
                if (dev.get_Interface(null) != Constants.PLUGIN_STRING_NAME)
                {
                    continue; // Not ours!
                }
                if (dev.get_Device_Type_String(null) == "EnOcean " + type.ToString())
                {
                    string hsAddr = dev.get_Address(null); //FIXME: Should probably not use address but a plugin value!
                    if (id == hsAddr)
                    {
                        return(dev);
                    }
                }
            }
            return(null);
        }
        private void GetDevicesFromHomeSeer()
        {
            var deviceList       = new List <Scheduler.Classes.DeviceClass>();
            var deviceEnumerator = (clsDeviceEnumeration)_hs.GetDeviceEnumerator();

            while (!deviceEnumerator.Finished)
            {
                var foundDevice = deviceEnumerator.GetNext();
                deviceList.Add(foundDevice);
            }
            //==  Where d.Interface(hs) = Me.Name
            _melcloudDevices     = deviceList.Where(x => x.get_Interface(_hs) == Utility.PluginName).ToList();
            _lastDeviceFetchTime = SystemTime.Now();
        }
Example #3
0
        public void Initialize()
        {
            Dictionary <int, Scheduler.Classes.DeviceClass> device_map = new Dictionary <int, Scheduler.Classes.DeviceClass>();
            Dictionary <int, bool> processed = new Dictionary <int, bool>();

            Scheduler.Classes.clsDeviceEnumeration devenum = HS.GetDeviceEnumerator() as Scheduler.Classes.clsDeviceEnumeration;

            while (!devenum.Finished)
            {
                Scheduler.Classes.DeviceClass dev = devenum.GetNext();
                if (dev.get_Interface(null) != Constants.PLUGIN_STRING_NAME)
                {
                    continue; // Not ours!
                }
                var extraData = dev.get_PlugExtraData_Get(HS);
                if (extraData == null)
                {
                    extraData = new PlugExtraData.clsPlugExtraData();
                }
                var typeStr = (string)extraData.GetNamed("EnOcean Type");
                if (typeStr == null)
                {
                    continue; // No type - continue
                }
                if (typeStr != "Controller")
                {
                    continue; // Not a controller
                }
                var dataStr = (string)extraData.GetNamed("EnOcean Cfg");
                if (dataStr == null)
                {
                    Console.WriteLine("No json data on device - skipping");
                    //                   extraData.AddNamed("EnOcean Cfg", config.ToString());
                    //                 rootDev.set_PlugExtraData_Set(HS, extraData);
                    continue; // Skip interface
                }
                else
                {
                    var config = JObject.Parse(dataStr);
                    Console.WriteLine("Loaded config: {0}", config.ToString());
                    var ctrlInstance = new EnOceanController(HS, HSCB, hspiInst, config);
                    ctrlInstance.Initialize();
                    AddInterface(ctrlInstance);
                }
            }
        }
        public FloorsRoomsAndDevices  GetDevicesFloorsAndRooms()
        {
            var deviceList       = new List <DeviceFromHomeSeer>();
            var deviceEnumerator = (clsDeviceEnumeration)_hs.GetDeviceEnumerator();

            while (!deviceEnumerator.Finished)
            {
                var foundDevice = deviceEnumerator.GetNext();
                deviceList.Add(new DeviceFromHomeSeer()
                {
                    DeviceName = foundDevice.get_Name(_hs), DeviceId = foundDevice.get_Ref(_hs), FloorName = foundDevice.get_Location2(_hs), RoomName = foundDevice.get_Location(_hs)
                });
            }

            var floors = deviceList.Select(x => x.FloorName).Distinct().ToList();
            var rooms  = deviceList.Select(x => x.RoomName).Distinct().ToList();

            return(new FloorsRoomsAndDevices()
            {
                Devices = deviceList,
                Floors = floors,
                Rooms = rooms
            });
        }