mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-12 12:06:58 +00:00
Adds Fusion Custom Properties support and bridge to pass values from custom properties to devices
This commit is contained in:
parent
6a8ae5b244
commit
7112c50f5a
8 changed files with 158 additions and 25 deletions
|
|
@ -10,6 +10,7 @@ using Newtonsoft.Json.Linq;
|
|||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Devices.Common.Occupancy;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Behaviours
|
||||
|
|
@ -17,7 +18,7 @@ namespace PepperDash.Essentials.Room.Behaviours
|
|||
/// <summary>
|
||||
/// A device that when linked to a room can power the room on when enabled during scheduled hours.
|
||||
/// </summary>
|
||||
public class RoomOnToDefaultSourceWhenOccupied : Device
|
||||
public class RoomOnToDefaultSourceWhenOccupied : Device, IRuntimeConfigurableDevice
|
||||
{
|
||||
RoomOnToDefaultSourceWhenOccupiedConfig Config;
|
||||
|
||||
|
|
@ -72,6 +73,13 @@ namespace PepperDash.Essentials.Room.Behaviours
|
|||
}
|
||||
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
SetUpDevice();
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
void SetUpDevice()
|
||||
{
|
||||
Room = DeviceManager.GetDeviceForKey(Config.RoomKey) as EssentialsRoomBase;
|
||||
|
||||
|
|
@ -109,20 +117,23 @@ namespace PepperDash.Essentials.Room.Behaviours
|
|||
Debug.Console(1, this, "Unable to parse a DateTime config value \n Error: {1}", e);
|
||||
}
|
||||
|
||||
AddEnableEventToGroup();
|
||||
if (!Config.EnableRoomOnWhenOccupied)
|
||||
FeatureEventGroup.ClearAllEvents();
|
||||
else
|
||||
{
|
||||
AddEnableEventToGroup();
|
||||
|
||||
AddDisableEventToGroup();
|
||||
AddDisableEventToGroup();
|
||||
|
||||
FeatureEventGroup.UserGroupCallBack += new ScheduledEventGroup.UserEventGroupCallBack(FeatureEventGroup_UserGroupCallBack);
|
||||
FeatureEventGroup.UserGroupCallBack += new ScheduledEventGroup.UserEventGroupCallBack(FeatureEventGroup_UserGroupCallBack);
|
||||
|
||||
FeatureEventGroup.EnableAllEvents();
|
||||
FeatureEventGroup.EnableAllEvents();
|
||||
}
|
||||
|
||||
FeatureEnabled = CheckIfFeatureShouldBeEnabled();
|
||||
}
|
||||
else
|
||||
Debug.Console(1, this, "Unable to get room from Device Manager with key: {0}", Config.RoomKey);
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -134,6 +145,22 @@ namespace PepperDash.Essentials.Room.Behaviours
|
|||
return JToken.FromObject(Config);
|
||||
}
|
||||
|
||||
public object GetDeviceConfig()
|
||||
{
|
||||
return Config;
|
||||
}
|
||||
|
||||
public void SetDeviceConfig(object config)
|
||||
{
|
||||
var newConfig = config as RoomOnToDefaultSourceWhenOccupiedConfig;
|
||||
|
||||
Config = newConfig;
|
||||
|
||||
ConfigWriter.UpdateDeviceProperties(this.Key, GetLocalConfigProperties());
|
||||
|
||||
SetUpDevice();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subscribe to feedback from RoomIsOccupiedFeedback on Room
|
||||
/// </summary>
|
||||
|
|
@ -185,11 +212,16 @@ namespace PepperDash.Essentials.Room.Behaviours
|
|||
{
|
||||
if (SchedulerUtilities.CheckIfDayOfWeekMatchesRecurrenceDays(DateTime.Now, CalculateDaysOfWeekRecurrence()))
|
||||
{
|
||||
Debug.Console(1, this, "*****Feature Enabled by startup check.*****");
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(enabled)
|
||||
Debug.Console(1, this, "*****Feature Enabled*****");
|
||||
else
|
||||
Debug.Console(1, this, "*****Feature Disabled*****");
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue