public override Task <bool> Start() { _mqttService.SubscribeTopic("tele/+/+"); _mqttService.SubscribeTopic("stat/+/+"); _mqttService.SubscribeTopic("cmnd/+/+"); _mqttService.MqttMessageObservable.Subscribe(OnMqttMessage); return(base.Start()); }
public Task <bool> Start() { _mqttService.SubscribeTopic(_config.DefaultOwnTrackTopic); _mqttService.OnMqttMessage.Subscribe(message => { if (message.Topic.Contains("owntracks/user/")) { var homeCoordinate = new Coordinate(_neonConfig.Home.Latitude, _neonConfig.Home.Longitude); var ownTrackData = message.Message.FromJson <OwnTracksData>(); var deviceCoordinate = new Coordinate(ownTrackData.Latitude, ownTrackData.Longitude); var ev = new OwnTracksEd { Longitude = ownTrackData.Longitude, Latitude = ownTrackData.Latitude, EntityName = ownTrackData.IdName, BatteryLevel = ownTrackData.Battery, Altitude = ownTrackData.Altitude, DistanceFromHome = new Distance(homeCoordinate, deviceCoordinate).Kilometers }; _ioTService.InsertEvent(ev); _logger.LogInformation($"Received position from id {ev.EntityName}"); } }); return(Task.FromResult(true)); }
public override Task <bool> Start() { Logger.LogInformation($"Subscribing topic {Config.Topic}"); _mqttService.MqttMessageObservable.Subscribe(OnMqttMessage); _mqttService.SubscribeTopic(Config.Topic); return(base.Start()); }
public Task <bool> Start() { if (_config.EnabledDiscovery) { _logger.LogInformation("Enabled discovery for network"); _mqttService.SubscribeTopic(_config.BaseTopic); _mqttService.OnMqttMessage.Subscribe(message => { if (message.Topic.StartsWith("tele/")) { ParseMqttMessage(message.Topic, message.Message); } }); } return(Task.FromResult(true)); }