Skip to content

Commit

Permalink
Merge branch 'folder_property' into PyISY_beta
Browse files Browse the repository at this point in the history
  • Loading branch information
shbatm committed Feb 22, 2021
2 parents 77b44c3 + 7280461 commit 1273d06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pyisy/nodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,17 @@ def get_by_index(self, i):
self.ntypes,
)

def get_folder(self, address):
"""Return the folder of a given node address."""
parent = self.nparents[self.addresses.index(address)]
if parent is None:
# Node is in the root folder.
return None
parent_index = self.addresses.index(parent)
if self.ntypes[parent_index] != TAG_FOLDER:
return self.get_folder(parent)
return self.nnames[parent_index]

@property
def children(self):
"""Return the children of the class."""
Expand Down
5 changes: 5 additions & 0 deletions pyisy/nodes/nodebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ def family(self):
"""Return the ISY Family category."""
return self._family

@property
def folder(self):
"""Return the folder of the current node as a property."""
return self._nodes.get_folder(self.address)

@property
def is_load(self):
"""Return the isLoad property of the node from it's notes."""
Expand Down

0 comments on commit 1273d06

Please sign in to comment.