-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Added continue-on-errors, added value template #8971
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
Conversation
Hello @iamjackg, When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es). The commits that are missing a linked GitHub account are the following:
Unfortunately, we are unable to accept this pull request until this situation is corrected. Here are your options:
We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community. Thanks, I look forward to checking this PR again soon! ❤️ |
else: | ||
for resrow in restable: | ||
self.value = resrow[-1] | ||
self.value = str(resrow[-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.
blank line at end of file
|
||
|
||
class SnmpData(object): | ||
"""Get the latest data and update the states.""" | ||
|
||
def __init__(self, host, port, community, baseoid, version): | ||
def __init__(self, host, port, community, baseoid, version, accept_errors, default_value): |
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 (94 > 79 characters)
_LOGGER.error("Please check the details in the configuration file") | ||
return False | ||
else: | ||
data = SnmpData(host, port, community, baseoid, version) | ||
add_devices([SnmpSensor(data, name, unit)], True) | ||
data = SnmpData(host, port, community, baseoid, version, accept_errors, default_value) |
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 (94 > 79 characters)
8ed8e09
to
1ea215e
Compare
data = SnmpData(host, port, community, baseoid, version) | ||
add_devices([SnmpSensor(data, name, unit)], True) | ||
data = SnmpData( | ||
host, port, community, baseoid,version, accept_errors, |
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.
missing whitespace after ','
I am looking forward to this! Support for |
if value is None: | ||
value = STATE_UNKNOWN | ||
elif self._value_template is not None: | ||
value = self._value_template.render_with_possible_json_value( |
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 we have json inside a snmp value?
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.
It's possible and entirely device-dependent, as SNMP can return string values. Any manufacturer can decide that one of their OIDs is going to return a JSON representation of some data. I'd rather leave the opportunity and cover the odd edge case.
* Added continue-on-errors, added value template * Refactored long lines * Fixed whitespace issues
Description:
Annoyed by the fact that my printer had to be on when I started Home Assistant, I added functionality to
The new configuration options are:
false
.accept_errors
is set and the host is unreachable or not responding. If not set, the sensor will have valueunknown
in case of errors.Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#3175
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.