Rule stopped working in 2.5.4

Openhab 2 running on a Pi4

Upgraded from 2.5.0 to 2.5.3

After a long battle with exec.whitelist(!) finally got my command scripts to run which exposed another problem.

I have a Rule which converts a string to a number. Not sure where I got the rule (somewhere on this site?) but it has worked without errors until I got to 2.5.3

The rule is:
<
rule “onewiretempValue1 String to Number”
when
Item onewiretemp1Value changed
then onewiretemp1Value_num.postUpdate(Float::parseFloat(String::format("%s",onewiretemp1Value.state).replace(’ ‘,’’)))
end

The error I get is:

<Rule ‘onewiretempValue1 String to Number’: The name ‘onewiretemp1Value_num’ cannot be resolved to an item or type; line 132, column 5, length 21>

onewiretemp1Value_num is defined in my Items file as a Number, as it always has been.

when working normally my event log shows:

<20:38:56.243 [INFO ] [smarthome.event.ItemStateChangedEvent] - onewiretemp1Value changed from 27.500 to 27.000
20:38:56.269 [INFO ] [smarthome.event.ItemStateChangedEvent] - onewiretemp1Value_num changed from 27.5 to 27.0

Any ideas on how to fix this?

Thanks
Brian

Please use fences (</>) to make it easier to read lines of code.

The name ‘onewiretemp1Value_num’ cannot be resolved to an item or type; line 132, column 5, length 21

Can you show us your item definition for onewiretemp1Value_num? I just want to make sure there isn’t a typo.

If nothing has changed since you updated, maybe the item file didn’t get loaded properly after the restart. Saving the item file might do the trick.

Sorry, haven’t figured out the fence thing yet.

Number onewiretemp1Value_num “HVAC Main [%.1f °C]” (gTemp)

Reverting back to 2.5.0 it all started working again

There are a variety of ways to get code fences, but I usually just select the text and press the </> button. Unfortunately, it sometimes gets a little messy with long, unbroken strings of text.

Number onewiretemp1Value_num "HVAC Main [%.1f °C]" (gTemp)

rule “onewiretempValue1 String to Number”
when
Item onewiretemp1Value changed
then onewiretemp1Value_num.postUpdate(Float::parseFloat(String::format("%s",onewiretemp1Value.state).replace(’ ‘,’’)))
end

Since it works when you revert to 2.5.0, I would guess that the item didn’t load properly after the upgrade.

Why did you go to 2.5.3 instead of straight to 2.5.10?

Russ

In my experience upgrades always generate issues, so my plan was to upgrade in steps

I have read all the release notes and was aware of the breaking change for Command scripts

I’ve tried to maintain a Staging system for testing but it’s limited without all the controlled devices, so I end up testing on my Main system

I really don’t understand the conversion expression in my rule so I was hoping someone could weigh in on whether it was still valid.

I’ll try upgrading again but I’m not optimistic

Yeah, I just clone my SD card whenever I’m going to upgrade, so that I can immediately fall back.

Unfortunately, I can’t help you with the converstion string, but I’m not convinced it’s the problem since your error is saying that the item couldn’t be resolved.

Did you get it from this post?

I guess that post is similar but my rule predates it by at least a couple years.

You’re right, the system is complaining about resolving the item type which should be valid.
BTW, I’ve got 4 of these temp sensors and they were all generating errors so it’s unlikely to be a file load issue, but I’ll try upgrading again when I have time to burn.

I was using the SD card clone method until I got a new laptop which does not like Win32DiskImager!
another issue to track down…

1 Like

Is this the only Item you see an error like that for or are other Items that should exist being reported as missing too? A good way to check is opening the sitemap. Your log will be flooded with errors about missing Items.

If this is the case, wait for OH to complete coming up and then restart it without clearing the cache. This is a known bug in OH 2.

If that isn’t the case, there is something wrong with the Item definition or .items file that is causing it not to be created.

Three other variations of that item. onewiretemp1Value_num, onewiretemp2Value_num, etc
Those are the only ones giving errors which led me to thinking it was something about the expression they were being used in.

I will be more patient and try the restart

Thanks

Just to follow up

upgraded again to 2.5.3 and came up the first time…no errors!

1 Like