Skip to content

Commit

Permalink
Merge branch 'node_renaming' into PyISY_beta
Browse files Browse the repository at this point in the history
shbatm committed Feb 19, 2021
2 parents 998702e + f18f375 commit 77b44c3
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@

- Module can now be used/tested from the command-line with the new `__main__.py` script; you can test a connection with `python3 -m pyisy http://your-isy-url:80 username password`.
- A new helper function has been added to create an `aiohttp.ClientSession` compliant with the ISY: `Connection.get_new_client_session(use_https, tls_ver=1.1)` will return a web session that can be passed to the init functions of `ISY` and `Connection` classes.
- Allow renaming of nodes and groups for ISY v5.2.0 or later using the `node.rename()` method.
- Add support for setting and retrieving Z-Wave Device Parameters using `node.set_zwave_parameter()` and `node.get_zwave_parameter()`.

### [v2.1.0] - Property Updates, Timestamps, Status Handling, and more...
1 change: 1 addition & 0 deletions pyisy/constants.py
Original file line number Diff line number Diff line change
@@ -173,6 +173,7 @@
METHOD_GET = "get"
METHOD_SET = "set"

URL_CHANGE = "change"
URL_CLOCK = "time"
URL_CONFIG = "config"
URL_DEFINITIONS = "definitions"
23 changes: 23 additions & 0 deletions pyisy/nodes/nodebase.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,9 @@
TAG_DESCRIPTION,
TAG_IS_LOAD,
TAG_LOCATION,
TAG_NAME,
TAG_SPOKEN,
URL_CHANGE,
URL_NODES,
URL_NOTES,
XML_TRUE,
@@ -327,3 +329,24 @@ async def turn_on(self, val=None):
cmd = CMD_OFF
val = None
return await self.send_cmd(cmd, val)

async def rename(self, new_name):
"""
Rename the node or group in the ISY.
Note: Feature was added in ISY v5.2.0, this will fail on earlier versions.
"""

# /rest/nodes/<nodeAddress>/change?name=<newName>
req_url = self.isy.conn.compile_url(
[URL_NODES, self._id, URL_CHANGE], query={TAG_NAME: new_name},
)
if not await self.isy.conn.request(req_url):
_LOGGER.warning(
"ISY could not update name for %s.", self._id,
)
return False
_LOGGER.debug("ISY renamed %s to %s.", self._id, new_name)

self._name = new_name
return True

0 comments on commit 77b44c3

Please sign in to comment.