Announcement

Collapse
No announcement yet.

Guidelines for porting plugins from HS3

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Guidelines for porting plugins from HS3

    I'm not able to find any documentation on creating HS4 version of existing plugin -
    I mean what's the policy on plugin ID and name - so the updater recognizes the plugin as HS4 version of old HS3 plugin?
    If the plugin has the same ID as the HS3 version - how does updater differentiate between two versions?
    How do I submit the HS4 and HS3 versions of the same plugin ?

    #2
    Alex,

    In the HS4 plugin you set both the HSPI.ID and HSPI.Name where in the HS3 environment there is only HSPI.Name. This is how they distinguish.
    For my plugin I have set both ID and Name the same.
    -- Wim

    Plugins:RFXCOM, HSTouch Server, Squeezebox, BLGData, Restart, Jon00's Perfmon and Network monitor, WeatherXML, BLBackup, TenScripting, BC4, Pushover, PHLocation, JowiHue, Zwave, Sonos
    650 devices ---- 336 events ----- 40 scripts

    Comment


      #3
      Originally posted by w.vuyk View Post
      Alex,

      In the HS4 plugin you set both the HSPI.ID and HSPI.Name where in the HS3 environment there is only HSPI.Name. This is how they distinguish.
      For my plugin I have set both ID and Name the same.
      Thank you. But how do you submit two versions? Separately? Just with the same ID?

      Comment


        #4
        If you go to the plugins page you submit a new plugin for your HS4 version, you can then tick a box for HS4 only or HS3/HS4 enabled. I even believe you cannot even submit a (new) hs3 plugin anymore, so this option might no longer exist and you are in the HS4 submition process immediately.

        I used the same ID as for the HS3 version.

        Wim
        -- Wim

        Plugins:RFXCOM, HSTouch Server, Squeezebox, BLGData, Restart, Jon00's Perfmon and Network monitor, WeatherXML, BLBackup, TenScripting, BC4, Pushover, PHLocation, JowiHue, Zwave, Sonos
        650 devices ---- 336 events ----- 40 scripts

        Comment


          #5
          One more question, probably belongs to a new thread...

          Code:
          /// <inheritdoc />
          /// <remarks>
          /// This ID is used to identify the plugin and should be unique across all plugins
          /// <para>
          /// This must match the MSBuild property $(PluginId) as this will be used to copy
          /// all of the HTML feature pages located in .\html\ to a relative directory
          /// within the HomeSeer html folder.
          /// </para>
          /// <para>
          /// The relative address for all of the HTML pages will end up looking like this:
          /// ..\Homeseer\Homeseer\html\HomeSeerSamplePlugin\
          /// </para>
          /// </remarks>
          public override string Id { get; } = "HomeSeerSamplePlugin";
          What do they mean by MSBuild property $(PluginId) ?

          Comment


            #6
            Originally posted by alexbk66 View Post
            One more question, probably belongs to a new thread...

            Code:
            /// <inheritdoc />
            /// <remarks>
            /// This ID is used to identify the plugin and should be unique across all plugins
            /// <para>
            /// This must match the MSBuild property $(PluginId) as this will be used to copy
            /// all of the HTML feature pages located in .\html\ to a relative directory
            /// within the HomeSeer html folder.
            /// </para>
            /// <para>
            /// The relative address for all of the HTML pages will end up looking like this:
            /// ..\Homeseer\Homeseer\html\HomeSeerSamplePlugin\
            /// </para>
            /// </remarks>
            public override string Id { get; } = "HomeSeerSamplePlugin";
            What do they mean by MSBuild property $(PluginId) ?
            If you edit the .csproj file of the Sample plugin you will see the PluginId property defined there:

            Code:
            <?xml version="1.0" encoding="utf-8"?>
            <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
            <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Mic rosoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVe rsion)\Microsoft.Common.props')" />
            <PropertyGroup Label="HomeSeer Properties">
            <!--
            This ID must be specified and match the value set in HSPI.Id
            It is used to ensure that the Assembly name, namespace,
            class ID, and HTML output directory correctly correspond to one another
            -->
            <PluginId>HomeSeerSamplePlugin</PluginId>
            <!--
            This is the root directory for the local HomeSeer installation.
            The plugin will be automatically deployed to this directory after a successful build
            -->
            <HomeSeerRoot>..\Homeseer\Homeseer\</HomeSeerRoot>
            </PropertyGroup>

            Comment


              #7
              Thank you spud - so for every plugin I have to edit the .csproj file manually? The VS IDE doesn't expose these types of properties?

              Do you have plans to create a basic template for creating HS4 plugin? Like Alex Dresko did for HS3.

              Comment


                #8
                Originally posted by spud View Post

                If you edit the .csproj file of the Sample plugin you will see the PluginId property defined there:

                Code:
                <!--
                This ID must be specified and match the value set in HSPI.Id
                It is used to ensure that the Assembly name, namespace,
                class ID, and HTML output directory correctly correspond to one another
                -->
                <PluginId>HomeSeerSamplePlugin</PluginId>
                <!--
                This is the root directory for the local HomeSeer installation.
                The plugin will be automatically deployed to this directory after a successful build
                -->
                <HomeSeerRoot>..\Homeseer\Homeseer\</HomeSeerRoot>
                This doesn't seem to be the case - there's no post-build event which would do it. Correct me if I'm wrong spud

                Comment


                  #9
                  AFAIK the PluginId in the .csproj is only used to copy the html files of your project to the HS4 html directory after a successful build.
                  Code:
                   <Target Name="AfterBuild" Condition=" '$(Configuration)|$(Platform)' == 'DirectToHs|AnyCPU' ">
                  <Copy SourceFiles="@(HtmlFiles)" DestinationFolder="$(OutputPath)\html\$(PluginId)" />
                  </Target>
                  So it's not mandatory that you set this variable in the the csproj. If you don't want your html files to be deployed automatically, just forget about this.

                  Comment


                    #10
                    Originally posted by spud View Post
                    AFAIK the PluginId in the .csproj is only used to copy the html files of your project to the HS4 html directory after a successful build.
                    Code:
                     <Target Name="AfterBuild" Condition=" '$(Configuration)|$(Platform)' == 'DirectToHs|AnyCPU' ">
                    <Copy SourceFiles="@(HtmlFiles)" DestinationFolder="$(OutputPath)\html\$(PluginId)" />
                    </Target>
                    So it's not mandatory that you set this variable in the the csproj. If you don't want your html files to be deployed automatically, just forget about this.
                    Ah, yeah, how I missed that...

                    It feels a bit messy unnecessary - especially matching plugin Id, exe naming, matching namespace. Four or five different places - .csproj file, namespace name, exe name, "public override string Id", SettingsFileName.

                    Would be nice if plugin Id could be set only once - i.e. in the .csproj file only.

                    I couldn't find a way of getting plugin Id from the .csproj file in the C# code, but at least if plugin Id must match the namespace name - then this should be really sufficient in the AbstractPlugin class:

                    Code:
                    public override string Id => GetType().Namespace.Replace("HSPI_", "");
                    
                    public override string Name => Id;
                    
                    protected override string SettingsFileName => $"{Id}.ini";
                    [EDIT]

                    At least this is already in the AbstractPlugin

                    Code:
                    protected virtual string SettingsFileName => $"{Id}.ini";

                    Comment

                    Working...
                    X