-
-
Notifications
You must be signed in to change notification settings - Fork 38k
Add relay addr & chan config to alarmdecoder zones #15242
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
Merged
+35
−4
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b797bca
Add relay addr & chan config to zones
digiblur 1ccf1af
Correct long lines
digiblur 5fd7195
Add ident
digiblur 38c1a41
Minor capitalization comment change
digiblur 497e5da
Added debug logger message
digiblur 0087aea
Update addr/chan config and debug logging
digiblur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,8 @@ | |
| from homeassistant.components.alarmdecoder import ( | ||
| ZONE_SCHEMA, CONF_ZONES, CONF_ZONE_NAME, CONF_ZONE_TYPE, | ||
| CONF_ZONE_RFID, SIGNAL_ZONE_FAULT, SIGNAL_ZONE_RESTORE, | ||
| SIGNAL_RFX_MESSAGE) | ||
| SIGNAL_RFX_MESSAGE, SIGNAL_REL_MESSAGE, CONF_RELAY_ADDR, | ||
| CONF_RELAY_CHAN) | ||
|
|
||
| DEPENDENCIES = ['alarmdecoder'] | ||
|
|
||
|
|
@@ -37,8 +38,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None): | |
| zone_type = device_config_data[CONF_ZONE_TYPE] | ||
| zone_name = device_config_data[CONF_ZONE_NAME] | ||
| zone_rfid = device_config_data.get(CONF_ZONE_RFID) | ||
| relay_addr = device_config_data.get(CONF_RELAY_ADDR) | ||
| relay_chan = device_config_data.get(CONF_RELAY_CHAN) | ||
| device = AlarmDecoderBinarySensor( | ||
| zone_num, zone_name, zone_type, zone_rfid) | ||
| zone_num, zone_name, zone_type, zone_rfid, relay_addr, relay_chan) | ||
| devices.append(device) | ||
|
|
||
| add_devices(devices) | ||
|
|
@@ -49,14 +52,16 @@ def setup_platform(hass, config, add_devices, discovery_info=None): | |
| class AlarmDecoderBinarySensor(BinarySensorDevice): | ||
| """Representation of an AlarmDecoder binary sensor.""" | ||
|
|
||
| def __init__(self, zone_number, zone_name, zone_type, zone_rfid): | ||
| def __init__(self, zone_number, zone_name, zone_type, zone_rfid, relay_addr, relay_chan): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (93 > 79 characters) |
||
| """Initialize the binary_sensor.""" | ||
| self._zone_number = zone_number | ||
| self._zone_type = zone_type | ||
| self._state = None | ||
| self._name = zone_name | ||
| self._rfid = zone_rfid | ||
| self._rfstate = None | ||
| self._relay_addr = relay_addr | ||
| self._relay_chan = relay_chan | ||
|
|
||
| @asyncio.coroutine | ||
| def async_added_to_hass(self): | ||
|
|
@@ -70,6 +75,9 @@ def async_added_to_hass(self): | |
| self.hass.helpers.dispatcher.async_dispatcher_connect( | ||
| SIGNAL_RFX_MESSAGE, self._rfx_message_callback) | ||
|
|
||
| self.hass.helpers.dispatcher.async_dispatcher_connect( | ||
| SIGNAL_REL_MESSAGE, self._rel_message_callback) | ||
|
|
||
| @property | ||
| def name(self): | ||
| """Return the name of the entity.""" | ||
|
|
@@ -122,3 +130,9 @@ def _rfx_message_callback(self, message): | |
| if self._rfid and message and message.serial_number == self._rfid: | ||
| self._rfstate = message.value | ||
| self.schedule_update_ha_state() | ||
|
|
||
| def _rel_message_callback(self, message): | ||
| """Update Relay state.""" | ||
| if self._relay_addr == message.address and self._relay_chan == message.channel: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (87 > 79 characters) |
||
| self._state = message.value | ||
| self.schedule_update_ha_state() | ||
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.
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.
Is this required for the relay address to be effective? If so, mark both items with
vol.Inclusive.