Closed alexbk66 closed 5 years ago
This is not due to HSPI, but the way HomeSeer works. To actually get your plugin to show you need to register a webpage (if I am not completely mistaken).
Here is how I did it with my last plugin (from InitIO(string port))
var wpd = new WebPageDesc
{
link = "AwsomePlugin_Main_ConfigPage",
plugInName = "AwsomePlugin"
};
_callback.RegisterConfigLink(wpd);
Clicking on your pluginname in the pluginlist will now trigger PostBackProc(string page, string data, string user, int userRights) where page is "AwsomePlugin_Main_ConfigPage"
Seems to work if Config page is registered for this plugin:
Thanks, @oesolberg. I didn't know this.
@alexbk66, what template did you start with? Was your original screenshot the default behavior of the template, or did you modify the code such that it exhibited that behavior? If it was the default, we likely need to fix the template, as that doesn't seem good.
Hi @alexdresko, I used template B and yes, it doesn't implement registring the config page for the plugin, so I had to copy the code from HSPI_HikAlarmCheck.
BTW, I coudn't find anywhere how to also pass the plugin version to HS, instead of showing N/A. Anybody have any idea?
@alexbk66 Please create an issue for the version information. The templates should do that automatically.
Also, should we re-open this issue add this code from @oesolberg in plugin B?
Regarding plugin version - I started a topic in HS forum https://forums.homeseer.com/forum/homeseer-products-services/system-software-controllers/hs3-hs3pro-software/hs3-plug-in-development/1258609-display-plugin-version I don't think it's an issue with HSPI
Regarding registering config page - I copied (and modified) the code from HSPI_HikAlarmCheck:
/// <summary>
/// Registers a web page with HomeSeer.
/// </summary>
/// <param name="link">The link to be registered.</param>
/// <param name="linktext">The text to appear in the HomeSeer menu system for the link.</param>
/// <param name="page_title">The title to be displayed for the web page.</param>
public void RegisterWebPage(string link, string linktext = "", string page_title = "")
{
try
{
if (linktext == "")
linktext = link;
linktext = linktext.Replace("_", " ");
if (page_title == "")
page_title = linktext;
link = GetName() + "_" + link;
HS.RegisterPage(link, GetName(), "");
HomeSeerAPI.WebPageDesc wpd = new HomeSeerAPI.WebPageDesc();
wpd.plugInName = GetName();
wpd.link = link;
wpd.linktext = linktext;
wpd.page_title = page_title;
Callback.RegisterConfigLink(wpd);
Callback.RegisterLink(wpd);
}
catch (Exception ex)
{
HS.WriteLog(GetName(), "Error registering web links: " + ex.Message);
}
}
As I said before, HSPI_HikAlarmCheck is really good C# example, and it has good comments too which we might want to copy to HSPI
I had a quick look at the plugin version issue and it appears to be a "remote plugin” issue. If I take one of my plugins and run it remotely I get version as N/A, but when I run same plugin locally I get the version defined in the assembly.
I output the version to the console so I can see that info when operating remotely, which I only do for debug purposes. Once released I run all my plugins locally
private static string GetAssemblyNameAndVersion() { Assembly assem = Assembly.GetExecutingAssembly(); AssemblyName assemName = assem.GetName(); Version ver = assemName.Version; return assemName.Name + ", Version " + ver.ToString(); }
static void Main(string[] args) { // Set up logging mechanisms m_Log.OnLog += OnLog; m_Log.WriteLine("HSPI_MySensors running.", LOG_LEVEL.PLUGIN, LOG_SUB_LEVEL.GENERIC); m_Log.WriteLine("Assembly: " + GetAssemblyNameAndVersion(), LOG_LEVEL.PLUGIN, LOG_SUB_LEVEL.GENERIC);
On Nov 8, 2018, at 9:53 PM, alexbk66 notifications@github.com wrote:
Hi @alexdresko, I used template B and yes, it doesn't implement registring the config page for the plugin, so I had to copy the code from HSPI_HikAlarmCheck.
BTW, I coudn't find anywhere how to also pass the plugin version to HS, instead of showing N/A. Anybody have any idea?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
When I execute the plugin remotely - the Remote Plug-Ins section in HS shows the plugin connected, but no plugin name or version is shown: