Refer to Items by value or variable in Rules? (Code portability.)

I’m going to leave these here:

For this second link also look at ben_jones12’s post a little down.

The tl;dr of it is don’t do this. There are much much better ways to reuse the same code for different Items.

But because some people simply must suffer this sort of pain on their own…

I think you can just do:

val physical_relay1 = HardWire_20AMP_Relay
val physical_relay2 = Safety_20AMP_Relay

No quotes.

Furthermore, your rule is incorrect syntax.

    if(physical_relay1.state == OFF) {
        Kitchen_Heat_Power_STATUS.postUpdate(OFF)
    }
    else if(pyhsical_relay1.state == ON) {
        physical_relay2.sendCommand(OFF)
    }

NOTE: do you really mean to check if physical_relay1’s state is ON in the else if? If not then that clause will never be executed. If you really do mean OFF then:

    if(physical_relay1.state == OFF){
        Kitchen_Heat_Power_STATUS.postUpdate(OFF)
        physical_relay2.sendCommand(OFF)
    }