private async Task GenerateEntities(NetDaemonHost daemonHost, string sourceFolder) { if (!_netDaemonSettings.GenerateEntities.GetValueOrDefault()) { return; } if (_entitiesGenerated) { return; } _logger.LogTrace("Generating entities from Home Assistant instance .."); _entitiesGenerated = true; var services = await daemonHost.GetAllServices().ConfigureAwait(false); var sourceRx = CodeGenerator.GenerateCodeRx( "Netdaemon.Generated.Reactive", daemonHost.State.Select(n => n.EntityId).Distinct(), services ); await File.WriteAllTextAsync(Path.Combine(sourceFolder !, "_EntityExtensionsRx.cs.gen"), sourceRx).ConfigureAwait(false); }
private async Task GenerateEntitiesAsyncInternal(NetDaemonHost daemonHost, string sourceFolder) { var services = await daemonHost.GetAllServices().ConfigureAwait(false); var entityIds = daemonHost.State.Distinct().ToList(); var sourceRx = _codeGenerator.GenerateCodeRx( "NetDaemon.Generated.Reactive.Services", entityIds, services.ToList() ); await File.WriteAllTextAsync(Path.Combine(sourceFolder, "_EntityExtensionsRx.cs.gen"), sourceRx).ConfigureAwait(false); }