Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hassmodel APIs creates entities of types created by nd-codegen #1188

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

FrankBakkerNl
Copy link
Contributor

@FrankBakkerNl FrankBakkerNl commented Oct 16, 2024

Proposed change

When using nd-codegen the HassModel API's can now return entities of the generated types. So you can eg do

var allLights = haContext.GetAllEntities().OfType()

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • The code compiles without warnings (code quality check)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration are added/changed:

Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 96.15385% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82%. Comparing base (2dabce4) to head (4f29244).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...sModel/NetDeamon.HassModel/Entities/StateChange.cs 0% 0 Missing and 1 partial ⚠️
...n.HassModel/Internal/AppScopedHaContextProvider.cs 80% 1 Missing ⚠️
Additional details and impacted files
@@         Coverage Diff          @@
##           main   #1188   +/-   ##
====================================
  Coverage    82%     82%           
====================================
  Files       193     196    +3     
  Lines      3790    3820   +30     
  Branches    425     428    +3     
====================================
+ Hits       3132    3162   +30     
  Misses      491     491           
  Partials    167     167           
Flag Coverage Δ
unittests 82% <96%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@helto4real helto4real left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean and nice code as usual. Specially liked the tests you added!

var entityClasses = EntitiesGenerator.Generate(entityDomains);
var serviceClasses = ServicesGenerator.Generate(orderedServiceDomains);
var extensionMethodClasses = ExtensionMethodsGenerator.Generate(orderedServiceDomains, entityDomains);

return new[] { helpers, entityClasses, serviceClasses, extensionMethodClasses }.SelectMany(x => x).ToArray();
return [..helpers, entityFactory, ..entityClasses, ..serviceClasses, ..extensionMethodClasses];
Copy link
Collaborator

@helto4real helto4real Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just love this syntax!

@helto4real helto4real merged commit c7a4ec4 into net-daemon:main Oct 17, 2024
7 of 8 checks passed
@FrankBakkerNl FrankBakkerNl deleted the EntityFactory branch October 24, 2024 19:10
helto4real pushed a commit that referenced this pull request Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants