Exemple #1
0
        private async void lstDeviceList_DoubleClick(object sender, EventArgs e)
        {
            CurrentAggregate = (DeviceAggregate)lstDeviceList.SelectedItem;
            if (CurrentAggregate != null && CurrentAggregate.Report.DeviceType == DeviceType.Chromecast)
            {
                var chromecastReport = CurrentAggregate.Report as ChromecastDeviceDiscoveryReportItem;
                CurrentAggregate.StartDevice();

                lblAddress.Text = chromecastReport.EndPoint.ToString();
                lblName.Text    = chromecastReport.Name;

                groupChromecast.Enabled = true;
                CurrentAggregate.ConnectionChannel.MessageReceived += OnData;
                CurrentAggregate.ReceiverChannel.MessageReceived   += OnData;
                CurrentAggregate.HeartbeatChannel.MessageReceived  += OnData;
                CurrentAggregate.MediaChannel.MessageReceived      += OnData;

                btnLaunchYoutube.Enabled = true;
            }
        }
Exemple #2
0
        private async void lstDeviceList_DoubleClick(object sender, EventArgs e)
        {
            CurrentAggregate = (DeviceAggregate)lstDeviceList.SelectedItem;
            if (CurrentAggregate != null && CurrentAggregate.Report.DeviceType == DeviceType.Chromecast)
            {
                var chromecastReport = CurrentAggregate.Report as ChromecastDeviceDiscoveryReportItem;
                CurrentAggregate.StartDevice();

                lblAddress.Text = chromecastReport.EndPoint.ToString();
                lblName.Text = chromecastReport.Name;

                groupChromecast.Enabled = true;
                CurrentAggregate.ConnectionChannel.MessageReceived += OnData;
                CurrentAggregate.ReceiverChannel.MessageReceived += OnData;
                CurrentAggregate.HeartbeatChannel.MessageReceived += OnData;
                CurrentAggregate.MediaChannel.MessageReceived += OnData;

                btnLaunchYoutube.Enabled = true;
            }
        }
Exemple #3
0
        private async Task <string> GetProvisionCommandsAsync(DeviceAggregate device)
        {
            var commands = new List <string>
            {
                // Reset MQTT prefixes
                "Prefix1 1",
                "Prefix2 1",
                "Prefix3 1",

                // Reset state texts
                "StateText1 OFF",
                "StateText2 ON",
                "StateText3 TOGGLE",
                "StateText4 HOLD"
            };

            if (device.Configuration != null)
            {
                if (!string.IsNullOrWhiteSpace(device.Configuration.TopicName))
                {
                    commands.Add($"Topic {device.Configuration.TopicName}");
                    // Adds 2 seconds between Topic and remaining commands. Without this the Topic won't change! (Tasmota 8.2.0)
                    commands.Add("Delay 20");
                }

                if (device.Configuration.FriendlyNames != null)
                {
                    var i = 1;
                    foreach (var n in device.Configuration.FriendlyNames)
                    {
                        if (!String.IsNullOrWhiteSpace(n))
                        {
                            commands.Add($"FriendlyName{i} {n}");
                            i++;
                        }
                    }
                }

                if (!string.IsNullOrWhiteSpace(device.Configuration.SetupCommands))
                {
                    commands.AddRange(device.Configuration.SetupCommands.Split(';'));
                }
            }

            var globalConfiguration = await _deviceConfigurationRepository.GetDeviceConfigurationAsync("common");

            if (globalConfiguration != null && !string.IsNullOrWhiteSpace(globalConfiguration.SetupCommands))
            {
                commands.AddRange(globalConfiguration.SetupCommands.Split(';'));
            }

            if (device.Template != null)
            {
                commands.Add($"Template {device.Template.Definition}");
                commands.Add("Module 0");
            }

            var allCommands = string.Join(';', commands);

            return(allCommands);
        }