Пример #1
0
        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 });
        }
Пример #2
0
 public Manager(INetDaemonRxApp app, Configurator configurator)
 {
     _app          = app;
     _configurator = configurator;
     _configurator.Configure(_app);
     Subscriptions.Setup(_app, _configurator, this);
 }
Пример #3
0
        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;
            }
        }
Пример #4
0
        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);
        }
Пример #5
0
 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);
 }
Пример #6
0
 /// <summary>
 /// Initialize using the Home Assistant Default
 /// </summary>
 /// <param name="daemon"></param>
 /// <returns></returns>
 public SunEntity(INetDaemonRxApp daemon) : this(daemon, new[] { "sun.sun" })
 {
 }
Пример #7
0
 /// <inheritdoc />
 public BinarySensorEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds)
 {
 }
 /// <inheritdoc />
 public PersistentNotificationEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon,
                                                                                                    entityIds)
 {
 }
Пример #9
0
 private static void SetupSubscriptionHandler(INetDaemonRxApp app, EventType eventType, EventHandler <HassEventArgs> handler, IEnumerable <string> configEntityIds, string roomName, Func <(EntityState Old, EntityState New), bool> predicate = null !)
Пример #10
0
 /// <inheritdoc />
 public InputBooleanEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds)
 {
 }
Пример #11
0
 /// <inheritdoc />
 public DeviceTrackerEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds)
 {
 }
Пример #12
0
 /// <inheritdoc />
 public AlarmControlPanelEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds)
 {
 }
Пример #13
0
 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();
 }
Пример #15
0
 /// <inheritdoc />
 public AutomationEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds)
 {
 }
Пример #16
0
 /// <inheritdoc />
 public ImageProcessingEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds)
 {
 }
Пример #17
0
 public HelloWorldImplementation(INetDaemonRxApp x)
 {
     app = x;
 }
Пример #18
0
 /// <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)
 {
 }
Пример #19
0
 public FakeMockableAppImplementation(INetDaemonRxApp app)
 {
     _app = app;
 }
Пример #20
0
 /// <inheritdoc />
 public MediaPlayerEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds)
 {
 }
Пример #21
0
 /// <inheritdoc />
 public ZoneEntity(INetDaemonRxApp daemon, IEnumerable <string> entityIds) : base(daemon, entityIds)
 {
 }
Пример #22
0
 public HouseModeImplementation(INetDaemonRxApp app, IScheduler?scheduler = null)
 {
     Scheduler = scheduler;
     _app      = app;
 }