Skip to content

Abstract device model exteded by model name (identifier)#64

Merged
rytilahti merged 2 commits intorytilahti:masterfrom
syssi:feature/retrieve-device-model
Sep 6, 2017
Merged

Abstract device model exteded by model name (identifier)#64
rytilahti merged 2 commits intorytilahti:masterfrom
syssi:feature/retrieve-device-model

Conversation

@syssi
Copy link
Copy Markdown
Collaborator

@syssi syssi commented Sep 6, 2017

No description provided.

mirobo/device.py Outdated
import socket
import logging
from typing import Any, List
from typing import Any, List, Optional
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'typing.List' imported but unused

Copy link
Copy Markdown
Collaborator Author

@syssi syssi Sep 6, 2017

Choose a reason for hiding this comment

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

It's used as annotation. This is fine.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Indeed, I added a noqa for those cases for now.

@coveralls
Copy link
Copy Markdown

coveralls commented Sep 6, 2017

Coverage Status

Coverage increased (+0.1%) to 32.877% when pulling 75a1899 on syssi:feature/retrieve-device-model into b374872 on rytilahti:master.

mirobo/device.py Outdated

def model(self):
return self.info().model

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Although I think it's fine to expose the model information directly in DeviceInfo, I'm not sure if the Device interface should be extended to expose this too. What is the usecase you have in your mind and would it be too bad to access the model directly there on the call-site?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I want to provide the model of the device as sensor attribute at home assistant. It's good to know as long there is no discovery process and the user has to decide which component to use. Especially if various generations of a device exists I would like to handle the firmware differences properly.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Makes sense, but would it be too bad to fetch info only once and use the DeviceInfo to get extract the information out from it, making the fetch explicit and avoid doing multiple I/O calls when accessing other information from the object.

mirobo/device.py Outdated

@property
def netif(self):
def netif(self) -> str:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

IIRC these are not strings but rather dicts, maybe it's a good idea to add an example output into the class' docstring.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

My fault. I wil add a proper docstring for the future.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Not a problem. Looks like I lost my connectivity to my raspberry pi running as a controller, so I can't do much testing on this for now. If you can, could you please add the output of the info() to the doctstring of DeviceInfo class (that will also help when creating unit tests at some point).

@syssi syssi force-pushed the feature/retrieve-device-model branch from 0faacbe to fd715bd Compare September 6, 2017 17:44
@rytilahti
Copy link
Copy Markdown
Owner

Mmh, looks like coveralls got stuck for some reason. Anyway, this all looks fine so I'm merging it.

@rytilahti rytilahti merged commit 3cd4b30 into rytilahti:master Sep 6, 2017
@coveralls
Copy link
Copy Markdown

coveralls commented Sep 6, 2017

Coverage Status

Coverage increased (+0.02%) to 32.894% when pulling fd715bd on syssi:feature/retrieve-device-model into 9424964 on rytilahti:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants