- Platform information:
- Hardware: Raspberry Pi Model 3B+
- OS: Linux devpi 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022 armv7l GNU/Linux
- Java Runtime Environment: OpenJDK Runtime Environment Zulu11.54+25-CA (build 220.127.116.11+1-LTS)
- openHAB version: 3.2.0 - Release Build
Like a number of people on this forum, I want to check that a Thing associated with an Item is ONLINE. I understand that an item can link to multiple Things but in my case (tuya switch) they don’t. I have read a few posts on this forum but they are not textual rules-based answers (and I can’t figure it out).
I have tried this:
import org.osgi.framework.BundleContext.getService rule "Test" when Time cron "0,15,30,45 * * ? * * *" // Check every 15 seconds then var itemChannelLinkRegistryService = getService("org.openhab.core.thing.link.ItemChannelLinkRegistry") logDebug("MP","itemChannelLinkRegistryService=" + itemChannelLinkRegistryService) var myThings=itemChannelLinkRegistryService.getBoundThings("test-thing") logDebug("MP","myThings=" + myThings) end
but that results in:
2022-06-14 16:55:45.594 [DEBUG] [org.openhab.core.model.script.MP ] - itemChannelLinkRegistryService=null 2022-06-14 16:55:45.597 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'al-1' failed: 'getBoundThings' is not a member of 'org.openhab.core.persistence.PersistenceService'; line 10, column 15, length 59 in al
Clearly, the getService function is failing to return anything. Can someone please tell me what I am doing wrong? Thanks.