Add product_name attribute to zwave nodes. (#7071)
This commit is contained in:
parent
d63028e44a
commit
5e18c997f7
2 changed files with 11 additions and 2 deletions
|
@ -15,6 +15,7 @@ ATTR_QUERY_STAGE = 'query_stage'
|
|||
ATTR_AWAKE = 'is_awake'
|
||||
ATTR_READY = 'is_ready'
|
||||
ATTR_FAILED = 'is_failed'
|
||||
ATTR_PRODUCT_NAME = 'product_name'
|
||||
|
||||
STAGE_COMPLETE = 'Complete'
|
||||
|
||||
|
@ -79,6 +80,8 @@ class ZWaveNodeEntity(ZWaveBaseEntity):
|
|||
self.node = node
|
||||
self.node_id = self.node.node_id
|
||||
self._name = node_name(self.node)
|
||||
self._product_name = '{} {}'.format(
|
||||
node.manufacturer_name, node.product_name)
|
||||
self.entity_id = "{}.{}_{}".format(
|
||||
DOMAIN, slugify(self._name), self.node_id)
|
||||
self._attributes = {}
|
||||
|
@ -160,6 +163,7 @@ class ZWaveNodeEntity(ZWaveBaseEntity):
|
|||
"""Return the device specific state attributes."""
|
||||
attrs = {
|
||||
ATTR_NODE_ID: self.node_id,
|
||||
ATTR_PRODUCT_NAME: self._product_name,
|
||||
}
|
||||
attrs.update(self._attributes)
|
||||
if self.battery_level is not None:
|
||||
|
|
|
@ -41,6 +41,8 @@ class TestZWaveNodeEntity(unittest.TestCase):
|
|||
query_stage='Dynamic', is_awake=True, is_ready=False,
|
||||
is_failed=False, is_info_received=True, max_baud_rate=40000,
|
||||
is_zwave_plus=False, capabilities=[], neighbors=[], location=None)
|
||||
self.node.manufacturer_name = 'Test Manufacturer'
|
||||
self.node.product_name = 'Test Product'
|
||||
self.entity = node_entity.ZWaveNodeEntity(self.node,
|
||||
self.zwave_network)
|
||||
|
||||
|
@ -79,8 +81,10 @@ class TestZWaveNodeEntity(unittest.TestCase):
|
|||
def test_node_changed(self):
|
||||
"""Test node_changed function."""
|
||||
self.maxDiff = None
|
||||
self.assertEqual({'node_id': self.node.node_id},
|
||||
self.entity.device_state_attributes)
|
||||
self.assertEqual(
|
||||
{'node_id': self.node.node_id,
|
||||
'product_name': 'Test Manufacturer Test Product'},
|
||||
self.entity.device_state_attributes)
|
||||
|
||||
self.node.get_values.return_value = {
|
||||
1: mock_zwave.MockValue(data=1800)
|
||||
|
@ -135,6 +139,7 @@ class TestZWaveNodeEntity(unittest.TestCase):
|
|||
self.entity.node_changed()
|
||||
self.assertEqual(
|
||||
{'node_id': self.node.node_id,
|
||||
'product_name': 'Test Manufacturer Test Product',
|
||||
'query_stage': 'Dynamic',
|
||||
'is_awake': True,
|
||||
'is_ready': False,
|
||||
|
|
Loading…
Add table
Reference in a new issue