Replies: 1 comment
-
Can you give some a more descriptive usecase ? I am yet to understand the scenario. Also is it possible for you to share the code ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi vinodsr,
Great work!
I have over 20 Tuya devices. I imagine people with a large number of Tuya devices might (like me) want to have their monitoring dashboards set up to compare power consumption metrics for similar devices so instead of every node being manually added to the workflow, an iterative approach based on category might be more manageable.
How easy would it be for you to extend your excellent NPM to add a node that gets the complete device list based on successful connection of a single device, and then filters by category?
The API itself does allow this, once you've connected to a single device you can invoke getDevicesByUser. As a test, I modded tuya-cli locally to extend the values it outputs.
To cut a long story short, I can now run "tuya-cli batchinfo" in an exec node without the interactive prompting. It uses the following code:
const prettyDevices = devices.map(device => ({name: device.name, id: device.id, key: device.local_key, product_name:device.product_name, online: device.online, category: device.category})); if (options.stringify) { console.log(JSON.stringify(prettyDevices)); } else { console.log(prettyDevices); }
To get
{ name: 'Zigbee Gateway', id: '****', key: '****', product_name: 'Smart Gateway', online: true, category: 'wfcon' }, { name: 'Wi-fi smart socket (with power monitor)', id: '****', key: '****', product_name: 'io-WiFi-Plug-PM', online: true, category: 'cz' }, { name: 'Wi-fi smart socket (unmonitored)', id: '****', key: '****', product_name: 'Smart socket', online: true, category: 'cz' }, { name: 'Zigbee Light switch (single)', id: '****', key: '****', product_name: 'X711', online: true, category: 'kg' }, { name: 'Zigbee Light switch (Triple', id: '****', key: '****', product_name: 'X713', online: true, category: 'kg' },
This data can then be used by other nodes to display power consumption graphs for monitored plugs, on/off statuses for light switches and unmonitored plugs, and so on.
Is this functionality something that could be ported into a new node?
Cheers
Beta Was this translation helpful? Give feedback.
All reactions