示例#1
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="entityIds">The unique ids of the entities managed</param>
 /// <param name="daemon">The Daemon that will handle API calls to Home Assistant</param>
 public EntityManager(IEnumerable <string> entityIds, INetDaemon daemon)
 {
     _entityIds = entityIds;
     _daemon    = daemon;
 }
示例#2
0
        public static async Task HandleAttributeInitialization(this INetDaemonAppBase netDaemonApp, INetDaemon _daemon)
        {
            var netDaemonAppType = netDaemonApp.GetType();

            foreach (var method in netDaemonAppType.GetMethods())
            {
                foreach (var attr in method.GetCustomAttributes(false))
                {
                    if (netDaemonApp is NetDaemonApp daemonApp)
                    {
                        switch (attr)
                        {
                        case HomeAssistantServiceCallAttribute hasstServiceCallAttribute:
                            await HandleServiceCallAttribute(_daemon, daemonApp, method, true).ConfigureAwait(false);

                            break;

                        case HomeAssistantStateChangedAttribute hassStateChangedAttribute:
                            HandleStateChangedAttribute(_daemon, hassStateChangedAttribute, daemonApp, method);
                            break;
                        }
                    }
                    else if (netDaemonApp is NetDaemonRxApp daemonRxApp)
                    {
                        switch (attr)
                        {
                        case HomeAssistantServiceCallAttribute hasstServiceCallAttribute:
                            await HandleServiceCallAttribute(_daemon, daemonRxApp, method, false).ConfigureAwait(false);

                            break;
                        }
                    }
                }
            }
        }
示例#3
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="entityIds">The unique ids of the entities managed</param>
 /// <param name="daemon">The Daemon that will handle API calls to Home Assistant</param>
 public MediaPlayerManager(IEnumerable <string> entityIds, INetDaemon daemon) : base(entityIds, daemon)
 {
 }
示例#4
0
        public static void HandleAttributeInitialization(this INetDaemonApp netDaemonApp, INetDaemon _daemon)
        {
            var netDaemonAppType = netDaemonApp.GetType();

            foreach (var method in netDaemonAppType.GetMethods())
            {
                foreach (var attr in method.GetCustomAttributes(false))
                {
                    switch (attr)
                    {
                    case HomeAssistantServiceCallAttribute hasstServiceCallAttribute:
                        HandleServiceCallAttribute(_daemon, netDaemonApp, method);
                        break;

                    case HomeAssistantStateChangedAttribute hassStateChangedAttribute:
                        HandleStateChangedAttribute(_daemon, hassStateChangedAttribute, netDaemonApp, method);
                        break;
                    }
                }
            }
        }
示例#5
0
 public DelayResult(TaskCompletionSource <bool> delayTaskCompletionSource, INetDaemon daemon)
 {
     _delayTaskCompletionSource = delayTaskCompletionSource;
     _daemon = daemon;
 }
示例#6
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="daemon">The NetDaemon that handles API calls to Home Assistant</param>
 public TimeManager(INetDaemon daemon)
 {
     _daemon = daemon;
 }