HomeSeer / Plugin-SDK

Plugin development kit for the 4th major edition of the HomeSeer platform.
https://www.nuget.org/packages/HomeSeer-PluginSDK/
GNU Affero General Public License v3.0
20 stars 4 forks source link

hs4 is writing to my insteon.ini file #284

Closed mnsandler closed 2 years ago

mnsandler commented 2 years ago

why is hs4 writing to my insteon.ini file?

I have my own ini file management library. i do not use the hs.SaveIniSetting method

i do create two settings pages, but in OnSettingChange, i get the changed values and save them to the ini with my own code

what is going on?

ps. i use the EInputType.Password type in one InputView , and hs4 is saving the pswd in the clear to the ini file. Unacceptable!

how do i turn off hs4 from messing with ini file?

please point me to where this is documented behavior

spudwebb commented 2 years ago

If you don't want the PluginSdk to handle the writing to the .ini file, you need to override OnSettingsPageSave

there is two ways of handling settings with the PluginSdk

1) Let the PluginSdk handles the load/save from the .ini file, i.e using LoadSettingsFromIniand only overriding OnSettingChange() This how it is done in the sample plugins

2) Handling load/save from the .ini file yourself by overriding OnSettingsLoad() and OnSettingsPageSave()

        protected override void OnSettingsLoad() {
            Settings = Controller.GetJuiSettingsPages();
        }

        protected override void OnSettingPageSave(Page pageDelta) {
            Controller.SaveJuiSettingsPage(pageDelta);
        }

This is how I did it in the plugins I wrote because it is more flexible, and closer to the way it was done in HS3

mnsandler commented 2 years ago

thanks. this is very helpful.

is this spelled out in in the docs anywhere?

i dont usually look in the sample plugin for documentation

jldubz commented 2 years ago

@mnsandler

is this spelled out in in the docs anywhere?

I want to note here that the Plugin SDK is designed to provide default behavior that matches what was demonstrated and recommended for HS3 plugins. You can override any method that is defined as virtual in AbstractPlugin to bypass any of this defaulted behavior in AbstractPlugin See - https://homeseer.github.io/Plugin-SDK-Docs/api/HomeSeer.PluginSdk.AbstractPlugin.html?tabs=cs

The base implementation of the IPlugin interface. It includes default implementations for most of the IPlugin members and wraps others with convenience methods and objects that make it simpler to interface with the HomeSeer system.

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/virtual