-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating block by device Name rather than device idx #1155
Comments
But this code generates error when inserted in dashticz/custom/CONFIG.js.
|
This code is able to generate Device Table by name : This code works fine in dashticz/custom/custom.js ==> How can I make it accepted or generate equivalent in dashticz/custom/CONFIG.js ? |
The Domoticz object can only be accessed from custom.js It doesn't exist yet when CONFIG.js is executed.
It's a dictionary (object) containing all elements (devices, groups, config) obtained from Domoticz. |
Using names for device selection was not implemented, because device names may not be unique. A work around could be to use the following in CONFIG.js:
The Dashticz url can contain query parameters which end up in the _PARAMS object. This object can be read from CONFIG.js. |
Thanks for answer. How can I, at least, dynamically get a table like DeviceTable[idx] = device.Name available in CONFIG.js ? I could solve my needs starting from that table and my own js code in CONFIG.js |
In CONFIG.js it will be difficult, since at that moment the Domoticz connection is not active yet, so no device information is available. Is it a read-only device? Then you could use the deviceHook function in custom.js I will check how much effort it is to use device names instead of device idx. |
Device related are :
With an unpredictable number of occurrences of these 3 blocks |
ok, try latest beta. You should be able to use device names instead of device idx.
Please report any strange behavior you encounter, because I only did some minimal regression testing yet. |
Fantastic, it works for block ! |
Can you post the block definition your graph? |
Can you test latest beta? |
Now it also works for graph blocks : But this one is failing: blocks['graph_ActivityMonitor-LifeEvent'] = { |
I intend to use the following prototype of code in CONFIG.js to dynamically build blocks But I miss a function giving the device idx from device name if this domoticz device exist Then we could use : var EnergyLineSwitchLine = []; BlockList = [] columns['C1-Energy-Lines'] = { |
In latest beta you now can use Domoticz.getAllDevices('Device name') to get a device with a specific name. I think you can use a dummy block and set the blocks parameter from custom.js. I'll try ... |
Domoticz.getAllDevices('Device name') usable in custom.js is clearly a plus and will help. But blocks are generated in CONFIG.js and not in custom.js which is mainly used for cosmetic and effects only So the solution is simple to express, but perhaps morecomplicated to implement : ==>Make Domoticz.getAllDevices('Device name') returning idx usable in CONFIG.js and users like me will do the rest ! |
No, not really. Alternative:
Then in custom.js, if the device exists:
|
or, maybe cleaner/easier: add a beforeFirstRender() hook, in which you still can modify the blocks object. |
Clearly this last solution would be efficient :
Feasible ? |
ok. See: |
Thanks lokonli for this superb demonstration of reactivity and light speed implementation ! Let me have a try with my own needs and I will get back to you for feed back. |
How can we fix this last problem with custom graph with device name ? The graph below is failing when I replace 'd.l_46' by 'd.l_ActivityMonitor-LifeEvent' in custom data as below. I get error during Dashticz interface generation because d.l_46 is probably still automatically generated Solution fix suggestion for your code : The Dashticz user will just have to know that d.l_ from d.l_1 to d.l_n Feasible ? My test is here : blocks['graph_ActivityMonitor-LifeEvent'] = { |
I'm working on quite a big update of the graph module, including upgrade to latest chart.js version. I've made some changes already: for single device graphs the '_' part is removed. |
Keep me informed, I will be happy to test this new d.l_1 to d.l_n mode. |
I just successfully used new beforeFirstRenderHook() function to implement :
So the test is clearly passed OK. Thanks again for you reactivity ! |
I just successfully used new beforeFirstRenderHook() function to implement : I confirm everything works fine. Can you please advice me when you will have replace device idx by dataset indice in custom graph (d.dataset_1 to d.dataset_n) |
For a test version of the new graph module, see: |
I would need to be able to create block from domoticz device Name rather than from domoticz device idx
I noticed existence of Domoticz.getAllDevices() function but calling this function with:
var mydevices = Domoticz.getAllDevices()
in dashticz/custom/CONFIG.js
is apparently not recognized
and I do not known if Domoticz.getAllDevices()[DeviceName] is allowed for this function.
==> How can I manage to get a variable containing equivalent of domoticz.devices syntax in dashticz/custom/CONFIG.js
and parse it by name ?
The text was updated successfully, but these errors were encountered: