public async Task <NEEOBrain> DiscoverOneBrain() { var lookup = await ZeroconfResolver.BrowseDomainsAsync(_options); var found = lookup.FirstOrDefault((l) => l.Key.StartsWith(_neeoKey)); if (found == null) { return(null); } var brain = new NEEOBrain(); var hosts = await ZeroconfResolver.ResolveAsync(found.Key); foreach (var host in hosts) { brain.IpArray = host.IPAddresses.ToList().ToArray(); foreach (var service in host.Services) { brain.Name = host.DisplayName; brain.Host = brain.IpArray[0]; brain.Port = service.Value.Port; foreach (var dict in service.Value.Properties) { brain.Version = dict["rel"]; brain.Region = dict["reg"]; } } } return(brain); }
public async Task <NEEOBrain> DiscoverOneBrain() { if (_brain == null) { if (_discover == null) { throw new NEEOException("brain or discover must be defined"); } _brain = await _discover.DiscoverOneBrain(); } return(_brain); }
public DiscoverModule(string name, string host, int port, string version, string region, string[] ipArray) { _brain = new NEEOBrain { Name = name, Host = host, Port = port, Version = version, Region = region, IpArray = ipArray }; _instance = this; }
public static string BuildBrainUrl(NEEOBrain brain, string baseUrl = null, int brainport = NEEOConf.DEFAULT_BRAIN_PORT) { if (brain == null) { throw new NEEOException("URLBUILDER_MISSING_PARAMETER_BRAIN"); } if (baseUrl == null) { baseUrl = string.Empty; } if (brain.Host != null && brain.Port != 0) { return(PROTOCOL + brain.Host + ':' + brain.Port.ToString() + baseUrl); } throw new NEEOException("URLBUILDER_INVALID_PARAMETER_BRAIN"); }
internal static async Task <NEEORecipe[]> GetRecipesPowerState(NEEOBrain brain) { if (brain == null) { throw new NEEOException("MISSING_BRAIN_PARAMETER"); } string url = UrlBuilder.BuildBrainUrl(brain, NEEOUrls.BASE_URL_GETACTIVERECIPES); _logger.LogDebug($"Recipe | GET RecipesPowerState {url}"); NEEORecipe[] recipes = await _restClient.HttpGet <NEEORecipe[]>(url); if (recipes != null) { Factory.BuildRecipesModel(recipes, _restClient); } return(recipes); }
public static Task <NEEORecipe[]> GetRecipesPowerState(NEEOBrain configuration) { return(RecipeModule.GetRecipesPowerState(configuration)); }
public static Task <NEEORecipe[]> GetAllRecipes(NEEOBrain configuration) { return(RecipeModule.GetAllRecipes(configuration)); }