Automating HDHomeRun Updates
One thing about the HDHomeRun that I do not loike is when there is an update available for the device, that it does not notify you. Instead, I have to periodically go to the web interface of the device, and check to see if there is an update available. I decided that instead of me doing this, that I automate this repetitive task.
Below is the C# code that I wrote for the automation. Using Selenium WebDriver, the automation goes to the HDHomeRun device web interface and looks for the update button. If it sees the button, then it clicks it. Otherwise it exits out. Below is the code.
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
IWebDriver? driver = null;
try
{
ChromeOptions chromeOptions = new();
chromeOptions.AddArgument("--headless");
driver = new ChromeDriver("/home/almostengineer/Downloads", chromeOptions);
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("http://hdhomerun");
if (driver.Title != "HDHomeRun Main Menu")
{
throw new Exception("Unable to confirm on correct page");
}
try
{
IWebElement installButton = driver.FindElement(By.Id("upgradeInstallBtn"));
Console.WriteLine("Update is available");
string statusText = driver.FindElement(By.Id("upgradeInstallStatus")).Text;
Console.WriteLine(statusText);
installButton.Click();
}
catch (NoSuchElementException ex)
{
Console.Error.WriteLine(ex.Message);
Console.WriteLine("No update available");
}
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
if (driver != null)
{
driver.Quit();
}
Posted: 2023-06-18
Author: Kenny Robinson