-
Notifications
You must be signed in to change notification settings - Fork 68
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
Reduce code duplication in entities #111
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.
Looks really good, thank you 💥
The only thing I'm not really happy about is duplicating all the methods in sensors/alarms. But i think we can reduce that too :)
Thanks @KapJI for taking the initiative to do this. 🚀😁 |
@KapJI, are you still working on it? Please re-request review when you want some of us to review :) |
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 good to me!
I'd be happy if we can try it locally just to make sure it doesn't break anything before merging it :)
def get_device(self): | ||
"""Return the device matched by device name | ||
from the list of google devices in coordinator_data""" | ||
matched_devices = [ | ||
device | ||
for device in self.coordinator.data | ||
if device.name == self.device_name | ||
] | ||
return matched_devices[0] if matched_devices else 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.
Love it! Thanks for implementing it. Maybe not the most looking solution, but hopefully more robust
I tested it locally, works as before :) |
Simplify class structure.
model
with invalidVERSION
fordevice_info
. We don't really want to maintain version in different places.GoogleHomeDeviceSensor
constructor the same as for other sensors. If there is no such device incoordinator_data
, set state toNone
, it should render asunknown
in HA.GoogleHomeAlarmSensor
toGoogleHomeAlarmsSensor
, same forTimers
.GoogleHomeDeviceSensor
.