OH1.8: The name 'unkown' ... cannot be resolved to an item or type

have you defined the timer in the top of the rules file (just after imports)? As you cannot declare variables/timers between rules in the same file.

Maybe it’s just a timing issue…in such as when the else-part comes to the timer.reschedule, the the timer actually expired and has been set to null again, thus throwing the error? maybe you should add a check for timer==null around the Tank_Irrigation_Reporting.postUpdate(ON) like:

if timer==null {
Tank_Irrigation_Reporting.postUpdate(ON)
//do the whole timer set routine
} else {
Tank_Irrigation_Reporting.postUpdate(ON)
Timer_Tank_Irrigation_Reporting.reschedule(now.plusMinutes(2))
}

clutching at straws :wink:

Yes…

How can this be? The time is created for 2 minutes, and the error occurs after one minute…

I have the check for if(timer == null) written as:

 if (Timer_Tank_Irrigation_Reporting == null) { ... }

Obvious now that you point it out. It sounded good at the time i wrote it :slight_smile:

You are a funny man… :slight_smile: understand where you are coming from and appreciate you are thinking about this issue.

And as far as the brckets in the createTimer are concerned:

Now I know why there are two (three) version for coding this timer business. Thanks Rich!

I installed the designer again; just to make sure there is no syntax error in my rule, and there are no red crosses in my rules (or elsewhere).

Should I just give it a rest – as in this is too hard?!
I have spent 6 hours reading the forum with related issues, and none of them got resolved (other than syntax errors)… is this a bug?

When you reload the rules file, you almost certainly have a copy of the timer already running. Reloading the rules file will not destroy it, only the handle var.
I guess it will mess up when it completes; I couldn’t say how it might affect the “new” rule creating another timer but it might be an explanation.
Does that fit with error only seen on rules reload, but not at system startup?

Just quickly scanning the thread. I apologize if I’m way off base.

The problem you are seeing was one I say for awhile in OH 1 and OH 2. I don’t know when or if the problem went away (I’m pretty much exclusively using Expire binding now instead of Timers in Rules, I highly recommend it, makes rules a lot simpler).

The error appeared to be related to OH trying to cancel times that no longer exist on a rules reload. At least when I noticed those errors I would have one for each Timer I had active at the time.

Both are correct. It was an unfortunate but of syntactic sugar the designers if the language chose. The denotes a lambda. If a lambda is the last argument to a method call you can define the lambda outside the closing ).

You will notice I always define my lambda inside the ().

In short, (time, [ lambda]) and (time) [ lambda ] are both correct.

Actually it is perfectly valid to send the String “ON” to a Switch Item. The String must be all caps but the Switch Item knows how to parse it. If you use the Actions, the String “ON” gets sent even when you usesendCommand(MyItem, ON).

Possibly. Something weird is going on for sure.

At this point I would consider the Expire binding as the more “correct” approach and recommend considering using it.

Sometimes discretion is the better part of valor. Semper gumby.

I haven’t tried the ‘reboot’ yet… all the stuff I’ve read on this forum does not get to the bottom of it…
… my system is running quite a few things, hence, rebooting is a last resort; and was a reason once to give up on Windows :slight_smile:

Now that two smarty pants :slight_smile: suggested the Expire binding, which I will now use.

… don’t you worry… always appreciate your replies. :slight_smile:

I tried both versions of the time; same (error) result.

While I am open to change, I do not change just because I could… I am not on OH2 because of the many problems associated with it; this createTimer thing had tons of examples; yes, lots that had problems, but I thought there must be a few working ones out there (maybe they didn’t look at the log or ignored it) – and look at the effort I put into getting this right 8+ hours by now… however, given your and Watou’s reply to use the Expire binding, I will go that route…

Thanks to all for hanging in there trying to solve such an awkward error!

Is the Expire binding working with OH1.8.3?
Where do I find it?
went there: https://github.com/openhab/openhab1-addons/wiki/Expire-Binding
which sent’ me there: https://openhab.ci.cloudbees.com/job/openHAB1-Addons/lastSuccessfulBuild/artifact/bundles/binding/org.openhab.binding.expire/target/org.openhab.binding.expire-1.9.0-SNAPSHOT.jar
which ended up as 404.

sudo apt-get install openhab-addon-binding-expire
said: Unable to locate package openhab-addon-binding-expire

True… link is broken (it’s because since the release of openHAB2 stable (2.0.0) all binding snapshots have been renumbered from 1.9.x to 1.10.x (and for OH2 from 2.0.x to 2.1.x)… so https://openhab.ci.cloudbees.com/job/openHAB1-Addons/lastSuccessfulBuild/artifact/bundles/binding/org.openhab.binding.expire/target/org.openhab.binding.expire-1.10.0-SNAPSHOT.jar works :))

Try also: https://openhab.ci.cloudbees.com/job/openHAB1-Addons/lastBuild/org.openhab.binding$org.openhab.binding.expire/
(place org.openhab.binding.expire-1.10.0-SNAPSHOT.jar in your addons folder… it should load it up… I am not familiar with OH1)

I don’t know if it will work on OH1… it should (since it’s a 1.x binding)

1 Like

It does work with 1.8.

Clearly the wiki needs to be updated.

I would have expected the apt-get to have installed it. Is there a snapshot repo 1.8 users should be pulling from to get the 1.9 and 1.10 version bindings?

1 Like

OK… after Rich second your suggestion, I tried the expire binding.
In principle it works. :slight_smile: Well, this is a success story for me, as I tried something new and it worked (other than the link for the binding being broken – now fixed).

Question for you if you do not mind:
Considering the example you’ve given me…
If the level change does not arrive within 2 min (given it is, under normal conditions, updated every 60 sec), I should never have an expired timer, thus a state of UNDEF.
However, what my initial timer rule achieved was:
send reporting = ON if a level update has been received
send reporting = OFF if it hasn’t

With my expire binding I get the OFF, but what gives me the ON…?
If this makes sense?!

EDIT:
At present I have this:

rule "Irrigation tank update not received"
  when
    Item Tank_Irrigation_Level changed to UNDEF
  then
     logInfo("IrriTank.rule", "Tank_Irrigation_Reporting: no update received on time")
     Tank_Irrigation_Reporting.postUpdate("OFF")
end

rule "Irrigation tank update received"
  when
    Item Tank_Irrigation_Level received update
  then
     Tank_Irrigation_Reporting.postUpdate("ON")
end

Which is not really much of a saving compared to the createTimer()…
I suspect it is my lack of creativity to solve this differently. :frowning:

Just one rule can be used to track whether the Tank_Irrigation_Level is UNDEF or another state:

rule "Irrigation tank update received"
  when
    Item Tank_Irrigation_Level received update
  then
     Tank_Irrigation_Reporting.postUpdate(if (Tank_Irrigation_Level.state == UNDEF) OFF else ON)
end
1 Like

Ouch… This hurts!
Thank you for enlightening me…
I wondered how I could incorporate the if()… doh.
Again, thank you very much…

(Reading through the Please test the new Expire Binding, which has some really good bits in it.)

Hmmm…

tried the suggestion, winch results in an error:

2017-02-06 18:16:30.846 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Irrigation tank update received': The name 'UNDEF' cannot be resolved to an item or type.

I also tried “UNDEF”, Undefined, “Undefined”…

And then rewrote the rule to:

rule "Irrigation tank update not received"
  when
    Item Tank_Irrigation_Level received update
  then
    // https://community.openhab.org/t/oh1-8-the-name-unkown-cannot-be-resolved-to-an-item-or-type/22078/24
    // OH2: if (Tank_Irrigation_Level.state == UNDEF) {
    // OH1: if (Tank_Irrigation_Level.state == Undefined) {
    if (Tank_Irrigation_Level.state == Undefined) {
      logInfo("IrriTank.rule", "Tank_Irrigation_Reporting: no update received on time")
      Tank_Irrigation_Reporting.postUpdate("OFF")
    } else {
      Tank_Irrigation_Reporting.postUpdate("ON")
    }
end

… same result, with all four variations of undefined.

EDIT: I made a mistake in the if() and corrected Undefinded to Undefined

Sorry, I forgot you are on openHAB 1.8. UNDEF in openHAB 2 is Undefined in openHAB 1. Don’t use quotes for states like ON, OFF, Undefined. You seem to be trying Undefinded when Undefined should work.

1 Like

Thank you again! … and for spotting my mistake!

With the correction it works!! :slight_smile:

(Have updated my code above, so others who might copy mau not experience this problem.)

Clearly, I have been on this timer thing for too long – 2 days now – and don not see the forest because of the trees. :unamused:

To demonstrate what I wanted to achieve…

2 Likes

Glad you got it working and I’m sorry you had such a challenge getting it to work. I’ve become a complete Expire binding convert largely because working with Timers can be so error prone and the errors seen can be very challenging to figure out what went wrong.

No need to be sorry… :slight_smile:
It has nothing to do with you…

As I said, most of these cases I read on the forum did not end up with a resolution… and the ongoing issue of cryptic errors the average, let alone newbie, cannot resolve.

At least , we’ve got something working now… :slight_smile: