mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-09 01:35:02 +00:00
#742 Updates to room combination interfaces and EssentialsRoomCombiner and EssentialsPartitionController
This commit is contained in:
@@ -42,14 +42,19 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
void CreateScenarios()
|
||||
{
|
||||
RoomCombinationScenarios = new List<IRoomCombinationScenario>();
|
||||
|
||||
foreach (var scenarioConfig in _propertiesConfig.Scenarios)
|
||||
{
|
||||
var scenario = new RoomCombinationScenario(scenarioConfig);
|
||||
RoomCombinationScenarios.Add(scenario);
|
||||
}
|
||||
}
|
||||
|
||||
void SetRooms()
|
||||
{
|
||||
_rooms = new List<IEssentialsRoom>();
|
||||
|
||||
foreach (var roomKey in _propertiesConfig.RoomKeys)
|
||||
{
|
||||
var room = DeviceManager.GetDeviceForKey(roomKey) as IEssentialsRoom;
|
||||
@@ -62,7 +67,36 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
void SetupPartitionStateProviders()
|
||||
{
|
||||
foreach (var pConfig in _propertiesConfig.Partitions)
|
||||
{
|
||||
var sensor = DeviceManager.GetDeviceForKey(pConfig.DeviceKey) as IPartitionStateProvider;
|
||||
|
||||
var partition = new EssentialsPartitionController(pConfig.Key, pConfig.Name, sensor, _propertiesConfig.defaultToManualMode, pConfig.AdjacentRoomKeys);
|
||||
|
||||
partition.PartitionPresentFeedback.OutputChange += PartitionPresentFeedback_OutputChange;
|
||||
|
||||
Partitions.Add(partition);
|
||||
}
|
||||
}
|
||||
|
||||
void PartitionPresentFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
DetermineRoomCombinationScenario();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines the current room combination scenario based on the state of the partition sensors
|
||||
/// </summary>
|
||||
void DetermineRoomCombinationScenario()
|
||||
{
|
||||
//RoomCombinationScenarios.FirstOrDefault((s) =>
|
||||
//{
|
||||
// foreach (var partitionState in s.PartitionStates)
|
||||
// {
|
||||
// var partition = Partitions.FirstOrDefault(
|
||||
// }
|
||||
//});
|
||||
}
|
||||
|
||||
#region IEssentialsRoomCombiner Members
|
||||
@@ -111,11 +145,11 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public List<IRoomCombinationScenario> RoomCombinationScenarios { get; private set; }
|
||||
|
||||
public List<IPartitionStateProvider> PartitionStateProviders { get; private set; }
|
||||
public List<IPartitionStateProvider> Partitions { get; private set; }
|
||||
|
||||
public void TogglePartitionState(string partitionKey)
|
||||
{
|
||||
var partition = PartitionStateProviders.FirstOrDefault((p) => p.Key.Equals(partitionKey)) as IManualPartitionSensor;
|
||||
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionKey)) as IPartitionController;
|
||||
|
||||
if (partition != null)
|
||||
{
|
||||
|
||||
@@ -84,8 +84,8 @@ namespace PepperDash.Essentials.Core
|
||||
[JsonProperty("partitionStates")]
|
||||
public List<PartitionState> PartitionStates { get; set; }
|
||||
|
||||
[JsonProperty("roomMap")]
|
||||
public Dictionary<string, string> RoomMap { get; set; }
|
||||
[JsonProperty("uiMap")]
|
||||
public Dictionary<string, string> UiMap { get; set; }
|
||||
|
||||
[JsonProperty("activationActions")]
|
||||
public List<DeviceActionWrapper> ActivationActions { get; set; }
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace PepperDash.Essentials.Core
|
||||
/// <summary>
|
||||
/// Describes the functionality for an EssentailsRoomCombiner device
|
||||
/// </summary>
|
||||
public interface IEssentialsRoomCombiner
|
||||
public interface IEssentialsRoomCombiner : IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the room combination scenario has changed
|
||||
@@ -51,7 +51,7 @@ namespace PepperDash.Essentials.Core
|
||||
/// <summary>
|
||||
/// The partition
|
||||
/// </summary>
|
||||
List<IPartitionStateProvider> PartitionStateProviders { get; }
|
||||
List<IPartitionStateProvider> Partitions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the state of a manual partition sensor
|
||||
@@ -77,6 +77,16 @@ namespace PepperDash.Essentials.Core
|
||||
/// Activates this room combination scenario
|
||||
/// </summary>
|
||||
void Activate();
|
||||
|
||||
/// <summary>
|
||||
/// The state of the partitions that would activate this scenario
|
||||
/// </summary>
|
||||
List<PartitionState> PartitionStates { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The mapping of UIs by key to rooms by key
|
||||
/// </summary>
|
||||
Dictionary<string, string> UiMap { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public List<PartitionState> PartitionStates { get; private set; }
|
||||
|
||||
public Dictionary<string, string> EnabledRoomMap { get; set; }
|
||||
public Dictionary<string, string> UiMap { get; set; }
|
||||
|
||||
private bool _isActive;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
PartitionStates = config.PartitionStates;
|
||||
|
||||
EnabledRoomMap = config.RoomMap;
|
||||
UiMap = config.UiMap;
|
||||
|
||||
activationActions = config.ActivationActions;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user