feat: Adds mechanism to track initialization status of EssentialsDevice as well as an event on DeviceManager to notify when all devices initialized. Room combiner now waits for all initialize before setting current scenario.

This commit is contained in:
Neil Dorin
2024-10-04 10:33:09 -06:00
parent f351c036ed
commit fa38e8a9a8
3 changed files with 55 additions and 2 deletions

View File

@@ -17,6 +17,24 @@ namespace PepperDash.Essentials.Core
[Description("The base Essentials Device Class")]
public abstract class EssentialsDevice : Device
{
public event EventHandler Initialized;
private bool _isInitialized;
public bool IsInitialized {
get { return _isInitialized; }
private set
{
if (_isInitialized == value) return;
_isInitialized = value;
if (_isInitialized)
{
Initialized?.Invoke(this, new EventArgs());
}
}
}
protected EssentialsDevice(string key)
: base(key)
{
@@ -41,6 +59,8 @@ namespace PepperDash.Essentials.Core
try
{
Initialize();
IsInitialized = true;
}
catch (Exception ex)
{