示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GoogleHomeGraphService"/> class.
 /// </summary>
 /// <param name="logger">Logging instance.</param>
 /// <param name="messageHub">Message hub.</param>
 /// <param name="googleHomeGraphClient">Google Home Graph API client.</param>
 /// <param name="stateCache">State cache,</param>
 public GoogleHomeGraphService(
     ILogger <GoogleHomeGraphService> logger,
     IMessageHub messageHub,
     GoogleHomeGraphClient googleHomeGraphClient,
     StateCache stateCache)
 {
     _log                   = logger ?? throw new ArgumentException(nameof(logger));
     _messageHub            = messageHub ?? throw new ArgumentException(nameof(messageHub));
     _googleHomeGraphClient = googleHomeGraphClient ?? throw new ArgumentException(nameof(googleHomeGraphClient));
     _stateCache            = stateCache ?? throw new ArgumentException(nameof(stateCache));
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MqttService"/> class.
        /// </summary>
        /// <param name="logger">Logging instance.</param>
        /// <param name="deviceConfiguration">Ddevice configuration.</param>
        /// <param name="stateCache">State cache,</param>
        /// <param name="messageHub">Message hub.</param>
        /// <param name="googleHomeGraphClient">Google Home Graph API client.</param>
        /// <param name="brokerSettings">MQTT broker settings.</param>
        public MqttService(
            ILogger <MqttService> logger,
            DeviceConfiguration deviceConfiguration,
            StateCache stateCache,
            IMessageHub messageHub,
            GoogleHomeGraphClient googleHomeGraphClient,
            BrokerSettings brokerSettings)
            : base(logger, brokerSettings, "google/home/")
        {
            _log                   = logger;
            _deviceConfig          = deviceConfiguration;
            _stateCache            = stateCache;
            _messageHub            = messageHub;
            _googleHomeGraphClient = googleHomeGraphClient;

            // Subscribe to google home based topics
            SubscribedTopics.Add(TopicRoot + "#");

            // Subscribe to all monitored state topics
            foreach (var topic in _stateCache.Keys)
            {
                SubscribedTopics.Add(topic);
            }
        }