Open wvuyk opened 4 years ago
please some answer???????????
This has not been implemented in the core code yet and will not be ready for the first release, so hold off on implementing this.
Too bad. Saw the code for it and really like that possibility for the users. Will wait then for this function to work. I have prepared some code in the plugin already that should return results, so if you ever want to test it, both triggers and actions of my plugin should/might just work.
Thanks,
Wim
Note:
To further be able to extend the ability to identify what events (actions + triggers) reference a device/feature, it makes sense to try and standardize a device/feature dropdown menu in JUI so plugin developers do not have to code their own every single time they want to present a device/feature select list to the user.
Referenced by PSDK-55
Submitted a development request for HS4 to track adding this feature back onto the events page.
Referenced by PSDK-30 and HS-612
@wvuyk it looks like we won't be getting to an events page rewrite as soon as we hoped, but I will keep you updated as soon as we get to it and work on implementing this issue.
Thanks for all of your contributions.
We are now 18 month further after this question. Is there any intention to allow plugins to deliver referenced devices? I do think this is a good feature for users, making this more simple to users?
I just found this looking why ReferencesDeviceOrFeature was never being called. I would love to implement this in my plugins.
This is going to be fixed in HS4 version 4.2.17.0. With this version when a user search for a device in the global search box, the ReferencesDeviceOrFeature methods of your events actions and triggers will be called, and if this method return true the event will be reported in the search results.
Excellent. Just updated my two plugins that should be able to support this. Can't wait to test it!
I'm sorry, but I don't understand what is this function for?
Called by HomeSeer to determine if this action references the device or feature with the specified ref.
What exactly "references" mean here?
If you use the searchbox on the HS pages, you seek for devices and events using a device containing the search string(triggers and actions). It was included as a possibility to use in plugins in 2020, but it was never called from HS side. With this change a plugin can check its own action or trigger based on the users search string and tell if a device or feature is used (referenced) with a name containing the search string of the user.
I have the code waiting inside my plugin already since 2020, so I am really happy to see this is worked on now.... I do think it will help a lot of users to easier find where a device is really used. Is there a test possible for devs before the HS4 version is released?
Wim
@wvuyk , you can test this build: https://homeseer.com/updates4/SetupHS4_4_2_16_4.msi
Also please have a look at this other important change which is implemented in the same build: https://github.com/HomeSeer/Plugin-SDK/issues/124#issuecomment-1348887592
Thanks, seems to work good.
However, it seems that for every devOrFeatRef in a search action, the function is being called twice.
However, it seems that for every devOrFeatRef in a search action, the function is being called twice.
I just tested this again with the sample plugin and if I search for a specific device name then the function is correctly being called once by action configured, If I have 2 actions configured then the function is called twice, once for each action instance , which is what is expected. If I search for a string that match several device names, then the function is called once per device and per action configured, which is also what is expected.
I have only a single event in my test environment. Using my UniFi plugin (which has 3 different Event Actions), that event has an action for two of them. When I search for a device, it returns a single hit (ref 3049).
Each ReferencesDeviceOrFeature has a single log action. This is the result in the HS4 log:
Time From Type Message 19-12-2022 16:45:43 Unifi Info ReferencesDeviceOrFeature: EA_Doorbell for devOrFeatRef 3049 19-12-2022 16:45:43 Unifi Info ReferencesDeviceOrFeature: EA_CustomAPI for devOrFeatRef 3049 19-12-2022 16:45:43 Unifi Info ReferencesDeviceOrFeature: EA_Doorbell for devOrFeatRef 3049 19-12-2022 16:45:43 Unifi Info ReferencesDeviceOrFeature: EA_CustomAPI for devOrFeatRef 3049
So the two actions are both being called twice with the same reference ID.
Again, there is only one event defined in my test setup. Here is a screenshot:
Still can't reproduce this problem. Can you reproduce it with the sample plugin? Do you have some global actions attached to the Event Group? Can you send me your events.json and eventgroups.json files ?
Not sure what is different on my system. WIndows 11, latest updates, Visual Studio 2019, HS4 4.2.16.4.
I created a new test environment by deleting the content of the HomeSeerData.json directory.
Downloaded the latest sample plugin (VBnet). and imported it in Visual Studio.
Modified the ReferencesDeviceOrFeature sub in WriteLogSampleActionType.vb, added "Listener?.WriteLog(ELogType.Info, "ReferencesDeviceOrFeature called for ref: " & devOrFeatRef)" right before the "return false"
Created a virtual device "MyTestDevice" which in turn created a feature called "Control". Then I created an EventGroup "MyEventGroup" and an event "MyEvent". This event is manually triggered and has a single action "Sample Plugin Action - Write to Log".
Searched for "Control". First time the sub was hit twice, second and sub-sequential search attempts even three times!
Time From Type Message 19-12-2022 17:46:18 Sample Plugin VB Info ReferencesDeviceOrFeature called for ref: 6575 19-12-2022 17:46:18 Sample Plugin VB Info ReferencesDeviceOrFeature called for ref: 6575 19-12-2022 17:46:18 Sample Plugin VB Info ReferencesDeviceOrFeature called for ref: 6575
Let me know if you need anything else.
Found the problem, when you click the search button rather than pressing the enter key, the search is done twice. This is a HS4 UI bug.
Yes, I can confirm that hitting enter does not show the issue. Hitting search does it twice or even three times.
Oh, and while we are at it, the reason I click the search button is because just hitting enter sometimes generates a 404. It redirects to /?search_data=Control instead of /search.html?search_data=Control.
I created HS-1766 for the search being done twice issue and HS-1765 for the redirect and 404 page issue. Those problems will probably be fixed in the next version after 4.2.17.0 is released
I have tested too. My findings are that the routine is called for every feature in a device. For most plugins this might work, but for the JowiHue actions it is cumbersome. The actions are controlling all light attributes in one action where the HS device is split for the attributes like Hue, brightness and more. This means the action is checked up to 7 times with a reference to see if the feature might be part of the action. This results in multiple hits of course.
I worked around it so that an event cannot return another hit when called again within 2 seconds, but that is nothing more then a work around for this issue. Is it possible for a plugin to set a limit of one call per device (any of its features) for an action instead for each of its features? That could solve this issue?
Thanks,
Wim
@wvuyk, that depends on what your search for. For example with the following device:
If you search for "Virtual Test", your plugin will only be called with ref 2194 If you search for "Control1", your plugin will only be called with ref 2195 If you search for "Control2", your plugin will only be called with ref 2205 If you search for "1st Floor" or "Bedroom", your plugin will be called with the 3 refs because the root device and the 2 features all have their location1 set to "Bedroom" and their location2 set to "1st Floor"
Which says it all...
7 results as I tried to explain... 1 per device should be enough?
@wvuyk you should not include the name of the device "Badkamer Color" in the name of the features. HS4 should already do that for you in most places like an event action, so there is no need to duplicate the name, this is what is causing the additional results in the search.
It was needed in the beginning of HS4 as in event lists there was no organisation with devices, one could not tell the difference between the Hue part between devices. That is why this naming convention was chosen. and at this point it is a bit late in the game to try and revert this for users. I will stick to the work around for now then. Aside from that I miss the advice you give at this point in the documentation, so there might be some more plugins having this issue.
I am testing with my triggers and actions. I do like the search function in HS4 and am trying to answer on search calls when done by HS4. But I think the ReferencesDeviceOrFeature is never called from HS during a search?
Is this not (yet) implemented? Will it be in the future?
Wim