Open adamurban opened 3 years ago
Thank you for the PR! I was kind of hoping Leviton would offer a real API at this point so I could stop maintaining this hacked-together Repo, but alas! :-p
Code looks fine so far. Leave me a comment here when you're ready for a detailed review.
Yeah, I'm also hoping for a local API, but so far they've made it pretty clear that's not really going to happen :/
Happy for a more detailed review now if you're up for it; I don't currently plan to add support for more API methods at this time than the ones I've included here (unless there is something I missed that's useful for energy metering?), so the remaining work on this side is just cleaning things up.
Some initial questions / thoughts from my side:
1) Do I actually need to store residentialBreakerPanelId
as part of the base model, or is there a better way to handle this?
2) What's the best way to handle the required timestamp format/is there a better way to accept a wide variety of input formats and convert to the one the API needs?
Would also love your thoughts on the best way to pull breaker panels into Home Assistant. Could tack on some new data types (beyond switches) (ie, sensors) to the existing decora_wifi integration, or could make a new "leviton_breaker" or similar integration (which would be easier for me I think, but might not be as useful for people that have both in their system).
Bump :). I would love to see this merged.
I would suggest that you use a pytz object to store the timezone and then manipulate a datetime to provide a day/ week/ month/ year. Alternatively, the user could provide a string and based off the input type, you format it for the API.
I'm no HA expert, but my thinking is: Ultimately breakers are switches (albeit important ones) . I actually think of it in a similar manner to the TP-Link kasa devices that provide a switch as well as a voltage/ current/ power sensor.
Initial API models for pulling energy data for Smart Breakers.
Example usage:
Example output from breaker.get_energy_consumption_for_month():