-
-
Notifications
You must be signed in to change notification settings - Fork 32k
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 additional sensors to RainMachine #80914
Conversation
Hey there @bachya, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
@bachya All information is already returned every minute from the |
More fun with the RainMachine API. 😂 |
As a side note: my unit was severely borked a while back and I had to get creative in some ssh repairs--long story short, I have some de-compiled python source code for the main controller if you ever need it for reference. |
@@ -317,6 +377,14 @@ def update_from_latest_data(self) -> None: | |||
self._attr_native_value = self.coordinator.data.get("system", {}).get( | |||
"flowSensorWateringClicks" | |||
) | |||
elif self.entity_description.key == TYPE_LAST_LEAK_DETECTED: | |||
self._attr_native_value = utc_from_timestamp( | |||
self.coordinator.data.get("system", {}).get("lastLeakDetected") |
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.
Won't utc_from_timestamp
blow up if this ends up being None
?
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.
Yep. Resolved in the restuctured method. See comment below.
) | ||
|
||
if clicks and clicks_per_m3: | ||
self._attr_native_value = round((clicks * 1000) / clicks_per_m3, 1) |
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.
Feels like we have a bunch of replicated logic throughout here – what would you think about some easy helper methods (attached to this class) that centralize it?
I would look at anything you're replicating between sensor types (e.g., the round((clicks * 1000) / clicks_per_m3, 1)
calculation [and the data points fed into it]).
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.
Restructured the method to be less redundant. Take a look.
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.
Looks reasonable to me!
You've confirmed this functionally works? |
config_entry-rainmachine-044f461135ae717322ae9b933b75b1a4.json.txt Side note: any objections to using the |
Caught an error when I reset the last leak event in the controller. API says it uses |
That would be useful! I'd make that a config entry option so users can decide if they want that or a manually set duration (would avoid a breaking change, too). |
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.
Looks great!
Only problem is I have NO IDEA where those durations are being set. They don't match the last manual runs or the suggested program values. I'll do a PR in the future if I figure out how to set/store them, but for now, I'll leave it alone. |
Ahh.. found it. It's the last manual time you used in the RainMachine App. |
Proposed change
Expose additional sensors from the RainMachine controller:
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: