Skip to content

Commit

Permalink
#14 Can now set ChimeMode on an Area
Browse files Browse the repository at this point in the history
  • Loading branch information
jimboca committed Aug 6, 2022
1 parent 41b62c7 commit 3836d4b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,16 +383,19 @@ https://github.com/UniversalDevicesInc-PG3/udi-poly-ELK/issues
- 3.4.1: 08/04/2022 - BETA
- More documentation cleanup, still needs more.
- Added driver's to many Nodes, still more to go
- When node is queried the values are passed to PG3 with force option so they always update ISY
- When node is queried the values are passed to PG3 with force option so they always update the ISY
- This helps set initial ISY driver values during query-all on ISY restart
- Updates to work with latest elkm1_lib
- [Allow user to control Chime Mode](https://github.com/UniversalDevicesInc-PG3/udi-poly-ELK/issues/14)
- Also allow setting desired Chime Mode on an area, which may require multiple chime button presses
- Note that an ISY reboot is required to get the proper values to show up for chime mode in notifications and UD Mobile
- [ELM M1G System Trouble Status](https://github.com/UniversalDevicesInc-PG3/udi-poly-ELK/issues/78)
- See [ELK Controller](#ElkController) System Trouble Status
- [Add Remote Programming Status](https://github.com/UniversalDevicesInc-PG3/udi-poly-ELK/issues/80)
- See [ELK Controller](#ElkController) Remote Programming Status
- [Allow Elk NS to Recognize Keypad Presses](https://github.com/UniversalDevicesInc-PG3/udi-poly-ELK/issues)
- [Add ERROR driver to controller](https://github.com/UniversalDevicesInc-PG3/udi-poly-ELK/issues/62)
- Attempt to trap all errors and show status on ISY and in PG3 UI
- See [ELK Controller](#ELKController) Node server errors
- 3.3.8: 07/25/2022
- Fixed to work with udi-interface 3.0.47
Expand Down
37 changes: 32 additions & 5 deletions nodes/Area.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def __init__(self, controller, address, elk):
self.zones_violated = 0
self.zones_logical_status = [None] * Max.ZONES.value
self.zones_physical_status = [None] * Max.ZONES.value
self._zone_nodes = {}
self._keypad_nodes = {}
self._zone_nodes = list()
self._keypad_nodes = list()
self.poll_voltages = False
self.requested_chime_mode = None
self.ready = False
name = get_valid_node_name(self.elk.name)
if name == "":
Expand All @@ -55,14 +56,14 @@ def start(self):
address = f'zone_{zn+1}'
node = self.controller.add_node(address, ZoneNode(self.controller, self, address, self.controller.elk.zones[zn]))
if node is not None:
self._zone_nodes[zn] = node
self._zone_nodes.append(node)
for n in range(Max.KEYPADS.value):
if self.controller.elk.keypads[n].area == self.elk.index:
LOGGER.info(f"{self.lpfx} area {self.elk.index} {self.elk.name} node={self.name} adding keypad node {n} '{self.controller.elk.keypads[n]}'")
address = f'keypad_{n+1}'
node = self.controller.add_node(address,KeypadNode(self.controller, self, address, self.controller.elk.keypads[n]))
if node is not None:
self._keypad_nodes[n] = node
self._keypad_nodes.append(node)
else:
LOGGER.debug(f"{self.lpfx} area {self.elk.index} {self.elk.name} node={self.name} skipping keypad node {n} '{self.controller.elk.keypads[n]}'")
except Exception as ex:
Expand All @@ -77,7 +78,7 @@ def shortPoll(self):
return False
if self.poll_voltages:
for zn in self._zone_nodes:
self._zone_nodes[zn].shortPoll(poll_voltage=self.poll_voltages)
zn.shortPoll(poll_voltage=self.poll_voltages)

def longPoll(self):
pass
Expand Down Expand Up @@ -200,6 +201,16 @@ def set_arm_up_state(self,val=None,force=False):
def set_chime_mode(self,val=None,force=False):
LOGGER.warning(f'{self.lpfx} {val} elk.chime_mode={self.elk.chime_mode}')
self.set_driver('GV2', val, restore=False,default=self.elk.chime_mode[1],force=force)
if (self.requested_chime_mode is not None):
if (int(self.get_driver('GV2')) == int(self.requested_chime_mode)):
self.requested_chime_mode = None
else:
# Press the button again, but give it a sec
time.sleep(1)
self._keypad_nodes[0].press_key_chime()

def get_chime_mode(self):
return self.get_driver('GV2')

def set_poll_voltages(self,val=None, force=False):
LOGGER.info(f'{self.lpfx} {val}')
Expand Down Expand Up @@ -312,6 +323,21 @@ def cmd_clear_message(self,command):
LOGGER.error(f'{self.lpfx}',exc_info=True)
self.inc_error(f"{self.lpfx} {ex}")

def cmd_set_chime_mode(self,command):
LOGGER.debug(f'command={command}')
# command={'address': 'area_1', 'cmd': 'SET_CHIME_MODE', 'value': '3', 'uom': '25', 'query': {}}
try:
val = command.get('value')
if (int(self.get_chime_mode()) == int(val)):
LOGGER.warning(f'{self.lpfx} Already in chime_mode {val}')
return
self.requested_chime_mode = val
# Just press the button, and callback will handle it from here.
self._keypad_nodes[0].press_key_chime()
except Exception as ex:
LOGGER.error(f'{self.lpfx}',exc_info=True)
self.inc_error(f"{self.lpfx} {ex}")

"Hints See: https://github.com/UniversalDevicesInc/hints"
hint = [1,2,3,4]
drivers = [
Expand All @@ -338,4 +364,5 @@ def cmd_clear_message(self,command):
'SET_ENTRY_EXIT_TRIGGER': cmd_set_entry_exit_trigger,
'CLEAR_MESSAGE': cmd_clear_message,
'GV11': cmd_display_message,
'SET_CHIME_MODE': cmd_set_chime_mode,
}
2 changes: 1 addition & 1 deletion nodes/BaseNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, controller, primary_address, address, name):
self.lpfx = f'{address}:{name}:'
super(BaseNode, self).__init__(controller.poly, primary_address, address, name)

def set_drivers(self):
def set_drivers(self,force=False):
LOGGER.debug(f'{self.lpfx} does not have set_drivers')

def query(self):
Expand Down
7 changes: 6 additions & 1 deletion nodes/Keypad.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,15 @@ def cmd_query(self,command):
LOGGER.debug(f'{self.lpfx}')
self.query()

def cmd_key_chime(self,command):
# For others to call
def press_key_chime(self):
LOGGER.debug(f'{self.lpfx}')
self.elk.press_chime_key()

def cmd_key_chime(self,command):
LOGGER.debug(f'{self.lpfx}')
self.press_chime_key()

"Hints See: https://github.com/UniversalDevicesInc/hints"
hint = [1,2,3,4]
id = 'keypad'
Expand Down
1 change: 1 addition & 0 deletions profile/nodedef/nodedefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
</sends>
<accepts>
<cmd id="QUERY" />
<cmd id="KEY_CHIME" />
</accepts>
</cmds>
</nodeDef>
Expand Down

0 comments on commit 3836d4b

Please sign in to comment.