zwave.mqtt.status renamed to controller_status, while status should return the current state of the values

This commit is contained in:
Fabio Manganiello 2022-04-12 23:44:14 +02:00
parent b35c761a43
commit 332c91252c
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 20 additions and 11 deletions

View file

@ -356,7 +356,7 @@ export default {
async refreshStatus() { async refreshStatus() {
this.loading.status = true this.loading.status = true
try { try {
this.status = await this.zrequest('status') this.status = await this.zrequest('controller_status')
} finally { } finally {
this.loading.status = false this.loading.status = false
} }

View file

@ -496,7 +496,7 @@ class ZwaveMqttPlugin(MqttPlugin, ZwaveBasePlugin):
def _filter_values( def _filter_values(
self, self,
command_classes: Iterable[str], command_classes: Optional[Iterable[str]] = None,
filter_callback: Optional[Callable[[dict], bool]] = None, filter_callback: Optional[Callable[[dict], bool]] = None,
node_id: Optional[int] = None, node_id: Optional[int] = None,
node_name: Optional[str] = None, node_name: Optional[str] = None,
@ -509,16 +509,18 @@ class ZwaveMqttPlugin(MqttPlugin, ZwaveBasePlugin):
) )
command_classes = { command_classes = {
command_class_by_name[command_name] for command_name in command_classes command_class_by_name[command_name]
for command_name in (command_classes or [])
} }
values = {} values = {}
for node in nodes: for node in nodes:
for value in node.get('values', {}).values(): for value in node.get('values', {}).values():
if value.get('command_class') not in command_classes or ( if (
filter_callback and not filter_callback(value) command_classes
): and value.get('command_class') not in command_classes
) or (filter_callback and not filter_callback(value)):
continue continue
value_id = value['id_on_network'] value_id = value['id_on_network']
@ -570,15 +572,24 @@ class ZwaveMqttPlugin(MqttPlugin, ZwaveBasePlugin):
@action @action
def status(self, **kwargs) -> Dict[str, Any]: def status(self, **kwargs) -> Dict[str, Any]:
"""
Get the current status of the Z-Wave values.
:param kwargs: Extra arguments to be passed to :meth:`platypush.plugins.mqtt.MqttPlugin.publish``
(default: query the default configured device).
"""
return self._filter_values(**kwargs)
@action
def controller_status(self, **kwargs) -> Dict[str, Any]:
""" """
Get the status of the controller. Get the status of the controller.
:param kwargs: Extra arguments to be passed to :meth:`platypush.plugins.mqtt.MqttPlugin.publish`` :param kwargs: Extra arguments to be passed to :meth:`platypush.plugins.mqtt.MqttPlugin.publish``
(default: query the default configured device). (default: query the default configured device).
:return: dict with the following fields: ``device`` and ``state``.
""" """
msg_queue = queue.Queue() msg_queue = queue.Queue()
topic = f'{self.topic_prefix}/Controller/status' topic = f'{self.topic_prefix}/driver/status'
client = self._get_client(**kwargs) client = self._get_client(**kwargs)
def on_message(_, __, msg): def on_message(_, __, msg):
@ -606,9 +617,7 @@ class ZwaveMqttPlugin(MqttPlugin, ZwaveBasePlugin):
client.loop_stop() client.loop_stop()
return { return {
'device': status['nodeId'], 'state': status,
'state': status['status'],
'stats': {},
} }
@action @action