# \[SOLVED\] Heating rule optimization

**URL:** <https://community.openhab.org/t/solved-heating-rule-optimization/73085>\
**Category:** Scripts & Rules\
**Created:** [April 24, 2019, 8:04pm UTC](https://community.openhab.org/t/solved-heating-rule-optimization/73085 "2019-04-24T20:04:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaka\_Smode](https://community.openhab.org/letter_avatar_proxy/v4/letter/j/ecc23a/32.png) [@Jaka\_Smode](https://community.openhab.org/u/Jaka_Smode)\
**Post date:** [April 24, 2019, 8:04pm UTC](https://community.openhab.org/t/solved-heating-rule-optimization/73085/1 "2019-04-24T20:04:38Z")

</div>

Hello,  
I have a question, is there any way I can optimize my rule for heating to have a one degree offset?  
Other recommendations are welcomed.

My rule:

```
rule "ogrevanje"
when
        Item temperatura changed or Item Temperature changed
then
        var double termostat=(temperatura.state as DecimalType).doubleValue
        var double temp=(Temperature.state as DecimalType).doubleValue
        if(termostat>temp){
                pec.sendCommand(ON)
        }else{
                pec.sendCommand(OFF)
        }
end

```

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [April 24, 2019, 8:19pm UTC](https://community.openhab.org/t/solved-heating-rule-optimization/73085/2 "2019-04-24T20:19:18Z")

</div>

> [@Jaka\_Smode](#):
>
> to have a one degree offset?

You mean hysteresis? (a do-nothing band)

```php
       if(termostat>temp){
                pec.sendCommand(ON)
        }else if (termostat + 1.0 < temp) {
                pec.sendCommand(OFF)
        }

```
