Skip to content
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

Calculate Expander Zone Numbers Correctly for SE Panels #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions alarmdecoder/zonetracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def update(self, message):
zone = -1

if message.type == ExpanderMessage.ZONE:
zone = self.expander_to_zone(message.address, message.channel, self.alarmdecoder_object.mode)
zone = self.expander_to_zone(message.address, message.channel, self.alarmdecoder_object.mode, self.alarmdecoder_object.address)

if zone != -1:
status = Zone.CLEAR
Expand Down Expand Up @@ -213,14 +213,17 @@ def update(self, message):

self._clear_expired_zones()

def expander_to_zone(self, address, channel, panel_type=ADEMCO):
def expander_to_zone(self, address, channel, panel_type=ADEMCO,
dev_addr=0):
"""
Convert an address and channel into a zone number.

:param address: expander address
:type address: int
:param channel: channel
:type channel: int
:param dev_addr: device address
:type address: int

:returns: zone number associated with an address and channel
"""
Expand All @@ -230,9 +233,15 @@ def expander_to_zone(self, address, channel, panel_type=ADEMCO):
if panel_type == ADEMCO:
# TODO: This is going to need to be reworked to support the larger
# panels without fixed addressing on the expanders.

idx = address - 7 # Expanders start at address 7.
zone = address + channel + (idx * 7) + 1
if dev_addr != 31:
idx = address - 7 # Expanders start at address 7.
zone = address + channel + (idx * 7) + 1
else:
# SE panels use address 31, this is probably not the most
# fool-proof test, but it works reasonably well.
# SE panel address is 1 for the first expander 2 for the next
# and the first zone address for an expander zone is 9
zone = (address * 8) + channel + 1

elif panel_type == DSC:
zone = (address * 8) + channel
Expand Down