mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Simplify zwave_js code (#87235)
This commit is contained in:
parent
2f3b509513
commit
e3b820d9db
@ -254,17 +254,15 @@ class DriverEvents:
|
||||
self.dev_reg.async_remove_device(device.id)
|
||||
|
||||
# run discovery on controller node
|
||||
c_node_id = controller.own_node_id
|
||||
controller_node = controller.nodes.get(c_node_id) if c_node_id else None
|
||||
if controller_node:
|
||||
await self.controller_events.async_on_node_added(controller_node)
|
||||
if controller.own_node:
|
||||
await self.controller_events.async_on_node_added(controller.own_node)
|
||||
|
||||
# run discovery on all other ready nodes
|
||||
await asyncio.gather(
|
||||
*(
|
||||
self.controller_events.async_on_node_added(node)
|
||||
for node in controller.nodes.values()
|
||||
if controller_node is None or node != controller_node
|
||||
if node != controller.own_node
|
||||
)
|
||||
)
|
||||
|
||||
@ -396,13 +394,8 @@ class ControllerEvents:
|
||||
via_device_id = None
|
||||
controller = driver.controller
|
||||
# Get the controller node device ID if this node is not the controller
|
||||
if (
|
||||
controller.own_node_id is not None
|
||||
and controller.own_node_id != node.node_id
|
||||
):
|
||||
via_device_id = get_device_id(
|
||||
driver, controller.nodes[controller.own_node_id]
|
||||
)
|
||||
if controller.own_node and controller.own_node != node:
|
||||
via_device_id = get_device_id(driver, controller.own_node)
|
||||
|
||||
# Replace the device if it can be determined that this node is not the
|
||||
# same product as it was previously.
|
||||
|
@ -150,7 +150,7 @@ async def async_get_actions(
|
||||
|
||||
node = async_get_node_from_device_id(hass, device_id)
|
||||
|
||||
if node.client.driver and node.client.driver.controller.own_node_id == node.node_id:
|
||||
if node.client.driver and node.client.driver.controller.own_node == node:
|
||||
return actions
|
||||
|
||||
base_action = {
|
||||
|
@ -134,7 +134,7 @@ async def async_get_conditions(
|
||||
}
|
||||
node = async_get_node_from_device_id(hass, device_id)
|
||||
|
||||
if node.client.driver and node.client.driver.controller.own_node_id == node.node_id:
|
||||
if node.client.driver and node.client.driver.controller.own_node == node:
|
||||
return conditions
|
||||
|
||||
# Any value's value condition
|
||||
|
@ -258,7 +258,7 @@ async def async_get_triggers(
|
||||
dev_reg = device_registry.async_get(hass)
|
||||
node = async_get_node_from_device_id(hass, device_id, dev_reg)
|
||||
|
||||
if node.client.driver and node.client.driver.controller.own_node_id == node.node_id:
|
||||
if node.client.driver and node.client.driver.controller.own_node == node:
|
||||
return triggers
|
||||
|
||||
# We can add a node status trigger if the node status sensor is enabled
|
||||
|
Loading…
x
Reference in New Issue
Block a user