forked from platypush/platypush
Removed OZW type references altogether to prevent import errors
This commit is contained in:
parent
68c44c0c3c
commit
2224681e3c
1 changed files with 8 additions and 14 deletions
|
@ -19,11 +19,6 @@ class ZwavePlugin(ZwaveBasePlugin, SwitchPlugin):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from openzwave.group import ZWaveGroup
|
|
||||||
from openzwave.node import ZWaveNode
|
|
||||||
from openzwave.scene import ZWaveScene
|
|
||||||
from openzwave.value import ZWaveValue
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_backend() -> ZwaveBackend:
|
def _get_backend() -> ZwaveBackend:
|
||||||
backend = get_backend('zwave')
|
backend = get_backend('zwave')
|
||||||
|
@ -152,7 +147,7 @@ class ZwavePlugin(ZwaveBasePlugin, SwitchPlugin):
|
||||||
controller.request_node_neighbor_update(node.node_id)
|
controller.request_node_neighbor_update(node.node_id)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def value_to_dict(value: Optional[ZWaveValue]) -> Dict[str, Any]:
|
def value_to_dict(value) -> Dict[str, Any]:
|
||||||
if not value:
|
if not value:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@ -189,7 +184,7 @@ class ZwavePlugin(ZwaveBasePlugin, SwitchPlugin):
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def group_to_dict(group: Optional[ZWaveGroup]) -> Dict[str, Any]:
|
def group_to_dict(group) -> Dict[str, Any]:
|
||||||
if not group:
|
if not group:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@ -201,7 +196,7 @@ class ZwavePlugin(ZwaveBasePlugin, SwitchPlugin):
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def node_to_dict(cls, node: Optional[ZWaveNode]) -> Dict[str, Any]:
|
def node_to_dict(cls, node) -> Dict[str, Any]:
|
||||||
if not node:
|
if not node:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
@ -259,7 +254,7 @@ class ZwavePlugin(ZwaveBasePlugin, SwitchPlugin):
|
||||||
} if hasattr(node, 'values') else {},
|
} if hasattr(node, 'values') else {},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_node(self, node_id: Optional[int] = None, node_name: Optional[str] = None) -> ZWaveNode:
|
def _get_node(self, node_id: Optional[int] = None, node_name: Optional[str] = None):
|
||||||
assert node_id is not None or node_name is not None, 'Specify either node_id or name'
|
assert node_id is not None or node_name is not None, 'Specify either node_id or name'
|
||||||
nodes = self._get_backend().network.nodes
|
nodes = self._get_backend().network.nodes
|
||||||
|
|
||||||
|
@ -271,14 +266,14 @@ class ZwavePlugin(ZwaveBasePlugin, SwitchPlugin):
|
||||||
assert nodes, 'No such node name: {}'.format(node_name)
|
assert nodes, 'No such node name: {}'.format(node_name)
|
||||||
return nodes[0]
|
return nodes[0]
|
||||||
|
|
||||||
def _get_groups(self) -> Dict[int, ZWaveGroup]:
|
def _get_groups(self) -> dict:
|
||||||
return {
|
return {
|
||||||
group_index: group
|
group_index: group
|
||||||
for node in self._get_backend().network.nodes.values()
|
for node in self._get_backend().network.nodes.values()
|
||||||
for group_index, group in node.groups.items()
|
for group_index, group in node.groups.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_group(self, group_index: Optional[int] = None, group_label: Optional[str] = None) -> ZWaveGroup:
|
def _get_group(self, group_index: Optional[int] = None, group_label: Optional[str] = None):
|
||||||
assert group_index is not None or group_label is not None, 'Specify either group_index or label'
|
assert group_index is not None or group_label is not None, 'Specify either group_index or label'
|
||||||
groups = self._get_groups()
|
groups = self._get_groups()
|
||||||
|
|
||||||
|
@ -290,7 +285,7 @@ class ZwavePlugin(ZwaveBasePlugin, SwitchPlugin):
|
||||||
assert groups, 'No such group label: {}'.format(group_label)
|
assert groups, 'No such group label: {}'.format(group_label)
|
||||||
return groups[0]
|
return groups[0]
|
||||||
|
|
||||||
def _get_scene(self, scene_id: Optional[int] = None, scene_label: Optional[str] = None) -> ZWaveScene:
|
def _get_scene(self, scene_id: Optional[int] = None, scene_label: Optional[str] = None):
|
||||||
assert scene_id is not None or scene_label is not None, 'Specify either scene_id or label'
|
assert scene_id is not None or scene_label is not None, 'Specify either scene_id or label'
|
||||||
scenes = self._get_backend().network.get_scenes()
|
scenes = self._get_backend().network.get_scenes()
|
||||||
|
|
||||||
|
@ -456,8 +451,7 @@ class ZwavePlugin(ZwaveBasePlugin, SwitchPlugin):
|
||||||
self._get_network().test(count)
|
self._get_network().test(count)
|
||||||
|
|
||||||
def _get_value(self, value_id: Optional[int] = None, id_on_network: Optional[str] = None,
|
def _get_value(self, value_id: Optional[int] = None, id_on_network: Optional[str] = None,
|
||||||
node_id: Optional[int] = None, node_name: Optional[str] = None, value_label: Optional[str] = None) \
|
node_id: Optional[int] = None, node_name: Optional[str] = None, value_label: Optional[str] = None):
|
||||||
-> ZWaveValue:
|
|
||||||
assert (value_id is not None or id_on_network is not None) or \
|
assert (value_id is not None or id_on_network is not None) or \
|
||||||
((node_id is not None or node_name is not None) and value_label is not None), \
|
((node_id is not None or node_name is not None) and value_label is not None), \
|
||||||
'Specify either value_id, id_on_network, or [node_id/node_name, value_label]'
|
'Specify either value_id, id_on_network, or [node_id/node_name, value_label]'
|
||||||
|
|
Loading…
Reference in a new issue