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

Add support for watering reports. #101

Merged
merged 2 commits into from
Dec 17, 2023

Conversation

thomaskistler
Copy link
Contributor

Add support for watering reports.

pydrawise/schema.py Outdated Show resolved Hide resolved
pydrawise/schema.py Outdated Show resolved Hide resolved
options: list[Option] = field(default_factory=list)


class AdvancedProgramScopeEnum(Enum):
Copy link
Owner

Choose a reason for hiding this comment

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

Do you actually need this enum for something? It doesn't look very useful.

The only things that need to be defined in this file are fields that we actually want returned by the client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hard to tell whether someone will be able to use it. I'm assuming it's there for a reason.

Copy link
Owner

Choose a reason for hiding this comment

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

Sure, there's lots of stuff exposed by the GraphQL API, but I don't intend to expose all of it unless there are use-cases for it. There's a bunch of fields that are only useful for the Hydrawise app, for example.

Copy link
Owner

Choose a reason for hiding this comment

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

Another note here is that it's easy to add functionality when we find use-cases for it, but it's very hard to remove it.

pydrawise/schema.py Outdated Show resolved Hide resolved
pydrawise/schema.py Outdated Show resolved Hide resolved
pydrawise/schema.py Outdated Show resolved Hide resolved
pydrawise/schema.py Outdated Show resolved Hide resolved
pydrawise/schema.py Show resolved Hide resolved
@@ -419,7 +608,7 @@ class Controller:
sensors: list[Sensor] = field(default_factory=list)
zones: list[Zone] = field(default_factory=list)
permitted_program_start_times: list[ProgramStartTime] = field(default_factory=list)
status: Optional[ControllerStatus] = None
status: ControllerStatus = None
Copy link
Owner

Choose a reason for hiding this comment

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

If this isn't optional then it shouldn't have a default of None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did this for consistency reasons. This looks to be the convention throughout this file. There are many instances of required fields that have a default. If we want to go this route, we should probably clean it up everywhere.

Copy link
Owner

Choose a reason for hiding this comment

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

If it needs a default, then it should create an empty ControllerStatus. It's a typing violation to assign None here as it's not marked optional.

If this is incorrect elsewhere here, let's fix that in a separate PR.

pydrawise/client.py Outdated Show resolved Hide resolved
@dknowles2
Copy link
Owner

Looks like there's merge conflicts that need to be addressed.

@thomaskistler
Copy link
Contributor Author

Resolved the merge conflict.

@thomaskistler
Copy link
Contributor Author

Don't land it yet. I think you were right in that I'm going to remove some of the fields and classes to only return the data that is potentially useful.

@thomaskistler
Copy link
Contributor Author

This is ready for review now.

I guess once we land these changes, we will have to migrate the HA integration to the GraphQL API before we can really take advantage of it. Were you planning to do that already?

@thomaskistler
Copy link
Contributor Author

thomaskistler commented Dec 16, 2023

I have also started working on the migration from legacy api to new graphql api in Home Assistant here: thomaskistler/home-assistant-core#1. Before I start fixing the tests, please let me know whether this approach looks ok.

@dknowles2
Copy link
Owner

I have also started working on the migration from legacy api to new graphql api in Home Assistant here: thomaskistler/home-assistant-core#1. Before I start fixing the tests, please let me know whether this approach looks ok.

That looks really similar to what I had been working on: dknowles2/ha-core@1b7bfcc

Not sure if I'll have time in the next few weeks to get that reviewed, so feel free to send the PR upstream.

@dknowles2 dknowles2 merged commit 3d9e9b3 into dknowles2:main Dec 17, 2023
2 checks passed
@thomaskistler
Copy link
Contributor Author

Ok. I will merge the two and send them upstream.

Also, if you could cut a December release for pydrawise, that would be great. The most recent changes are required to integrate into HA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants