mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-12 03:57:27 +00:00
feat: Allows for the ItemKey to be left undefined or empty and the ParentDeviceKey to be used on it's own instead.
This commit is contained in:
parent
90251d92df
commit
aa503f3b29
2 changed files with 18 additions and 2 deletions
|
|
@ -9,9 +9,15 @@ namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
public abstract class AudioControlListItemBase
|
public abstract class AudioControlListItemBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Key of the parent device in the DeviceManager
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("parentDeviceKey")]
|
[JsonProperty("parentDeviceKey")]
|
||||||
public string ParentDeviceKey { get; set; }
|
public string ParentDeviceKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional key of the item in the parent device
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("itemKey")]
|
[JsonProperty("itemKey")]
|
||||||
public string ItemKey { get; set; }
|
public string ItemKey { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,18 @@ namespace PepperDash.Essentials.Core
|
||||||
/// The key of the device in the DeviceManager for control
|
/// The key of the device in the DeviceManager for control
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("deviceKey")]
|
[JsonProperty("deviceKey")]
|
||||||
public string DeviceKey => DeviceManager.AllDevices.
|
public string DeviceKey
|
||||||
Where(d => d.Key.Contains(ParentDeviceKey) && d.Key.Contains(ItemKey)).FirstOrDefault()?.Key ?? $"{ParentDeviceKey}--{ItemKey}";
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if(string.IsNullOrEmpty(ItemKey)) return ParentDeviceKey;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return DeviceManager.AllDevices.
|
||||||
|
Where(d => d.Key.Contains(ParentDeviceKey) && d.Key.Contains(ItemKey)).FirstOrDefault()?.Key ?? $"{ParentDeviceKey}--{ItemKey}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if the item is a level, mute , or both
|
/// Indicates if the item is a level, mute , or both
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue