public void Configure(INetDaemonRxApp app) { _app = app; Lights = new List <LightEntityDummy>(); foreach (var entityId in FilterControlEntities("light.")) { Lights.Add(new LightEntityDummy(app, new[] { entityId })); } Switches = new List <LightEntityDummy>(); foreach (var entityId in FilterControlEntities("switch.")) { Switches.Add(new LightEntityDummy(app, new[] { entityId })); } PresenceSensors = new List <BinarySensorEntity>(); foreach (var entityId in _config.PresenceEntityIds.Union(_config.KeepAliveEntityIds)) { PresenceSensors.Add(new BinarySensorEntity(app, new[] { entityId })); } NightTime = new BinarySensorEntity(app, new[] { _config.NightTimeEntityId }); }
public Manager(INetDaemonRxApp app, Configurator configurator) { _app = app; _configurator = configurator; _configurator.Configure(_app); Subscriptions.Setup(_app, _configurator, this); }
public RoomPresenceImplementation(INetDaemonRxApp app, PresenceConfig presenceConfig, IRandomController controller) { _app = app; _presenceConfig = presenceConfig; _controller = controller; try { _roomConfig = presenceConfig.RoomConfig; Scheduler = presenceConfig.Scheduler; _tracePrefix = $"({_roomConfig.Name}) - "; _normalTimeout = TimeSpan.FromSeconds(presenceConfig.RoomConfig.Timeout != 0 ? presenceConfig.RoomConfig.Timeout : 300); _nightTimeout = TimeSpan.FromSeconds(presenceConfig.RoomConfig.NightTimeout != 0 ? presenceConfig.RoomConfig.NightTimeout : 60); _overrideTimeout = TimeSpan.FromSeconds(presenceConfig.RoomConfig.OverrideTimeout != 0 ? presenceConfig.RoomConfig.OverrideTimeout : 900); _presenceEntityIds = presenceConfig.RoomConfig.PresenceEntityIds?.ToArray() ?? Array.Empty <string>(); _controlEntityIds = presenceConfig.RoomConfig.ControlEntityIds.ToArray(); _nightControlEntityIds = presenceConfig.RoomConfig.NightControlEntityIds.ToArray(); _keepAliveEntityIds = presenceConfig.RoomConfig.KeepAliveEntityIds.ToArray(); NdUserId = presenceConfig.NdUserId; } catch (Exception e) { _app.LogError(e, "Error in Constructor"); throw; } }
public static void Setup(INetDaemonRxApp app, Configurator configurator, Manager manager) { PresenceStartedHandler += manager.OnPresenceStarted; PresenceStoppedHandler += manager.OnPresenceStopped; HouseModeChangedHandler += manager.OnHouseModeChanged; SetupSubscriptionHandler(app, EventType.PresenceStarted, PresenceStartedHandler, configurator.PresenceSensors.Select(p => p.EntityId), configurator.RoomName, e => e.Old?.State == "off" && e.New?.State == "on"); SetupSubscriptionHandler(app, EventType.PresenceStopped, PresenceStoppedHandler, configurator.PresenceSensors.Select(p => p.EntityId), configurator.RoomName, e => e.Old?.State == "on" && e.New?.State == "off"); SetupSubscriptionHandler(app, EventType.HouseModeChanged, HouseModeChangedHandler, configurator.NightTime.EntityId, configurator.RoomName); }
public static string EntityState(this INetDaemonRxApp app, string?entityId) { if (entityId == null) { return(StartUp.UNKNOWN); } if (app.States.Any(e => e.EntityId == entityId)) { return(app.State(entityId)?.State?.ToString() ?? StartUp.UNKNOWN); } return(StartUp.UNKNOWN); }
/// <summary> /// Initialize using the Home Assistant Default /// </summary> /// <param name="daemon"></param> /// <returns></returns> public SunEntity(INetDaemonRxApp daemon) : this(daemon, new[] { "sun.sun" }) { }
/// <inheritdoc /> public BinarySensorEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds) { }
/// <inheritdoc /> public PersistentNotificationEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds) { }
private static void SetupSubscriptionHandler(INetDaemonRxApp app, EventType eventType, EventHandler <HassEventArgs> handler, IEnumerable <string> configEntityIds, string roomName, Func <(EntityState Old, EntityState New), bool> predicate = null !)
/// <inheritdoc /> public InputBooleanEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds) { }
/// <inheritdoc /> public DeviceTrackerEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds) { }
/// <inheritdoc /> public AlarmControlPanelEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds) { }
public static void LogEventHandled(this INetDaemonRxApp app, HassEventArgs args) { app.LogInformation("{CorrelationId} - Event Handled: {EventType}", args.CorrelationId, args.EventType); }
public LightEntityDummy(INetDaemonRxApp app, IEnumerable <string> entityIds) { _app = app; EntityId = entityIds.First(); }
/// <inheritdoc /> public AutomationEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds) { }
/// <inheritdoc /> public ImageProcessingEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds) { }
public HelloWorldImplementation(INetDaemonRxApp x) { app = x; }
/// <summary> /// Representing an AlarmControlPanel entity. /// </summary> /// <param name="daemon">An instance of <see cref="INetDaemonRxApp"/>.</param> /// <param name="entityIds">A list of entity id's that represent this entity</param> protected RxEntityBase(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds) { }
public FakeMockableAppImplementation(INetDaemonRxApp app) { _app = app; }
/// <inheritdoc /> public MediaPlayerEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds) { }
/// <inheritdoc /> public ZoneEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds) { }
public HouseModeImplementation(INetDaemonRxApp app, IScheduler?scheduler = null) { Scheduler = scheduler; _app = app; }