Added option to invert aREST pin switch logic for active low relays#14467
Merged
Conversation
houndci-bot
reviewed
May 15, 2018
| one_or_zero = 1 if self.invert else 0 | ||
| request = requests.get( | ||
| '{}/digital/{}/0'.format(self._resource, self._pin), timeout=10) | ||
| '{}/digital/{}/{}'.format(self._resource, self._pin, one_or_zero), timeout=10) |
There was a problem hiding this comment.
line too long (90 > 79 characters)
| one_or_zero = 0 if self.invert else 1 | ||
| request = requests.get( | ||
| '{}/digital/{}/1'.format(self._resource, self._pin), timeout=10) | ||
| '{}/digital/{}/{}'.format(self._resource, self._pin, one_or_zero), timeout=10) |
There was a problem hiding this comment.
line too long (90 > 79 characters)
syssi
reviewed
May 15, 2018
|
|
||
| PIN_FUNCTION_SCHEMA = vol.Schema({ | ||
| vol.Optional(CONF_NAME): cv.string, | ||
| vol.Optional(CONF_INVERT): cv.boolean, |
Member
There was a problem hiding this comment.
Please apply the default (False) here.
syssi
reviewed
May 15, 2018
|
|
||
| def turn_off(self, **kwargs): | ||
| """Turn the device off.""" | ||
| one_or_zero = 1 if self.invert else 0 |
Member
There was a problem hiding this comment.
I'm not happy about the naming. turn_off_payload = int(not invert)?
houndci-bot
reviewed
May 15, 2018
There was a problem hiding this comment.
line too long (83 > 79 characters)
There was a problem hiding this comment.
line too long (82 > 79 characters)
17a1983 to
2afd494
Compare
syssi
reviewed
May 15, 2018
| dev.append(ArestSwitchPin( | ||
| resource, config.get(CONF_NAME, response.json()[CONF_NAME]), | ||
| pin.get(CONF_NAME), pinnum)) | ||
| pin.get(CONF_NAME), pinnum, pin.get(CONF_INVERT, False))) |
Contributor
Author
There was a problem hiding this comment.
Good catch, thanks. Done.
w1ll1am23
pushed a commit
to home-assistant/home-assistant.io
that referenced
this pull request
May 15, 2018
2 tasks
Merged
girlpunk
pushed a commit
to girlpunk/home-assistant
that referenced
this pull request
Sep 4, 2018
…ome-assistant#14467) * Added option to invert aREST pin switch logic for active low relays * Fixed line lengths * Changed naming and set optional invert default value. * Fixed line length * Removed default from get
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
The current aREST pin switch assumes that setting the pin HIGH will turn a switch on, however when using the widely available and super common mechanical relay module that isn't the case. These modules are active low, meaning that the relay is turned on when the pin is set LOW. This change allows the user to specify if the pin switch logic should be inverted i.e. HIGH = off and LOW = on
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5377
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed: