Exemple #1
0
        public async Task StartAsync()
        {
            if (IsStarted)
            {
                return;
            }

            Log.Information("Starting service...");
            await DoWork(async() =>
            {
                var hardwareConfig = m_ConfigService.LoadHardwareConfig("hardware.xml");
                if (await m_Automation.FindDevicesAsync(hardwareConfig))
                {
                    m_ConfigService.SaveHardwareConfig("hardware.xml", hardwareConfig);
                    Log.Information("Hardware configuration updated");
                }

                var deviceInfo = m_Automation.GetDeviceInfo();
                Log.Information("Found devices: {Count}", deviceInfo.Count);
                foreach (var info in deviceInfo)
                {
                    Log.Information("{Name} - {Device}", info.Name, info.Device);
                }

                var automationConfig = m_ConfigService.LoadAutomationConfig("automation.xml");
                m_Automation.Start(automationConfig);
                IsStarted = true;

                m_HomeConfig = m_ConfigService.LoadHomeConfig("home.xml");
            });

            Log.Information("Service has started");
        }