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: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 20 additions and 11 deletions

View file

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

View file

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