Skip to content
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

$(...) selector misses states #109

Closed
AlCalzone opened this issue May 6, 2018 · 22 comments
Closed

$(...) selector misses states #109

AlCalzone opened this issue May 6, 2018 · 22 comments

Comments

@AlCalzone
Copy link
Collaborator

Disclaimer: This is a very old bug report. I'm not sure if its still relevant, but I'm leaving it here until we have confirmed that it works or not.

https://forum.iobroker.net/viewtopic.php?f=22&t=5665

@AlCalzone
Copy link
Collaborator Author

Just confirmed, this issue is still present in the newest version of the adapter. I could reproduce it this way:

  1. Stop an adapter and delete its objects, in my case g-homa
  2. Stop the JS adapter instance
  3. Create a script which has a selector which contains "device" or "channel" as the type
function doIt() {
    log(`selector found ${$("device{shortmac=D3:D2:EA}").length} states`);
}
doIt();
setTimeout(doIt, 30000);
  1. Start the JS adapter instance, wait until the script has started.
  2. Start the adapter from step 1

Expectation:
2018-06-26 19:09:33.856 - info: javascript.1 script.js.dev-Skripte.script_dev: selector found 0 states
2018-06-26 19:10:03.859 - info: javascript.1 script.js.dev-Skripte.script_dev: selector found 4 states

Actual:
2018-06-26 19:09:33.856 - info: javascript.1 script.js.dev-Skripte.script_dev: selector found 0 states
2018-06-26 19:10:03.859 - info: javascript.1 script.js.dev-Skripte.script_dev: selector found 0 states

I believe this has to do with this part of the code, where context.channels and context.devices is filled exactly once.

if (name === 'channel' || name === 'device') {

Once that has been done, changes to the objects and channels collections are no longer reflected in the $-selector.

I think this should be moved outside the sandbox.js and kept in sync with changes in objects and channels.

@AlCalzone AlCalzone added the bug label Jun 26, 2018
@GermanBluefox
Copy link
Contributor

Still open?

@AlCalzone
Copy link
Collaborator Author

Yes, still an issue:
grafik

@Garfonso
Copy link
Contributor

Garfonso commented Apr 18, 2020

1. Stop an adapter and delete its objects, in my case `g-homa`

Do you also delete the g-homa.0 object?

I believe this has to do with this part of the code, where context.channels and context.devices is filled exactly once.

I, too, think that this is an issue. Both are filled here, once in adapter lifetime and never updated: https://github.com/ioBroker/ioBroker.javascript/blob/master/lib/sandbox.js#L572

The context comes from main function so they could be cleaned in onObjectChanged easily. I am not 100% sure on what changes to do that, though... because the way devices and channels are filled they do not really describe objects of type device/channel but parent/grandparent of a state (i.e. [addtional_part].device.channel.state, no matter what the structure really looks like).

Not sure if that is intended? But given that this code seems to exist for a long time, I am a bit hesitant to change it, maybe people rely on that behaviour?

What do you think?

For the current system one probably would have to clean the caches for every object addition / deletion.

@AlCalzone
Copy link
Collaborator Author

Do you also delete the g-homa.0 object?

I don't remember but I think I just deleted everything of the adapter.

@stale
Copy link

stale bot commented Jul 27, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions.
Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

@stale stale bot added the wontfix label Jul 27, 2020
@AlCalzone
Copy link
Collaborator Author

I don't recall a fix for this.

@stale stale bot removed the wontfix label Jul 27, 2020
@Garfonso
Copy link
Contributor

Garfonso commented Aug 7, 2020

the way devices and channels are filled they do not really describe objects of type device/channel but parent/grandparent of a state (i.e. [addtional_part].device.channel.state, no matter what the structure really looks like).

I'd still like to get some kind of comment (from the core devs or anybody else) on that issue... currently the device/channel filters do not really care for the object structure at all but assume a fixed device.channel.state structure.

Is that intended?

One result is that a selector for "device" will fail if the device does not have channels. Also both filters will find non existing objects (i.e. for a state instance.0.one.two.state a device instance.0.one and a channel instance.0.one.two can be found, even if those do not exist at all in the object database).

Changing that would be a breaking change and would also make the code a lot more complex (or at least require a huge change).

So the easier way to go would be to just delete the whole cache for every object change and let it be as it is (and wait till someone notices and complains 😉). (If the object structure would be honoured by the cache a more intelligent clean up would be possible, but currently that would be to error prone IMHO - at least that is the conclusion I reached when I looked at it more closely, which is ~6 months past now, already).

@stale
Copy link

stale bot commented Nov 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions.
Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

@stale stale bot added the wontfix label Nov 7, 2020
@Garfonso
Copy link
Contributor

Garfonso commented Nov 7, 2020

Maybe we should add some label on this issue? It is far from solved and should be discussed.

@stale stale bot removed the wontfix label Nov 7, 2020
@AlCalzone
Copy link
Collaborator Author

What label shuts the bot up? @Apollon77
Bug doesn't seem to do it

@Apollon77
Copy link
Contributor

Enhancement - or simply one post every 3months

@AlCalzone
Copy link
Collaborator Author

AlCalzone commented Nov 7, 2020

I think we should add one more. Enhancement is not correct if an issue is a bug.
I mean it's fine for user reports but if a maintainer says this is a bug, it is a bug.

@Garfonso
Copy link
Contributor

Garfonso commented Nov 7, 2020

A reminder every three months has its perks, too. 😄

@Apollon77
Copy link
Contributor

a new lable "confirmed bug" and have that in stalebot excluded?

@MartinSchlender
Copy link

Here is another case for easyly reproducing the problem if you have a an Amazon Echo and Alexa2 adapter running
https://forum.iobroker.net/topic/39019/ids-vom-selektor-wie-kann-man-die-objekte-aktualisieren

@stale
Copy link

stale bot commented Feb 24, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions.
Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

@DrBakterius
Copy link

The problem has been known for so very long now and still no solution in sight?

@stale
Copy link

stale bot commented Jul 8, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions.
Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

@stale stale bot added the wontfix label Jul 8, 2021
@AlCalzone AlCalzone removed the wontfix label Jul 8, 2021
@AlCalzone
Copy link
Collaborator Author

Wanna try to solve it and make a PR? :)

@Garfonso
Copy link
Contributor

Garfonso commented Jul 8, 2021

the way devices and channels are filled they do not really describe objects of type device/channel but parent/grandparent of a state (i.e. [addtional_part].device.channel.state, no matter what the structure really looks like).

I still see the question if that is intended or should be changed unanswered and code is not changed. The device/channel selectors currently do not select objects of type device or channel. Is that intended or not?

If it is not, it should be changed and then in onObject change it is easy to update channel/device cache from object type.

If it is intended and device/channel should select grandparent / parent no matter what type of object they are (and IIRC even no matter if they exists at all) the most feasible thing to to in onObject change is probably to delete the cache and recreate it the next time. But with adapters changing objects every few minutes this could mean a lot of additional workload which might even lead to the conclusion that the cache should be stripped altogether and only the required parents / grandparents should be calculated as needed and not cached.

So for me still this question needs to be answered before it makes sense to fix the bug. The change from grandparent/parent to device/channel is of course a breaking one. But it would make sense, in my eyes.

@Apollon77
Copy link
Contributor

In my eyes changes to channels or devices and such needs to be reflected in adapter ... means yes it is an bug, but noone had time so far to fix it ... So PRs welcome until someone else finds time.

The question is more: What else might be missing beside channel/devices? Is enums updated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants