Beispiel #1
0
        private void InitializeDevices(ConfigurationObject.DevicesConfig devicesConfig)
        {
            devicesConfig.Shutters?.ToList().ForEach(x =>
            {
                AllDevices.Add(new Shutter(x, _gpioConnection));
            });
            devicesConfig.Lightings?.ToList().ForEach(x =>
            {
                AllDevices.Add(new Lighting(x, _gpioConnection));
            });
            devicesConfig.WindMonitors?.ToList().ForEach(x =>
            {
                AllDevices.Add(new WindMonitor(x, _gpioConnection));
            });

            RegisterAllEmergencyDevices();
        }
        public static Dictionary <string, List <string> > GenerateDeviceWithTopicsDictionary(ConfigurationObject.DevicesConfig devices)
        {
            var retval = new Dictionary <string, List <string> >();

            if (devices.Shutters != null)
            {
                foreach (var device in devices.Shutters)
                {
                    var topicsList = new List <string>
                    {
                        $"{ShutterTopicPrefix}{device.Floor}/{device.Description}",
                        $"{ShutterTopicPrefix}{device.Floor}/{device.Description}/timeron",
                        $"{ShutterTopicPrefix}{device.Floor}/{device.Description}/timeroff",
                        $"{ShutterTopicPrefix}{device.Floor}/{device.Description}/status",
                    };
                    retval.Add(device.Description, topicsList);
                }
            }

            if (devices.Lightings != null)
            {
                foreach (var device in devices.Lightings)
                {
                    var topicsList = new List <string>
                    {
                        $"{LightingTopicPrefix}{device.Floor}/{device.Description}",
                        $"{LightingTopicPrefix}{device.Floor}/{device.Description}/status",
                    };
                    retval.Add(device.Description, topicsList);
                }
            }

            return(retval);
        }