8.0 Listener for history enabled on tag?

Is there a listener available on the gateway for when history gets enabled/disabled on a tag? Or when a tag gets updated?

I need to run a function when history setting gets modified for my custom datasink.
@Kevin.Herron, @Colby.Clegg

Hey,

So you can subscribe to the “modifiedProperties” property on any tag to get a collection of properties that have changed when the tag is modified. Mostly this is used with a wildcard subscription, so something like subscribe("[provider]*.modifiedProperties"), to listen for anything.

Then, you could look for Collection.contains(WellKnownTagProps.HistoryEnabled). So something like:

subscribeAsync(TagPathParser.parseSafe("[default]*.modifiedProperties"), e -> {
            if (e.getValue().getQuality().isGood() &&
                ((Collection) e.getValue().getValue()).contains(WellKnownTagProps.HistoryEnabled)) {
                historyEnabledChanged(e.getTagPath());
            }
        });

Side note: no idea about timeframe, but for what it’s worth, at some point we will be restructuring how tag history works so that the history storage component of the tag is actually created by the implementing provider, and not just a generic collector that fires data to it. I’m only guessing at what you’re trying to do, but I bet that would help you manage lifecycles much better…

1 Like

Works great. Thank you.