mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Add product_name attribute to zwave nodes. (#7071)
This commit is contained in:
parent
d63028e44a
commit
5e18c997f7
@ -15,6 +15,7 @@ ATTR_QUERY_STAGE = 'query_stage'
|
|||||||
ATTR_AWAKE = 'is_awake'
|
ATTR_AWAKE = 'is_awake'
|
||||||
ATTR_READY = 'is_ready'
|
ATTR_READY = 'is_ready'
|
||||||
ATTR_FAILED = 'is_failed'
|
ATTR_FAILED = 'is_failed'
|
||||||
|
ATTR_PRODUCT_NAME = 'product_name'
|
||||||
|
|
||||||
STAGE_COMPLETE = 'Complete'
|
STAGE_COMPLETE = 'Complete'
|
||||||
|
|
||||||
@ -79,6 +80,8 @@ class ZWaveNodeEntity(ZWaveBaseEntity):
|
|||||||
self.node = node
|
self.node = node
|
||||||
self.node_id = self.node.node_id
|
self.node_id = self.node.node_id
|
||||||
self._name = node_name(self.node)
|
self._name = node_name(self.node)
|
||||||
|
self._product_name = '{} {}'.format(
|
||||||
|
node.manufacturer_name, node.product_name)
|
||||||
self.entity_id = "{}.{}_{}".format(
|
self.entity_id = "{}.{}_{}".format(
|
||||||
DOMAIN, slugify(self._name), self.node_id)
|
DOMAIN, slugify(self._name), self.node_id)
|
||||||
self._attributes = {}
|
self._attributes = {}
|
||||||
@ -160,6 +163,7 @@ class ZWaveNodeEntity(ZWaveBaseEntity):
|
|||||||
"""Return the device specific state attributes."""
|
"""Return the device specific state attributes."""
|
||||||
attrs = {
|
attrs = {
|
||||||
ATTR_NODE_ID: self.node_id,
|
ATTR_NODE_ID: self.node_id,
|
||||||
|
ATTR_PRODUCT_NAME: self._product_name,
|
||||||
}
|
}
|
||||||
attrs.update(self._attributes)
|
attrs.update(self._attributes)
|
||||||
if self.battery_level is not None:
|
if self.battery_level is not None:
|
||||||
|
@ -41,6 +41,8 @@ class TestZWaveNodeEntity(unittest.TestCase):
|
|||||||
query_stage='Dynamic', is_awake=True, is_ready=False,
|
query_stage='Dynamic', is_awake=True, is_ready=False,
|
||||||
is_failed=False, is_info_received=True, max_baud_rate=40000,
|
is_failed=False, is_info_received=True, max_baud_rate=40000,
|
||||||
is_zwave_plus=False, capabilities=[], neighbors=[], location=None)
|
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.entity = node_entity.ZWaveNodeEntity(self.node,
|
||||||
self.zwave_network)
|
self.zwave_network)
|
||||||
|
|
||||||
@ -79,7 +81,9 @@ class TestZWaveNodeEntity(unittest.TestCase):
|
|||||||
def test_node_changed(self):
|
def test_node_changed(self):
|
||||||
"""Test node_changed function."""
|
"""Test node_changed function."""
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
self.assertEqual({'node_id': self.node.node_id},
|
self.assertEqual(
|
||||||
|
{'node_id': self.node.node_id,
|
||||||
|
'product_name': 'Test Manufacturer Test Product'},
|
||||||
self.entity.device_state_attributes)
|
self.entity.device_state_attributes)
|
||||||
|
|
||||||
self.node.get_values.return_value = {
|
self.node.get_values.return_value = {
|
||||||
@ -135,6 +139,7 @@ class TestZWaveNodeEntity(unittest.TestCase):
|
|||||||
self.entity.node_changed()
|
self.entity.node_changed()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
{'node_id': self.node.node_id,
|
{'node_id': self.node.node_id,
|
||||||
|
'product_name': 'Test Manufacturer Test Product',
|
||||||
'query_stage': 'Dynamic',
|
'query_stage': 'Dynamic',
|
||||||
'is_awake': True,
|
'is_awake': True,
|
||||||
'is_ready': False,
|
'is_ready': False,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user