Exemple #1
0
        public void SendPower(SonoffStatusEd entity, string commandName, params object[] args)
        {
            var device      = args[0] as string;
            var channel     = args[1] as string;
            var powerStatus = args[2] as string;

            _mqttService.SendMessage($"/cmnd/{device}/power{channel}", powerStatus);
        }
Exemple #2
0
 public async Task <bool> SetStatus(string deviceName, int channel, bool active)
 {
     return(await _mqttService.SendMessage(new MqttMessage()
     {
         Payload = active ? "ON" : "OFF",
         Topic = $"cmnd/{deviceName}/POWER{channel}"
     }));
 }
        public T InsertEvent <T>(T value) where T : IIotEntity
        {
            InsertOrUpdate(value);
            _eventDatabaseService.Insert(value);


            _mqttService.SendMessage($"events/{value.EntityType}", value);

            return(value);
        }
        private void DoWork(object state)
        {
            _logger.LogInformation("Timed Background Service is working.");

            try
            {
                if (_mqttService.MqttServiceClient.IsConnected)
                {
                    _mqttService.SendMessage(_appConfig.Value.MQTTMessage, "/testing");
                }
            }
            catch
            {
                _logger.LogInformation("No connection to...{0}");
            }
        }