openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.87k stars 3.58k forks source link

[hueemulation] Hue Emulation publishes Items not matching configured tags #13420

Open Argelbargel opened 2 years ago

Argelbargel commented 2 years ago

I installed the hue emulation into my openhab 3 instance and immediatly changed the configuration so that only Items matching certain tags (with which no item was tagged until then) should be exposed/published by the emulation (instead of Switchable etc. i simply changed the Tags to HueSwitchable etc.). Nonetheless the emulation exposes many (but not all) of my lights (it seems these are items/things bound to the ikea tradfri binding) and a load of sensors including much of my echo's sensors.

This seems like a bug to me as i expected that publishing is controlled only by the configured tags. I already tried to remove all the meta data in jsondb/..Metadata.json but after restarting openhab the lights and sensors get exposed again.

Is there any trick or workaround to only expose specific items? I think i could tag all the unwanted items with "internal" but that seems a bit cumbersome....

Context

I'd like to expose a single item/switch (which my echo shall trigger if it detects presence via ultrasonic sound), not all of my lights etc. as most of my equipment is currently still connected to the echo or tradfri and does not need to be exposed again.

Your Environment

openhab 3.3.0/openhabian (installed via apt into my existing raspbian), raspberry 4

Argelbargel commented 2 years ago

Hmm. This seems intentional, so i must be understanding something wrong. The code in StateUtils#determineTargetType() seems to fall back on (or prefer) openhab's semantic tags (e.g. ColorLight or Light)if an item is neither tagged with the ignored tag nor one of the configurable tags.

So, marking all of the above items with the ignored tag seems to be the only way to get this working for my use case. Perhaps you could extend the documentation so that that's a bit clearer?

lsiepel commented 1 month ago

To me this is a clear text. If you have suggestions on how to improve the documenation let me know. image

Argelbargel commented 1 month ago

Hmm. It's almost two years since i wrote this. Hope i get this right:

What i did seems to be to configure the following:

org.openhab.hueemulation:restrictToTagsSwitches=Huemu_Switch org.openhab.hueemulation:restrictToTagsWhiteLights=Huemu_Light org.openhab.hueemulation:restrictToTagsColorLights=Huemu_ColorLight

What i expected was that all items not tagged with any of the configured tags would be ignored. As "the service tries to expose ... based on some criteria explained in the section above". But what the code linked in my last comment does is to first determine the DeviceType based on the openhab-category of an item and then checking, whether it has a more specific tag configured "in the section above" or an ignored tag. When the item has no tag then it is exposed based on the category.

If this is how the emulation is intended to work, then i think the documentation should read ".The service tries... If items are not tagged they will be exposed based on their openhab-category. This means that any non-tagged items in the category "ColorLight" or "Light" will be exposed regardless of the above configuration as long as they are not explicitly tagged with an ignored tag". Define the tags with the following option:

lsiepel commented 1 month ago

@digitaldan as you are codeowner of this binding, can you confirm this behaviour as intended and or if the documentation should be adapted?

digitaldan commented 1 month ago

Hmm, while i did the initial version of the binding, @davidgraeff rewrote it (which was a good thing). At this point I'm not involved with it anymore and should be removed as a code owner.