mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
#525 Add Rooms Array & LinkToRooms method
This commit is contained in:
@@ -131,6 +131,16 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RegisterEisc();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RegisterEisc()
|
||||||
|
{
|
||||||
|
if (Eisc.Registered)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var registerResult = Eisc.Register();
|
var registerResult = Eisc.Register();
|
||||||
|
|
||||||
if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success)
|
if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||||
@@ -142,6 +152,27 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "EISC registration successful");
|
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "EISC registration successful");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LinkToRooms()
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Linking Rooms...");
|
||||||
|
|
||||||
|
foreach (var room in PropertiesConfig.Rooms)
|
||||||
|
{
|
||||||
|
var rm = DeviceManager.GetDeviceForKey(room.RoomKey) as IBridgeAdvanced;
|
||||||
|
|
||||||
|
if (rm == null)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, Debug.ErrorLogLevel.Notice,
|
||||||
|
"Room {0} does not implement IBridgeAdvanced. Skipping...", room.RoomKey);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rm.LinkToApi(Eisc, room.JoinStart, room.JoinMapKey, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterEisc();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a join map
|
/// Adds a join map
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -290,6 +321,9 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
[JsonProperty("devices")]
|
[JsonProperty("devices")]
|
||||||
public List<ApiDevicePropertiesConfig> Devices { get; set; }
|
public List<ApiDevicePropertiesConfig> Devices { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("rooms")]
|
||||||
|
public List<ApiRoomPropertiesConfig> Rooms { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public class ApiDevicePropertiesConfig
|
public class ApiDevicePropertiesConfig
|
||||||
{
|
{
|
||||||
@@ -303,6 +337,18 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
public string JoinMapKey { get; set; }
|
public string JoinMapKey { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ApiRoomPropertiesConfig
|
||||||
|
{
|
||||||
|
[JsonProperty("roomKey")]
|
||||||
|
public string RoomKey { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("joinStart")]
|
||||||
|
public uint JoinStart { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("joinMapKey")]
|
||||||
|
public string JoinMapKey { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EiscApiAdvancedFactory : EssentialsDeviceFactory<EiscApiAdvanced>
|
public class EiscApiAdvancedFactory : EssentialsDeviceFactory<EiscApiAdvanced>
|
||||||
|
|||||||
Reference in New Issue
Block a user