Open homeseerwu opened 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) {
}
}
Thank you for your response. I have the ConfigChange (and other) events registered but not seeing success:
I do see some HsEvents() but:
No HsEvent() callback when I enable or disable an event This is important so that I can spin down resources if disabled. My current solution is to scan everything (per above) every n seconds. Need a callback when an event is enabled or disabled.
No HsEvent() callback for trigger config changes There is no HsEvent() callback when I have successfully configured or modified my event trigger. I tried hooking into my EventTrigger class to catch this but all the interesting methods are called so often by so many different parts of HS that it became a nightmare. The only place that worked was OnConfigItemUpdate() ... but that doesn't help if the trigger is removed from the event.
ConfigChange's Event/Change event doesn't tell me which triggers My HsEvent() callback has no idea which trigger was removed or added. If I call GetEventByRef() the resulting EventData shows me the names of the triggers in the trigger groups. But for a plugin it appears only as "TYPE_PLUGIN". Would be useful for the event to included the removed TrigActInfo object. As a poor workaround for any ConfigChange: Event I am grabbing all TrigActInfo objects from GetTriggersByInterface() and comparing them to a cached copy of them associated with my running monitors. If a new one shows up I spin up a new monitor. If there is a monitor for a TrigActInfo not returned by GetTriggersByInterface() then I spin it down. I would love to have access to the specific TrigActInfo objects related to the event change (what was removed/what was added).
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.
Logged as HS-1894. I will schedule this issue for HS4 4.2.20.0.
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