Dummy/Virtual item without a binding

Hi,

I am migrating from openhab 1 to openhab 2, and I have a dummy/virtual item defined as:

Switch sSecurity "Security Toggle" <lock>

in my /etc/openhab2/items/security.items file.

In my rules I have things like:

if (sSecurity.state != ON) {

All this worked fine in openhab 1, but in openhab2 that items doesn’t seem to ‘register’ (i.e. it doesn’t appear in the list of items in Paper UI) even though I don’t get any error in openhab.log when I change the security.items file and it get refreshed.

I do get errors like:

2017-05-03 22:20:05.018 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule security loop: An error occured during the script execution: The name 'sSecurity' cannot be resolved to an item or type.

when a rule tries to access that item.

Any idea what I am doing wrong? Do I need to change something as part of the migration to openhab 2?

Thx,
Thib.

Hi all,

I have pretty much the same problem when trying to run my openhab-1 setup in openhab-2.

Is there any way to use items without a binding?

Thanks,
Daniel

There is nothing wrong with what you have posted.

  • Are you seeing errors in the logs when your .items file loads?
  • Do you see the missing Item(s) in PaperUI? Even when defined in a .items file they should appear there under Configurations -> Items
  • Do the missing Items appear in the Item browser in ESH Designer 0.8? That is the panel in the lower left corner by default. Do you see any syntax errors in Designer?

Hi Rich,

Before I forget, I use openhab 2.0.0.
To answer your questions:

  • No error when the .items file loads. If I ‘touch’ the file, all I get is:
    2017-05-04 22:08:49.698 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'security.items'
    without any error immediately after it.
  • I don’t see the “sSecurity” item in PaperUI (but I do see groups and zwave items in there – I don’t see this dummy item, or http1 items I have)
  • I don’t see it in ESH Designer 0.8 either. I only see the groups that I defined in the same .items file in the list of items in ESH. I don’t see any syntax error in there either, at least for the line defining sSecurity.

Hence my being a bit lost here… no obvious error that I can see to explain why the item is not created, and yet it doesn’t exist anywhere…

Thibault.

Make a new additional .items file and pop just this one in it. (suspecting an invisible control character etc. in the usual file)

Was worth a try, but no luck unfortunately:

$ cat sitemaps/test.sitemap 
Switch item=sSecurity label="blah"


2017-05-04 22:38:35.636 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'test.sitemap'
2017-05-04 22:39:05.022 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule security loop: An error occured during the script execution: The name 'sSecurity' cannot be resolved to an item or type.

(note I retyped the line again instead of copying and pasting to limit the risk of weird characters ending up in there)

No,I meant an .items file not a sitemap

oups sorry, not sure how I managed to do a sitemap instead of an .items.

But still the same with .items :confused:

 $ echo 'Switch item=sSecurity label="blah" <lock>' | tee items/test.items
Switch item=sSecurity label="blah" <lock>

2017-05-04 22:44:45.743 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'test.items'
2017-05-04 22:45:22.061 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule security loop: An error occured during the script execution: The name 'sSecurity' cannot be resolved to an item or type.

Okay, so let us now assume sSecurity is a valid Item.

Next I would create a new rules file with a single test rule that does something simple with sSecurity.
Suspicion that you have something like a var also called sSecurity in your original rules file.

Hi again,

Ok so instead of creating a new rules file, I’ve strip down almost everything from the my security.rules (I thought it would be even clearer) so as I am left with:

$ cat rules/security.rules 
rule "security loop"
when
    Time cron "05 * * * * ?"
then
    if (sSecurity.state != ON) {
		logInfo("Security loop", "In loop, with security currently disabled -- nothing to do.")
		return null
	}

    logInfo("Security loop", "Entering loop with security enabled...")

    logInfo("Security loop", "Exiting loop.")
end

But unfortunately still the same error:

2017-05-05 22:46:30.755 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'security.rules'
2017-05-05 22:46:52.203 [ERROR] [alization.ZWaveNodeInitStageAdvancer] - NODE 4: Node advancer: Retries exceeded at PING
2017-05-05 22:46:52.239 [ERROR] [alization.ZWaveNodeInitStageAdvancer] - NODE 10: Node advancer: Retries exceeded at PING
2017-05-05 22:46:52.249 [ERROR] [alization.ZWaveNodeInitStageAdvancer] - NODE 7: Node advancer: Retries exceeded at PING
2017-05-05 22:47:05.116 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule security loop: An error occured during the script execution: The name 'sSecurity' cannot be resolved to an item or type.

OK I think I have found the issue. It would appear I attempted to comment out a (different) line from my .items file at some point, but used a bash style (’#’) instead of C++ style comments (’//’).
With this, I don’t get any error when openhab (re)loads the .items file, but it still seems to make it silently fail to load the .items file properly (and not just the line in question unfortunately).

Now that this is fixed, I see the log line I expect:

2017-05-05 23:49:20.011 [INFO ] [smarthome.model.script.Security loop] - In loop, with security currently disabled -- nothing to do.

Thank you for your help on this one.

Another weird one is that now PaperUI doesn’t show any item at all, but instead greet me in configuration->Items with “500 - internal server error”.
HABmin in Configuration->Items doesn’t show any item either, but tells me “Error loading list of bindings!”. But no obvious error in openhab.log

I’ve now commented out all the now invalid openhab-1 style zwave item definitions, e.g.;

//Switch sChbAmis "Chambre d'amis" (gBackLights) {zwave="12:command=switch_binary,refresh_interval=60"}

and HABmin is happier (should’t Openhab log an error if it can’t parse/interpret a line?) but not PaperUI which still doesn’t show anything.

Oh well…