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

Request: Plugin notification if event trigger is deleted or enabled state changes #320

Open homeseerwu opened 1 year ago

homeseerwu commented 1 year ago

Environment

HomeSeer

OS

Windows

HS Version

4.2.16.0

Development

PSDK Version

v1.4.2.0

Language

C#

IDE

VS2019

Dev OS

Windows 10

Page

n/a

Plugin

My own plugin

Problem

Description

Event Trigger Plugins are not notified when event config changes occur relating to the plugin's event triggers.

Why Is This Necessary? Some event trigger plugins perform costly processing to detect when to trigger an event. The cost of such monitoring can be perf costly (memory, disk, cpu, network, etc). To conserve resource consumption such plugins enable its monitoring processing only when there is an active event configured to use the plugin's trigger. Therefore the plugin must be notified when a user removes the plugin's trigger from an event, changes an event's enabled state or outright deletes an event.

I have been unable to find any notification or callback into my plugin for these types of event configuration changes. As a (most horrible) workaround I have a timer fire every n seconds which then walks through each and every event to determine which processing systems my plugin should spin up or down.

My request: Enable a plugin to receive notification when:

The callback would indicate the specific event and the change (event deleted, event has been enabled, event has been disabled, or the an event's plugin-based trigger has been removed).

Crawl: System wide broadcast/callback for any of the above (not relating to a specific plugin). Plugin must be able to monitor such broadcasts/callbacks. Walk: Plugin registers for and receives callback indicating any event change per above Run: Plugin registers for and receives callback indicating an event scoped solely to the plugin's triggers per above

Screenshots

n/a

Expected Behavior

I expected some mechanism to alert my plugin when event trigger related event config changes are made.

Steps to Reproduce

n/a

Logs

n/a

spudwebb commented 1 year ago

register for config change using RegisterEventCB:

HomeSeerSystem.RegisterEventCB(HomeSeer.PluginSdk.Constants.HSEvent.CONFIG_CHANGE, Id);

then override HsEvent and filters on params[1] to get the changes related to events:

      public override void HsEvent(HomeSeer.PluginSdk.Constants.HSEvent eventType, object[] @params) {

          if(eventType == HomeSeer.PluginSdk.Constants.HSEvent.CONFIG_CHANGE && (int)@params[1] == (int)EConfigChangeTarget.Event) {

          }
      }

more info here: https://homeseer.github.io/Plugin-SDK-Docs/api/HomeSeer.PluginSdk.Systems.EHsSystemEvent.html?tabs=cs#HomeSeer_PluginSdk_Systems_EHsSystemEvent_ConfigChange

homeseerwu commented 1 year ago

Thank you for your response. I have the ConfigChange (and other) events registered but not seeing success:

I do see some HsEvents() but:

sjhill01 commented 1 year ago

It's been almost a year since this was opened and it's still a problem. I keep track in memory of what events to evaluate on HSEvent ValueChanges which means I have to be able to keep that list in sync with HomeSeer. The ConfigChange HSEvent only fires when adding or removing triggers, but does not fire like it should when the "Save" button is clicked on an existing trigger.

rjhelmke commented 1 year ago

Logged as HS-1894. I will schedule this issue for HS4 4.2.20.0.