-
Notifications
You must be signed in to change notification settings - Fork 4
plugin sdk entity ownership
When a plugin creates entities in Security Center using the SDK, those entities are owned by the plugin and marked with special properties that distinguish them from entities created by Config Tool or external applications. Understanding plugin entity ownership is crucial for proper plugin development.
Plugin entity ownership is an automatic mechanism where entities created by a plugin are:
- Owned by the plugin's role
-
Marked as synchronized (
entity.Synchronised = true) - Added to the plugin's root area (for hierarchical entity types)
- Managed by the plugin for running state and lifecycle
This ownership model allows Security Center to track which plugin is responsible for an entity and ensures proper cleanup when the plugin is uninstalled or removed.
When you create an entity from within a plugin using engine.CreateEntity(), the SDK automatically applies ownership:
What happens automatically:
- The entity is assigned to your plugin's role as the owner
- The entity is marked as
Synchronised = true - Hierarchical entities (areas, doors, access points, elevators, zones) are automatically added to the plugin's root area
- The entity becomes read-only to other plugins and external applications
The OwnerRole property returns the GUID of the role that owns the entity. For plugin-created entities, this is the GUID of the plugin's role.
// Get the owner role GUID
Guid ownerRoleGuid = entity.OwnerRole;
// For plugin-owned entities, this returns the plugin's role GUID
if (entity.IsOwnedByPlugin)
{
// ownerRoleGuid is the GUID of the plugin role
var pluginRole = engine.GetEntity<Role>(ownerRoleGuid);
Console.WriteLine($"Entity owned by plugin: {pluginRole.Name}");
}The OwnerRoleType property returns the type of role that owns the entity. For plugin-created entities, this is RoleType.Plugin.
// Check the owner role type
RoleType ownerType = entity.OwnerRoleType;
if (ownerType == RoleType.Plugin)
{
// Entity is owned by a plugin
}
else if (ownerType == RoleType.SecurityCenter)
{
// Entity is from a federation
}
else if (ownerType == RoleType.Archiver)
{
// Entity is owned by an Archiver role
}
// ... other role typesCommon RoleType values:
-
RoleType.Plugin- Plugin role -
RoleType.SecurityCenter- Federation (from another Security Center system) -
RoleType.Archiver- Archiver role -
RoleType.AccessManager- Access Manager role -
RoleType.IntrusionDetection- Intrusion Detection role - Many others (see SDK documentation for complete list)
// Check if an entity is owned by a plugin
if (entity.IsOwnedByPlugin)
{
// This entity was created by a plugin
}This property returns true when the entity's master role type is a plugin. It helps differentiate between:
- Plugin-owned entities (synchronized from plugins)
- Federation-synchronized entities (from other Security Center systems)
- Regular entities (created by Config Tool or external applications)
The Synchronised property indicates whether an entity is synchronized (from a plugin or federation):
// Check if entity is synchronized
if (entity.Synchronised)
{
// This entity is synchronized (plugin-owned or federated)
}Important
Synchronized entities can only be modified by their owner. If you try to modify a synchronized entity that your plugin doesn't own, you'll get a SdkException(SdkError.ReadonlyField).
Plugin-owned entities do not automatically have their running state managed. The plugin must explicitly set and maintain the RunningState property.
Why entities appear "red" in Config Tool:
When a plugin creates an entity but doesn't set its running state, the entity appears offline (red) in Config Tool because its running state defaults to State.NotRunning.
Solution - Set Running State:
engine.TransactionManager.ExecuteTransaction(() =>
{
var userGroup = (UserGroup)engine.CreateEntity("My User Group", EntityType.UserGroup);
userGroup.Description = "Created by my plugin";
// IMPORTANT: Set running state so it doesn't appear red
userGroup.RunningState = State.Running;
});Alternative - Use ModifyEntityState:
For entities that need to display diagnostic information in Config Tool, use ModifyEntityState() instead of setting RunningState directly. This method updates both the running state and displays diagnostic messages. See About plugin state management for details.
// Reports status and updates RunningState based on IsWarning/IsError
ModifyEntityState(deviceEntityId, new PluginStateEntry("Status", "Online"));Note
ModifyEntityState() only works for entities owned by your plugin or the plugin role itself.
Updating Running State:
// The plugin should update running state based on its operational status
if (pluginIsOperational)
{
entity.RunningState = State.Running;
}
else if (pluginHasWarnings)
{
entity.RunningState = State.Warning;
}
else
{
entity.RunningState = State.NotRunning;
}Plugin-owned entities follow the plugin's lifecycle:
- Created when the plugin creates them
- Maintained while the plugin is running
- Should be deleted or released when no longer needed
Hierarchical entity types (areas, doors, access points, elevators, zones) created by plugins are automatically added to a plugin root area.
Purpose of Plugin Root Area:
- Organizes all hierarchical entities owned by the plugin
- Automatically created when the first hierarchical entity is created
- Named after the plugin role
- Hidden from UI when empty
- Managed automatically by the SDK
Hierarchical Entity Types:
- Area
- Door
- Access Point
- Elevator
- Zone
Non-Hierarchical Entity Types (not added to root area):
- Cardholder
- User
- User Group
- Partition
- Credential
- Access Rule
- Schedule
- Most other entity types
Plugin-owned entities cannot be deleted from Config Tool by administrators. Only the owning plugin can delete them using engine.DeleteEntity().
Why this restriction exists:
- Prevents data inconsistency when external deletions occur without the plugin's knowledge
- Ensures the plugin maintains control over its managed entities
- Allows the plugin to perform cleanup operations before deletion
Deleting Plugin-Owned Entities:
// Only the owning plugin can delete its entities
engine.TransactionManager.ExecuteTransaction(() =>
{
engine.DeleteEntity(myPluginOwnedEntity);
});Attempting Deletion from Another Context:
If a different plugin or external application tries to delete a plugin-owned synchronized entity, the operation will fail with a SdkException(SdkError.ReadonlyField).
A plugin can release ownership of entities it created, transferring control back to Security Center. Once ownership is released:
- The entity is no longer synchronized (
Synchronised = false) - Config Tool administrators can modify and delete the entity
- The entity is removed from the plugin's root area
- The plugin is no longer responsible for managing the entity
engine.TransactionManager.ExecuteTransaction(() =>
{
var userGroup = (UserGroup)engine.CreateEntity("Shared User Group", EntityType.UserGroup);
userGroup.Description = "This will be managed by administrators";
userGroup.RunningState = State.Running;
// Release ownership to allow Config Tool management
userGroup.ReleaseOwnership();
// After this, the entity is no longer plugin-owned
});What Happens When You Call ReleaseOwnership():
-
Synchronisedis set tofalse - The plugin's ownership information is removed
- The entity is removed from the plugin's root area (if applicable)
- The entity becomes a regular entity manageable by anyone with appropriate privileges
Areas have special behavior when releasing ownership because they may contain child entities. When you call ReleaseOwnership() on an area:
Area Release Behavior:
- The area itself releases ownership
- All child entities also release ownership recursively
- This ensures consistent ownership state for the entire hierarchy
- Access points, doors, elevators, and zones under the area are all released
Example:
engine.TransactionManager.ExecuteTransaction(() =>
{
var area = engine.GetEntity<Area>(myAreaGuid);
// Releases ownership of the area AND all its children
area.ReleaseOwnership();
});Problem:
var userGroup = (UserGroup)engine.CreateEntity("My Group", EntityType.UserGroup);
// Entity appears red/offline in Config ToolSolution:
engine.TransactionManager.ExecuteTransaction(() =>
{
var userGroup = (UserGroup)engine.CreateEntity("My Group", EntityType.UserGroup);
userGroup.RunningState = State.Running; // Set running state
});Explanation: Plugin-owned entities default to State.NotRunning which appears red/offline in Config Tool. Always set RunningState = State.Running when creating entities.
- Plugin SDK Overview - Plugin architecture
- Plugin SDK Lifecycle - Entity creation during lifecycle events
- Plugin SDK Threading - Threading for entity operations
- Plugin SDK State Management - Reporting plugin and entity health
- SDK Transactions - Transaction requirements for entity operations
-
Security Center SDK Developer Guide Overview of the SDK framework and how to build integrations with Security Center.
-
Platform SDK
- Overview Introduction to the Platform SDK and core concepts.
- Connecting to Security Center Step-by-step guide for connecting and authenticating with the SDK.
- SDK Certificates Details certificates, licensing, and connection validation.
- Referencing SDK Assemblies Best practices for referencing assemblies and resolving them at runtime.
- SDK Compatibility Guide Understanding backward compatibility and versioning in the SDK.
- Entity Guide Explains the core entity model, inheritance, and how to work with entities.
- Entity Cache Guide Describes the engine's local entity cache and synchronization.
- Transactions Covers batching operations for performance and consistency.
- Events Subscribing to real-time system events.
- Actions Sending actions to Security Center.
- Security Desk Displaying content on monitors, reading tiles, sending tasks, and messaging operators.
- Custom Events Defining, raising, and subscribing to custom events.
- ReportManager Querying entities and activity data from Security Center.
- ReportManager Query Reference Complete reference of query types, parameters, and response formats.
- Privileges Checking, querying, and setting user privileges.
- Partitions Entity organization and access control through partitions.
- Logging How to configure logging, diagnostics, and debug methods.
-
Plugin SDK
- Overview Introduction to plugin architecture and capabilities.
- Certificates SDK certificate requirements for plugin roles.
- Lifecycle Initialization and disposal patterns.
- Threading Threading model, QueueUpdate, and async patterns.
- State Management Reporting plugin health and diagnostics.
- Configuration Configuration storage and monitoring.
- Restricted Configuration Secure credential storage and admin-only configuration.
- Events Event subscription and handling.
- Queries Query processing and response handling.
- Request Manager Request/response communication with clients.
- Database Database integration and schema management.
- Entity Ownership Understanding plugin-owned entities, running state management, and ownership release.
- Entity Mappings Using EntityMappings for plugin-specific configuration and external system integration.
- Server Management High availability and server failover.
- Custom Privileges Defining and enforcing custom privileges.
- Custom Entity Types Defining and managing plugin-specific entity types.
- Resolving Non-SDK Assemblies Handling third-party dependencies in plugins and workspace modules.
- Deploying Plugins Registering and deploying plugins and workspace modules.
- .NET 8 Support Building plugins with .NET 8 and .NET Standard compatibility.
-
Workspace SDK
- Overview Introduction to client-side UI extensions for Security Desk and Config Tool.
- Certificates SDK certificate requirements for workspace modules.
- Creating Modules Module lifecycle, registration patterns, and assembly resolution.
- Tasks Executable actions, home page entries, and programmatic invocation.
- Pages Page content, lifecycle, descriptors, and navigation.
- Components Dashboard widgets, tiles, maps, credentials, and content builders.
- Tile Extensions Custom tile widgets, views, and properties panels.
- Services Built-in services for dialogs, maps, alarms, badges, and more.
- Contextual Actions Right-click context menu extensions.
- Options Extensions Custom settings pages in application preferences.
- Configuration Pages Entity configuration pages for Config Tool.
- Monitors Multi-monitor support and shared components.
- Shared Components Using monitor and workspace shared UI components.
- Commands Command execution, evaluation, and interception.
- Extending Events Adding custom fields to Security Center events.
- Map Extensions Custom map objects, layers, and providers.
- Timeline Providers Custom timeline event sources for video playback.
- Image Extractors Custom image sources for cardholder photos and custom fields.
- Credential Encoders Encoding credentials with custom encoder components.
- Cardholder Fields Extractors Importing cardholder data from external sources.
- Content Builders Building and customizing tile content in Security Desk.
-
Macro SDK
- Overview How macros work, creating and configuring macro entities, automation, and monitoring.
- Developer Guide Developing macro code with the UserMacro class and Security Center SDK.
-
- Getting Started Setup, authentication, and basic configuration for the Web SDK.
- Referencing Entities Entity discovery, search capabilities, and parameter formats.
- Entity Operations CRUD operations, multi-value fields, and method execution.
- About access control in the Web SDK Concepts, relationships, and common access-control operations.
- About video in the Web SDK Concepts, relationships, configuration, and common video operations.
- Users and user groups Creating users, managing group membership, and assigning privileges.
- Partitions Managing partitions, entity membership, and user access control.
- Custom Fields Creating, reading, writing, and filtering custom entity fields.
- Custom Card Formats Managing custom credential card format definitions.
- Actions Control operations for doors, cameras, macros, and notifications.
- Events and Alarms Real-time event monitoring, alarm monitoring, and custom events.
- Incidents Incident management, creation, and attachment handling.
- Reports Activity reports, entity queries, and historical data retrieval.
- Tasks Listing and executing saved report tasks.
- Macros Monitoring currently running macros.
- Custom Entity Types Listing, retrieving, and deleting custom entity type descriptors.
- System Endpoints License usage, web tokens, and exception handling.
- Performance Guide Optimization tips and best practices for efficient API usage.
- Reference Entity GUIDs, EntityType enumeration, and EventType enumeration.
- Under the Hood Technical architecture, query reflection, and SDK internals.
- Troubleshooting Common error resolution and debugging techniques.
- Media Gateway Guide Setup and configuration of the Media Gateway role for video streaming.
- Developer Guide Complete guide to integrating GWP for live and playback video streaming.
- API Reference Full API documentation with interfaces, methods, properties, and events.
- Sample Application Comprehensive demo showcasing all GWP features with timeline and PTZ controls.
- Multiplexing Sample Multi-camera grid demo using a shared WebSocket connection.