-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Introduced Iperf3 client sensor #14213
Conversation
hass, self.update, second=config.get(CONF_SECOND), | ||
minute=config.get(CONF_MINUTE), hour=config.get(CONF_HOUR), | ||
day=config.get(CONF_DAY)) | ||
@property |
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.
expected 1 blank line, found 0
@property | ||
def service_name(self): | ||
"""Return the service name of the sensor.""" | ||
return slugify("{} {}".format('update_iperf3', self.iperf3_client.server)) |
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.
line too long (82 > 79 characters)
ATTR_TEST_STATUS = 'Test Status' | ||
ATTR_VERSION = 'Version' | ||
|
||
CONF_ATTRIBUTION = 'Data retrived using Iperf3' |
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.
Typo: retrieved
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.
Thanks! 👍
LGTM just the config schema should be improved. What about a list of time periods instead of the bunch of config keys (hour, minute, second)? |
@syssi I decided to follow this format as it is already in use in Fastcom and Speedtest sensors. Maybe we can simplify it and then change in all related components. I'm planning to do it in the future. Thanks for your review. |
CONF_MANUAL = 'manual' | ||
CONF_DURATION = 'duration' | ||
CONF_SERVER = 'server' | ||
CONF_PORT = 'port' |
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.
Can you please check if some of those constants are present already in const.py
?
vol.All(cv.ensure_list, [vol.All(vol.Coerce(int), vol.Range(0, 59))]), | ||
vol.Optional(CONF_MINUTE, default=[0]): | ||
vol.All(cv.ensure_list, [vol.All(vol.Coerce(int), vol.Range(0, 59))]), | ||
vol.Optional(CONF_HOUR): |
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.
Please remove this. For platforms Home Assistant already allows users to override a scan interval by passing scan_interval: <duration>
to the platform config. This is defined in PLATFORM_SCHEMA
which you extend. To set a default, define a SCAN_INTERVAL = timedelta(minutes=30)
sensor.update() | ||
|
||
for sensor in dev: | ||
hass.services.register(DOMAIN, sensor.service_name, update) |
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.
All services need to be always prefixed with the platform name.
_LOGGER.error("Iperf3 sensor error: %s", result.error) | ||
|
||
self.data = { | ||
'download': STATE_UNKNOWN, |
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.
Don't use STATE_UNKNOWN
, use None
instead.
ATTR_PROTOCOL: STATE_UNKNOWN, | ||
ATTR_REMOTE_HOST: STATE_UNKNOWN, | ||
ATTR_REMOTE_PORT: STATE_UNKNOWN, | ||
ATTR_VERSION: STATE_UNKNOWN, |
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.
We should not store static info in the attributes.
return ICON | ||
|
||
|
||
class Iperf3Data(object): |
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.
Since there is only 1 per entity, why extract it into its own class?
@balloob @fabaff guys, PR updated. Just one observation is to create the I noticed that we have this issue when using the Thanks guys |
If the component has an entity_id (like yours) a service call should look like this:
If you want to update all iperf3 sensors you could call Please prefix the service name with |
self._state = round(self.result.sent_Mbps, 2) | ||
|
||
@asyncio.coroutine | ||
def async_added_to_hass(self): |
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.
We should not restore state from the database since it can be queried from the device
@pvizeli This component requires the iperf3 binary > 3.0.6. What's needed to provide this dependency on hass.io? |
@syssi Thanks for your code review. I have actually already a PR ready to be submitted to add support to https://github.com/home-assistant/home-assistant/blob/dev/Dockerfile and I'm working on a separate PR too to HASS.io. I was waiting that to be merged so then I submit the next 2 ones. |
…removed state restore
@syssi Updated this PR to make sure Iperf3 will add support to Home assistant docker image [1]. I'll submit a PR to HASS soon too. [1] - https://hub.docker.com/r/homeassistant/home-assistant/ |
@syssi @pvizeli PR for hassio-build added at home-assistant/hassio-build#77 |
Actually, if you just need to install a package without compiling or other repositories, you should just add the package in the setup_prereqs file. The separate scripts are for packages that need more work to install. |
Thanks @michaelarnauts I'll make sure on the next PRs to do it this way! 👍 |
Description:
Introducing Iperf3 client sensor. With this sensor is possible to use iperf3 to test your network connection against a local or remote Iperf3 server.
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5282
Pull request in home-assistant/hassio-build: home-assistant/hassio-build#77
Example entry for
configuration.yaml
(if applicable):Download
Upload
Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable ([example][ex-requir]).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: