-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
[WIP] A basic proposal setup of entity representations as c# classes #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Handle state updates
[SetUp] | ||
public void Setup() | ||
{ | ||
_entityClientMock = new Mock<EntityClient>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: This doesn't work. Sealed classes cannot be mocked. Either delete unittests, use another constructor, or add interfaces.
So, I want to take a step back here before anyone adds more code to this... Please see my comment here: #11 Ultimately, my goal for this library specifically is to provide a C# layer on top of the REST API that Home Assistant provides out of the box. Basically a 1:1 command mapping with this: https://developers.home-assistant.io/docs/api/rest Now, I completely understand the value here - I totally agree that you should be able to do something like: Entities.Lights["my_light"].TurnOn(); However, I'd envision that as actually a completely separate project/repo/NuGet package from this one. Reason being, there are folks that just want exactly what this library provides - a nice REST wrapper - and nothing more. And then there are a different set of folks who actually want the super-friendly, easy-to-use C# interface that may give you some ease of use while sacrificing some performance. The way I see it, there are really three layers here:
If there is enough interest in this, I'd be happy to start up a repo and a codebase and start accepting PRs. I think if all of these libraries are under the same name, it may lessen some of the confusion - and I can even add a page to https://hacc.dev that explains these, since they're ultimately the same "family" of products/libraries. Thoughts? |
@qJake I understand your thoughts completely, which is also a reason why I've made everything in a separate project apart from yours (except for the constants, but they could be in the extra project too). The idea was also to put it in a separate NuGet package. It is totally valid to say this does not/should not belong here. My attempt was only for fullfilling mine and maybe other's extra needs. Because the base was already made by you, I thought it was suitable to extend it from here. If you would rather have this to be a separate github project, no problem at all! Then I'll just move it to my own github (or a new project under yours). |
@qJake @PockyBum522 I've moved the code to a separate project on my github: This PR can be closed |
Please review and comment for using such a setup. I want to have specific classes that represent the HA entities in my (to-be developed) project.
Addresses #12
Features:
EntitiesService
with methods to retrieve entities in the form of strongly typed C# classes. Currently implemented:Proposed (extra) features/nice-to-haves:
TurnOn(this IEnumerable<Light> lights)
to turn on a collection of lights (maybe in a separate project/NuGet package?)EntitiesService
only. Probably also make the Clients DI friendly?GetEntities
methodExample usage: