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

@@ -84,7 +84,15 @@ namespace PepperDash.Essentials.Core
SetupPartitionStateProviders();
SetRooms();
});
// Subscribe to the AllDevicesInitialized event
// We need to wait until all devices are initialized in case
// any actions are dependent on 3rd party devices already being
// connected and initialized
DeviceManager.AllDevicesInitialized += (o, a) =>
{
if (IsInAutoMode)
{
DetermineRoomCombinationScenario();
@@ -93,7 +101,7 @@ namespace PepperDash.Essentials.Core
{
SetRoomCombinationScenario(_propertiesConfig.defaultScenarioKey);
}
});
};
}
private void CreateScenarios()