/// <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="deviceRepository">Device repository.</param> /// <param name="stateCache">State cache,</param> public GoogleHomeGraphService( ILogger <GoogleHomeGraphService> logger, IMessageHub messageHub, GoogleHomeGraphClient googleHomeGraphClient, GoogleDeviceRepository deviceRepository, StateCache stateCache) { _log = logger ?? throw new ArgumentException(nameof(logger)); _messageHub = messageHub ?? throw new ArgumentException(nameof(messageHub)); _googleHomeGraphClient = googleHomeGraphClient ?? throw new ArgumentException(nameof(googleHomeGraphClient)); _deviceRepository = deviceRepository ?? throw new ArgumentException(nameof(deviceRepository)); _stateCache = stateCache ?? throw new ArgumentException(nameof(stateCache)); }
/// <summary> /// Initializes a new instance of the <see cref="MqttService"/> class. /// </summary> /// <param name="logger">Logging instance.</param> /// <param name="messageHub">Message hub.</param> /// <param name="brokerSettings">MQTT broker settings.</param> /// <param name="deviceRepository">Device repository.</param> /// <param name="stateCache">State cache,</param> public MqttService( ILogger <MqttService> logger, IMessageHub messageHub, BrokerSettings brokerSettings, GoogleDeviceRepository deviceRepository, StateCache stateCache) : base(logger, brokerSettings, "google/home") { _log = logger ?? throw new ArgumentException(nameof(logger)); _messageHub = messageHub ?? throw new ArgumentException(nameof(messageHub)); _deviceRepository = deviceRepository ?? throw new ArgumentException(nameof(deviceRepository)); _stateCache = stateCache ?? throw new ArgumentException(nameof(stateCache)); // Subscribe to google home based topics SubscribedTopics.Add(TopicRoot + "/#"); // Subscribe to all monitored state topics foreach (var topic in _stateCache.Keys) { SubscribedTopics.Add(topic); } }
/// <summary> /// Initializes a new instance of the <see cref="MqttService"/> class. /// </summary> /// <param name="logger">Logging instance.</param> /// <param name="deviceRepository">Device repository.</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, GoogleDeviceRepository deviceRepository, StateCache stateCache, IMessageHub messageHub, GoogleHomeGraphClient googleHomeGraphClient, BrokerSettings brokerSettings) : base(logger, brokerSettings, "google/home") { _log = logger; _deviceRepository = deviceRepository; _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); } }