openhab / openhab-addons

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

[mqtt.homie] An Item linked to a property command not-retained Homie channel ignores the command options metadata #16843

Open Procsiab opened 3 months ago

Procsiab commented 3 months ago

Expected Behavior

After adding Command Options metedata from the Item's UI page, clicking the Item state shows the list of labels declared inside the metadata

Current Behavior

After adding Command Options metedata from the Item's UI page, clicking the Item state shows the enum strings read from MQTT Homie instead

Steps to Reproduce (for Bugs)

  1. Add an MQTT Homie Thing (e.g. I am interacting with a Valetudo instance)
  2. Choose a discovered channel that is documented as Property, command, not retained and add a link to an item
  3. Set type: string and tags: ['Point'] (Type as String, semantic class as Point)
  4. Open the Item's configuration page
  5. Add a Command Options metadata with a label different than the advertised command string from MQTT
  6. Click on the Item's state card from the same UI page, the set Command Options will not be shown

Context

I would like to override the command strings advertised by the Homie Thing for visualization inside a sitemap

Workaround

For the time being, I changed my sitemap replacing Default for Switch or Selection for all the objects referencing said Homie-linked Items and using the Map property to declare a second time every label I would like to show up.

Your Environment

OpenHAB and the MQTT broker are run as rootless containers on Fedora IoT 40.20240520.0 with Podman 5.0.3; container images are fetched from the docker.io registry, from the official sources.

The Homie thing I am interacting with is a Valetudo instance.

The following is the description of one Homie Topic that is showing the issue I described:

Command topic: <TOPIC PREFIX>/<IDENTIFIER>/TopicName/trigger/set
Command response topic: <TOPIC PREFIX>/<IDENTIFIER>/TopicName/trigger
Data type: [enum](https://homieiot.github.io/specification/#enum) (allowed payloads: PERFORM)
ccutrer commented 1 month ago

Do you have a screenshot of what you're seeing, marked up with what you're expecting? Mostly this sounds like either a Core or a WebUI issue. The binding just provides a default command and/or state description, and it can't do anything about it the actual display (especially if you override it).

Procsiab commented 1 month ago

I think I have good news regarding this issue: I am not able to reproduce it anymore with OpenHAB 4.2.0; to be more clear with respect to my initial comment, I will add screenshots below to show you where now I see the expected behaviour and with version 4.1.2 I was experiencing the issue:

1. Item linked to a Homie thing's Property, command, not retained type channel

Screenshot from 2024-07-28 09-48-37

2. Command Metadata for that Item

Screenshot from 2024-07-28 09-49-01

3. Sitemap section for that Item, using only the Default element

Screenshot from 2024-07-28 09-50-49

4. Sitemap rendered from Android client, highlight on the Default sitemap element linked to the Item

Screenshot_20240728-095146_openHAB

5. Tapping on the sitemap Default element reveals the command options

In OpenHAB 4.1.2 I did not see any of the command options I set inside the Item's metadata, whereas I was presented with an empty selection menu

Screenshot_20240728-095155_openHAB

Procsiab commented 1 month ago

Unfortunately, I could reproduce this issue by updating from OpemHAB 4.2.0 to 4.2.1; the following is the screenshot of the same screen on the Android client as before, no changes in the sitemap:

IMG_20240817_091728_835

As you can see, the drop down is no longer shown, and from the OpenHAB web interface the menu is empty, even if the Command Options are set on the underlying Item

I will gather the update log shortly

Procsiab commented 1 month ago

Below the contents of my update.log file

update.log ``` Image and userdata versions differ! Starting an upgrade. You can find backup of userdata in /openhab/userdata/backup/userdata-2024-08-16T18-22-16.tar ################################################ openHAB Docker update script ################################################ The script will attempt to update openHAB to version 4.2.1 Please read the following notes and warnings: Replacing userdata system files with newer versions... Clearing cache... Starting JSON database update... [main] INFO org.openhab.core.tools.internal.Upgrader - Already executed 'itemCopyUnitToMetadata' on 2024-02-15T15:41:27.808933026Z[GMT]. Use '--force' to execute it again. [main] INFO org.openhab.core.tools.internal.Upgrader - Already executed 'linkUpgradeJsProfile' on 2024-02-15T15:41:27.867574020Z[GMT]. Use '--force' to execute it again. [main] INFO org.openhab.core.tools.internal.Upgrader - Already executed 'linkUpgradeScriptProfile' on 2024-07-12T13:48:22.270561213Z[GMT]. Use '--force' to execute it again. JSON database updated successfully. SUCCESS: openHAB updated from 4.2.0 to 4.2.1 ```

And here follows the contents of openhab.log

openhab.log ``` 2024-08-16 18:22:46.080 [INFO ] [org.openhab.core.Activator ] - Starting openHAB 4.2.1 (Release Build) 2024-08-16 18:22:48.276 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Europe/Rome'. 2024-08-16 18:22:48.282 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Location set to '41.4672715428209,12.903710603713991'. 2024-08-16 18:22:48.284 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'it_IT'. 2024-08-16 18:22:48.285 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Measurement system set to 'SI'. 2024-08-16 18:22:55.157 [INFO ] [.core.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007 2024-08-16 18:22:57.961 [INFO ] [e.automation.internal.RuleEngineImpl] - Rule engine started. 2024-08-16 18:23:23.136 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '127.0.0.1' with clientid openhab-auriga 2024-08-16 18:23:26.241 [INFO ] [l.googletv.GoogleTVConnectionManager] - oogo - Error opening SSL connection to 192.168.1.72:6466 Host is unreachable 2024-08-16 18:23:37.155 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - ScriptEngine for language 'application/javascript' could not be found for identifier: 70f855d8-2592-478d-b5fc-c90bb5b54b3f 2024-08-16 18:23:37.162 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - ScriptEngine for language 'application/javascript' could not be found for identifier: 387af2bc-709a-4e30-bb13-ba8673758933 2024-08-16 18:23:37.228 [ERROR] [org.openhab.core.items.GenericItem ] - Tried to set invalid state 0.0 (DecimalType) on item Zia_Petunia_REST_Usa_detergente o f type StringItem, ignoring it 2024-08-16 18:23:37.366 [ERROR] [org.openhab.core.items.GenericItem ] - Tried to set invalid state 0.0 (DecimalType) on item Zia_Petunia_REST_Percorso_lavatur a_stretto of type StringItem, ignoring it 2024-08-16 18:23:37.429 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - ScriptEngine for language 'application/javascript' could not be found for identifier: 70f855d8-2592-478d-b5fc-c90bb5b54b3f 2024-08-16 18:23:37.989 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception: java.util.ConcurrentModificationException: null at java.util.HashMap$Values.forEach(HashMap.java:1068) ~[?:?] at org.openhab.binding.freeboxos.internal.api.rest.WebSocketManager.lambda$0(WebSocketManager.java:127) ~[?:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?] at java.lang.Thread.run(Thread.java:840) [?:?] 2024-08-16 18:23:38.052 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - ScriptEngine for language 'application/javascript' could not be found for identifier: d3f96672-86fd-41c6-933b-4fc53f94d772 2024-08-16 18:23:39.202 [WARN ] [ty.util.ssl.SslContextFactory.config] - Trusting all certificates configured for Client@69e1b496[provider=null,keyStore=null,t rustStore=null] 2024-08-16 18:23:39.202 [WARN ] [ty.util.ssl.SslContextFactory.config] - No Client EndPointIdentificationAlgorithm configured for Client@69e1b496[provider=null ,keyStore=null,trustStore=null] 2024-08-16 18:23:39.961 [INFO ] [nding.http.internal.HttpThingHandler] - Using the insecure client for thing 'http:url:ziapetunia'. 2024-08-16 18:25:24.267 [WARN ] [core.thing.internal.ThingManagerImpl] - Channel types or config descriptions for thing 'miio:generic:06C1E850' are missing in the respective registry for more than 120s. In case it does not happen immediately after an upgrade, it should be fixed in the binding. 2024-08-16 18:25:24.272 [WARN ] [core.thing.internal.ThingManagerImpl] - Failed to normalize configuration for thing 'miio:generic:06C1E850': {thing/channel=Ty pe description miio:YEELINK_LIGHT_LAMP1_power for miio:generic:06C1E850:power not found, although we checked the presence before.} 2024-08-16 18:25:40.335 [WARN ] [core.thing.internal.ThingManagerImpl] - Channel types or config descriptions for thing 'mqtt:homie300:460b8fd214:ziapetunia' a re missing in the respective registry for more than 120s. In case it does not happen immediately after an upgrade, it should be fixed in the binding. 2024-08-16 18:25:40.340 [WARN ] [core.thing.internal.ThingManagerImpl] - Could not normalize configuration for 'mqtt:homie300:460b8fd214:ziapetunia' because th e thing type was not found in registry. ```