Exemplo n.º 1
0
        public static async Task InitHomeMatic(string address)
        {
            // Save address
            ApplicationData.Current.LocalSettings.Values["address"] = address;

            // Init API
            HomeMaticApi = new HomeMaticXmlApi(new Ccu("HomeMatic CCU", address));
            if (await HomeMaticApi.CheckConnectionAsync())
            {
                Channels.Clear();

                var devices = await HomeMaticApi.GetDevicesAsync();

                foreach (var device in devices)
                {
                    var homeMaticDevice = device as HomeMaticDevice;
                    foreach (var channel in homeMaticDevice.ChannelList)
                    {
                        Channels.Add(channel);
                    }
                }
            }
            else
            {
                var dialog = new MessageDialog("Could not connect to your HomeMatic Central", "Connection Error");
                await dialog.ShowAsync();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            // Initialize HomeMatic API
            var ccu = new Ccu("Demo", "192.168.0.14");

            HomeMatic = new HomeMaticXmlApi(ccu);
        }
Exemplo n.º 3
0
        private void RestoreSavedSettings()
        {
            // Restore IP-Address
            var ipAddress = Settings.Values["ipAddress"];

            if (ipAddress != null)
            {
                HomeMatic = new HomeMaticXmlApi(new Ccu("Demo", (string)ipAddress));
            }

            // Restore selected light id
            var selectedLightId = Settings.Values["selectedLightId"];

            if (selectedLightId != null)
            {
                SelectedLightId = (int)selectedLightId;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initialized the HomeControlService with or without a previously loaded Configuration instance
        /// </summary>
        /// <returns></returns>
        /// <param name="config">Configuration instance</param>
        public async Task InitAsync(Configuration config = null)
        {
            // Load config from SettingsService, if none has been provided
            if (config == null)
            {
                if (!_SettingsService.IsLoaded)
                {
                    await _SettingsService.LoadSettingsAsync();
                }

                config = _SettingsService.Settings.Configuration;
            }

            // Load central units
            if (config.CentralUnits != null)
            {
                // HomeMatic
                var homeMaticCentral = config.CentralUnits.FirstOrDefault(c => c.Brand == Base.Models.CentralUnitBrand.HomeMatic);
                if (homeMaticCentral != null && homeMaticCentral is Ccu)
                {
                    HomeMatic = new HomeMaticXmlApi(homeMaticCentral as Ccu);
                }
            }
        }