Timer Rule Syntax error or item state error

  • Platform information:
    • Hardware: Virtualised 64bit CPU
    • OS: Ubuntu 18.04
    • Java Runtime Environment: openjdk version “1.8.0_232”
    • openHAB version: openHAB 2.4.0 Release Build

I have a rule here that doesn’t seem to be triggering and I can’t be sure if the problem is with the rule or with the thermostat. I am leaning towards the thermostat because of the way it presents it’s setpoint to OH.

The rule is here:
rule “Heat Boots Timer”

when

    Item thermostat_gf_setpoint changed

then

    if(thermostat_gf_setpoint.state > 21)

        if(boostTime===null)

            switch_gf_hall_heatboost.sendUpdate(ON)

            boostTime = createTimer(now.plusMinutes(60)) [|

                thermostat_gf_serpoint.sendCommand(20)

                    switch_gf_hall_heatboost.sendUpdate(OFF)

                    boostTime = null

            ]

end

The problem I see from the device side is how it presents it’s data, looking at the logs it seems that the °C is included in the state. It also seems to have an odd setpoint (2E+1). Here are some logs from changing the setpoint.

2020-01-20 12:18:13.557 [ome.event.ItemCommandEvent] - Item 'thermostat_gf_setpoint' received command 21
2020-01-20 12:18:13.560 [nt.ItemStatePredictedEvent] - thermostat_gf_setpoint predicted to become 21
2020-01-20 12:18:13.568 [vent.ItemStateChangedEvent] - thermostat_gf_setpoint changed from 2E+1 °C to 21.0 °C
2020-01-20 12:18:15.387 [ome.event.ItemCommandEvent] - Item 'thermostat_gf_setpoint' received command 22
2020-01-20 12:18:15.390 [nt.ItemStatePredictedEvent] - thermostat_gf_setpoint predicted to become 22
2020-01-20 12:18:15.398 [vent.ItemStateChangedEvent] - thermostat_gf_setpoint changed from 21.0 °C to 22.0 °C
2020-01-20 12:18:17.906 [ome.event.ItemCommandEvent] - Item 'thermostat_gf_setpoint' received command 20
2020-01-20 12:18:17.911 [nt.ItemStatePredictedEvent] - thermostat_gf_setpoint predicted to become 20
2020-01-20 12:18:17.920 [vent.ItemStateChangedEvent] - thermostat_gf_setpoint changed from 22.0 °C to 20.0 °C
2020-01-20 12:18:19.153 [ome.event.ItemCommandEvent] - Item 'thermostat_gf_setpoint' received command 19
2020-01-20 12:18:19.157 [nt.ItemStatePredictedEvent] - thermostat_gf_setpoint predicted to become 19
2020-01-20 12:18:19.166 [vent.ItemStateChangedEvent] - thermostat_gf_setpoint changed from 20.0 °C to 19.0 °C

If anyone could point me in the right direction, whether this is correcting an error in the rule or changing the systax to reflect how the item state is reported I’d be grateful.

Thanks in advance
Fred.

Just to clarify the start of the rule file includes:

var Timer boostTime = null

Thanks
Fred

I’ve also got this entry in the openhab.log when the rule is expected to trigger:

2020-01-20 12:31:18.560 [ERROR] [pse.smarthome.core.items.GenericItem] - Tried to set invalid state ON (OnOffType) on item thermostat_gf_setpoint of type NumberItem, ignoring it
2020-01-20 12:31:18.569 [ERROR] [pse.smarthome.core.items.GenericItem] - Tried to set invalid state OFF (OnOffType) on item thermostat_gf_setpoint of type NumberItem, ignoring it

Apologies for the additional posts, when I edit the first it ruins the formatting.

Thanks again,
Fred

There are a few things wrong with your rule. Do you see any validation warnings reported by VS Code or in the openhab.log when saving the file? First, you’re missing curly brackets everywhere. Second, the Item thermostat_gf_setpoint uses UoM, so your comparison is wrong. Third, there looks to be a typo in the name of the Item when you are sending the command (thermostat_gf_serpoint). Fourth, Items do not have a sendUpdate method… this should be postUpdate. Fifth, if the setpoint is less than 21°C, shouldn’t the timer be cancelled? I threw in some other stuff too :slightly_smiling_face:.

var Timer boostTime = null

rule “Heat Boots Timer”
when
    Item thermostat_gf_setpoint changed
then
    if (thermostat_gf_setpoint.state > 21|°C) {
        if (boostTime === null || boostTime.hasTerminated) {
            switch_gf_hall_heatboost.sendUpdate(ON)
            boostTime = createTimer(now.plusMinutes(60)) [|
                thermostat_gf_setpoint.sendCommand(20)
                switch_gf_hall_heatboost.postUpdate(OFF)
            ]
        }
    } else {
        boostTime?.cancel
    }
end

Thanks, this is my first rule with if statements and variables so your help is much appreciated :blush:

Fred

1 Like

Definitely check out VS Code and the openHAB extension. It will help a lot with writing and debugging your rules.