public TemperatureSensor(DeviceClient client, string componentName, ILogger log) : base(client, componentName, log) { base.SetPnPDesiredPropertyHandlerAsync <double>( "targetTemperature", (newValue) => OnTargetTempReceived?.Invoke(this, new TemperatureEventArgs(newValue)), this).Wait(); }
private void TriggerEventIfValueIsDouble(object newValue) { if (newValue != null && double.TryParse(newValue.ToString(), out double target)) { OnTargetTempReceived?.Invoke(this, new TemperatureEventArgs(target)); } else { logger.LogWarning("!!!!!!!!!!!! value is not double, skipping event"); } }
public async Task InitAsync() { var initialTarget = await base.ReadDesiredPropertyAsync <double>("targetTemperature"); OnTargetTempReceived?.Invoke(this, new TemperatureEventArgs(initialTarget)); }