Repository: cgarwood/python-openzwave-mqtt

Issue:
Rename option `sent_message` to `send_message`
It is a typo 🤦‍♂ 

Discussion:

Patch:
diff --git a/openzwavemqtt/models/command_class.py b/openzwavemqtt/models/command_class.py
index 0b702fd..fac4637 100644
--- a/openzwavemqtt/models/command_class.py
+++ b/openzwavemqtt/models/command_class.py
@@ -15,6 +15,8 @@ class OZWCommandClass(OZWNodeChildBase):
     EVENT_CHANGED = EVENT_COMMAND_CLASS_CHANGED
     EVENT_REMOVED = EVENT_COMMAND_CLASS_REMOVED
 
+    PLURAL_NAME = "commandclasses"
+
     @property
     def instance(self) -> int:
         """Return Instance."""
diff --git a/openzwavemqtt/models/instance.py b/openzwavemqtt/models/instance.py
index e404484..a6c7a35 100644
--- a/openzwavemqtt/models/instance.py
+++ b/openzwavemqtt/models/instance.py
@@ -49,14 +49,13 @@ class OZWInstance(ZWaveBase):
             "statistics": OZWInstanceStatistics,
         }
 
-    def send_message(self, topic, payload=""):
-        instance_id = self.id
+    def send_command(self, command: str, payload: str = ""):
         topic_prefix = self.options.topic_prefix
-        full_topic = f"{topic_prefix}{instance_id}/command/{topic}/"
-        self.options.sent_message(full_topic, payload)
+        full_topic = f"{topic_prefix}{self.id}/command/{command}/"
+        self.options.send_command(full_topic, payload)
 
     def add_node(self, secure=False):
-        self.send_message("addnode", {"secure": secure})
+        self.send_command("addnode", {"secure": secure})
 
     def cancel_controller_command(self):
-        self.send_message("cancelcontrollercommand")
+        self.send_command("cancelcontrollercommand")
diff --git a/openzwavemqtt/models/node.py b/openzwavemqtt/models/node.py
index 2831349..3ade28b 100644
--- a/openzwavemqtt/models/node.py
+++ b/openzwavemqtt/models/node.py
@@ -199,6 +199,17 @@ class OZWNode(ZWaveBase):
         """Return Neighbors."""
         return self.data.get("Neighbors")
 
+    @property
+    def values(self):
+        """Return list of OZWValue child items."""
+        _values = []
+        for instance in self.collections["instance"]:
+            for cc in instance.collections["commandclass"]:
+                for value in cc.collections["value"]:
+                    _values.append(value)
+
+        return _values
+
     def create_collections(self):
         """Create collections that Node supports."""
         return {
diff --git a/openzwavemqtt/options.py b/openzwavemqtt/options.py
index f8e8e03..041d147 100644
--- a/openzwavemqtt/options.py
+++ b/openzwavemqtt/options.py
@@ -5,10 +5,10 @@ from typing import Callable
 class OZWOptions:
     def __init__(
         self,
-        sent_message: Callable[[str, dict], None],
+        send_message: Callable[[str, dict], None],
         topic_prefix: str = "OpenZWave/",
     ):
-        self.sent_message = sent_message
+        self.send_message = send_message
         self.topic_prefix = topic_prefix
         self.listeners = {}
 


Test patch:
diff --git a/test/models/test_value.py b/test/models/test_value.py
index 478074e..e6e53d9 100644
--- a/test/models/test_value.py
+++ b/test/models/test_value.py
@@ -23,6 +23,9 @@ def test_value_events(mgr):
     assert events[0].value == "yo"
     assert events[0].parent.id == "4"
 
+    # Test OZWNode.values shortcut
+    assert mgr.get_instance("1").get_node("2").values[0].id == "3"
+
     # Listen for value changed
     mgr.options.listen(EVENT_VALUE_CHANGED, events.append)
     mgr.mock_receive_json(
@@ -34,10 +37,7 @@ def test_value_events(mgr):
 
     # Show how to use collection helpers
     assert (
-        mgr.get_instance("1")
-        .get_node("2")
-        .get_instance("1")
-        .get_commandclass("4")
+        list(mgr.get_instance("1").get_node("2").get_instance("1").commandclasses())[0]
         .get_value("3")
         .value
         == "yo2"