Jython error accessing items.Item_Name

OpenHAB 2.5.4

I’m getting random strange errors like this:

  File "<script>", line 14, in christmas_tree
AttributeError: 'org.openhab.core.automation.module.script.internal' object has no attribute 'Sun_Elevation'

The offending line:

    if items.Sun_Elevation.intValue() > 0:

The item Sun_Elevation is there, I even saw it in the log

15:28:18.111 [INFO ] [smarthome.event.ItemStateChangedEvent] - Sun_Elevation changed from 18.159740514762 to 17.9778766397046

Now if I changed the code to this, it works fine:

    if items['Sun_Elevation'].intValue() > 0:

It is as if the glue that enables the items being accessed as an attribute to the items object has been disabled.

Restarting OpenHAB would fix this.

Has this occurred again after the restart? Is it always from the same script?

It has happened several times and several restarts. It happened in at least two places in two separate script files that I know of.

I have not been able to reproduce this. Can you provide the bare minimum that will reproduce it, or at least one of the scripts where it is occurring?

Hi Scott, thanks for looking into this. In my logs for the past several weeks, I could only find it happen on one day, 3 days ago. So perhaps it was just some sort of a glitch, because I was reloading some mqtt stuff. Sorry, please consider it bogus for now.

1 Like