I’ve tried the above using state.toString() and just state in place of state.format("%s") and all had the same result. If thermostatEquipmentStatus is “”, I get the following log messages:
2018-06-14 08:53:46.249 [INFO ] [del.script.ClimateControl-FamilyRoom] - Before
2018-06-14 08:53:46.249 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Climate Control Family Room': An error occurred during the script execution: index=1, size=1
However, if thermoststatEquipmentStatus is set to “fan” then there isn’t an error.
2018-06-14 08:55:57.373 [INFO ] [del.script.ClimateControl-FamilyRoom] - Before
2018-06-14 08:55:57.373 [INFO ] [del.script.ClimateControl-FamilyRoom] - here
For testing, I’m setting that value using this rule and modifying the dimmer that triggers it to set the string value. It’s set from a binding IRL.
rule "Temp equipment status"
when Item testDimmer changed
then
logInfo("temp", "clearing equipment status");
thermostatEquipmentStatus.postUpdate("fan");
end
Platform information:
Hardware: 64 Bit Intel Core 2 Duo
OS: Fedora 25
openHAB version: openHAB 2.2.0 Release Build on Docker
I searched the forum and found a couple other places where this error message occurred. They seemed to be misuses of logInfo() by not passing at least 2 arguments. That’s not the case here. It seems to be related to the string item being empty. Not sure why… Anybody know what causes this?
Good idea. Unfortunately the log looks exactly the same when I tried it…
Also, I wondered if it was something the binding behind thermostatEquipmentStatus was doing where it didn’t like me manually changing those values. Changing all instances of thermostatEquipmentStatus with tempthermostatEquipmentStatus in the rule file and creating the item
thermostatEquipmentStatus is an item that is tied to a binding (ecobee). Since I am calling a postUpdate in a rule (“Temp equipment status”) posted in the first post, I wondered if the binding was having trouble with that and that was the cause of the error.
Before my 2nd post above, I tried two things:
Use !thermostatEquipmentStatus.state.tostring().isEmpty() like you suggested. This gave the same error.
Replace all uses of thermostatEquipmentStatus with newly defined vertual String Item tempthermostatEquipmentStatus. I did this to avoid the possibility of the binding having a problem with how I set the value. Still the same error.
I couldn’t post the full rule because there was too much in it, but I tried doing a simple rule containing just the if in question.
rule "Climate Control Family Room"
when
Item testSwitch changed
then
var commandName = "ClimateControl-FamilyRoom";
logInfo(commandName, "Before");
// If thermostat is in cooling mode and either the AC or the fan is on
if(thermostatHvacMode.state.format("%s") == "cool"
&& thermostatEquipmentStatus.state.toString() != ""
){
logInfo(commandName, "here");
}
else{
logInfo(commandName, "Other");
}
end
When I did this, I didn’t get the error. I don’t understand how the original rule could work in some situations and not others with the exact same code, but it looks like I may just have to rebuild the original rule from scratch and test after adding each bit of code.