Updates to add necessary functionality for occupancy sensors to trigger room to power on to default source during specific hours on certain days.

This commit is contained in:
Neil Dorin
2018-08-21 18:23:31 -06:00
parent c839cea495
commit c0c90f926e
7 changed files with 412 additions and 345 deletions

View File

@@ -387,7 +387,7 @@ namespace PepperDash.Essentials
/// <summary>
/// Will power the room on with the last-used source
/// </summary>
public void PowerOnToDefaultOrLastSource()
public override void PowerOnToDefaultOrLastSource()
{
if (!EnablePowerOnToLastSource || LastSourceKey == null)
return;

View File

@@ -532,7 +532,7 @@ namespace PepperDash.Essentials
/// <summary>
/// Will power the room on with the last-used source
/// </summary>
public void PowerOnToDefaultOrLastSource()
public override void PowerOnToDefaultOrLastSource()
{
if (!EnablePowerOnToLastSource || LastSourceKey == null)
return;

View File

@@ -59,7 +59,23 @@ namespace PepperDash.Essentials
/// <summary>
/// Seconds after vacancy detected until prompt is displayed
/// </summary>
protected int RoomVacancyShutdownPromptSeconds;
protected int RoomVacancyShutdownPromptSeconds;
/// <summary>
/// The time of day at which the room occupancy power on feature should be enabled
/// </summary>
protected DateTime RoomOccpuancyPowerOnStart;
/// <summary>
/// The time of day at which the room occupancy power on feature should be disabled
/// </summary>
protected DateTime RoomOccupancyPowerOnEnd;
/// <summary>
/// Should the room power on to the default source if occupied between the start and end times
/// </summary>
protected bool RoomOccupancyPowerOnIsEnabled;
/// <summary>
///
@@ -203,7 +219,12 @@ namespace PepperDash.Essentials
RoomOccupancy = statusProvider;
RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange;
}
}
/// <summary>
/// To allow base class to power room on to default source
/// </summary>
public abstract void PowerOnToDefaultOrLastSource();
void RoomIsOccupiedFeedback_OutputChange(object sender, EventArgs e)
{
@@ -217,16 +238,28 @@ namespace PepperDash.Essentials
{
Debug.Console(1, this, "Notice: Occupancy Detected");
// Reset the timer when the room is occupied
RoomVacancyShutdownTimer.Cancel();
RoomVacancyShutdownTimer.Cancel();
if(RoomOccupancyPowerOnIsEnabled)
{
var currentTime = DateTime.Now.TimeOfDay;
if (currentTime.CompareTo(RoomOccpuancyPowerOnStart.TimeOfDay) > 0 && RoomOccupancyPowerOnEnd.TimeOfDay.CompareTo(currentTime) > 0)
{
PowerOnToDefaultOrLastSource();
}
}
}
}
/// <summary>
/// Sets up events in the scheduler for the start and end times of the appropriate days to enable and disable the RoomOccupancyPowerOnIsEnabled flag
/// </summary>
void SetUpOccupancyRoomOnEventsInScheduler()
{
}
//void SwapVolumeDevices(IBasicVolumeControls currentDevice, IBasicVolumeControls newDevice)
//{
//}
/// <summary>
/// Executes when RoomVacancyShutdownTimer expires. Used to trigger specific room actions as needed. Must nullify the timer object when executed
/// </summary>