ioBroker / ioBroker.admin

user interface for configuration and administration
https://iobroker.net
MIT License
273 stars 78 forks source link

[bug]: jsonConfig: jsonData - instanceObj is undefined #2824

Open Scrounger opened 1 week ago

Scrounger commented 1 week ago

No existing issues.

Describe the bug

i have a table with autocompleteSendTo and try to send the instance (number) to the adapter. But the instanceObj is undefined. I tried all that are documented here: https://github.com/ioBroker/ioBroker.docs/blob/master/docs/en/dev/adapterjsonconfig.md#js-functions

but only globalData and data working

To Reproduce

...

Expected behavior

should send the data

Screenshots & Logfiles

table item with autocompleteSendTo

"deviceBlackList": {
                    "newLine": true,
                    "type": "table",
                    "sm": 12,
                    "md": 6,
                    "disabled": "!data.devicesEnabled",
                    "confirm": {
                        "condition": "!_alive",
                        "title": "Attention!",
                        "text": "This selection is only possible with a running instance!",
                        "ok": "Got it!",
                        "cancel": "cancel",
                        "type": "warning"
                    },
                    "items": [
                        {
                            "type": "autocompleteSendTo",
                            "title": "Choose which device should be excluded",
                            "attr": "mac",
                            "filter": true,
                            "sort": true,
                            "jsonData": "${instanceObj}",
                            "command": "deviceList",
                            "width": "60%"
                        },
                        {
                            "type": "checkbox",
                            "title": "Ignor in notifications",
                            "attr": "blacklisted",
                            "width": "15%"
                        }
                    ]
                }

the message i retrieve:

[onMessage]: {"command":"deviceList","message":null,"from":"system.adapter.admin.0","callback":{"message":null,"id":225,"ack":false,"time":1732192474754},"_id":88445533}

Browser error log: Cannot parse json data: undefined

Adapter version

7.4.1

js-controller version

7.0.3

Node version

18.x

Operating system

Ubuntu 22.04 LTS

Additional context

No response

mcm1957 commented 1 week ago

According to the docu you referred to theres only _instance as a varible. I do not see instanceObj documented. Where did you read that instanceObject should be defined?

Scrounger commented 1 week ago

I tried all that are documented here: https://github.com/ioBroker/ioBroker.docs/blob/master/docs/en/dev/adapterjsonconfig.md#js-functions

but only globalData and data working

as i wrote, i tried all from the documentation.

with _instance i get the following:

table item with autocompleteSendTo

                "deviceBlackList": {
                    "newLine": true,
                    "type": "table",
                    "sm": 12,
                    "md": 6,
                    "disabled": "!data.devicesEnabled",
                    "confirm": {
                        "condition": "!_alive",
                        "title": "Attention!",
                        "text": "This selection is only possible with a running instance!",
                        "ok": "Got it!",
                        "cancel": "cancel",
                        "type": "warning"
                    },
                    "items": [
                        {
                            "type": "autocompleteSendTo",
                            "title": "Choose which device should be excluded",
                            "attr": "mac",
                            "filter": true,
                            "sort": true,
                            "jsonData": "${_instance}",
                            "command": "deviceList",
                            "width": "60%"
                        },
                        {
                            "type": "checkbox",
                            "title": "Ignor in notifications",
                            "attr": "blacklisted",
                            "width": "15%"
                        }
                    ]
                }

the message i retrieve:

[onMessage]: {"command":"deviceList","message":null,"from":"system.adapter.admin.0","callback":{"message":null,"id":243,"ack":false,"time":1732199814887},"_id":88445551}

Browser console error: image

instanceObj is defined in the code and in https://github.com/ioBroker/ioBroker.admin/issues/1323

Scrounger commented 4 days ago

Thanks for fixing this, but i tested it with v7.4.2 and it is still not working.

I tried both instanceObj and _instance. Get the follwing browser console error: image

and the messages for both looks like this:

[onMessage]: {"command":"deviceList","message":null,"from":"system.adapter.admin.0","callback":{"message":null,"id":491,"ack":false,"time":1732620141351},"_id":56710972}

[onMessage]: {"command":"deviceStateList","message":{"instanceID":"${_instance}","adapter":"${globalData}"},"from":"system.adapter.admin.0","callback":{"message":{"instanceID":"${_instance}","adapter":"${globalData}"},"id":492,"ack":false,"time":1732620141352},"_id":56710973}
GermanBluefox commented 8 hours ago

OK. I investigated a bit and found following. instanceObj is only available if custom config edited.

Why do you need to send the instanceObj to backend, if backend can have this information just by accessing it with this.config and this.common?