Ok it’s my fault cos I didn’t exactly copy/paste the rules file I will this time
i don’t want to switch off exactly when there is no ping cos that will create other
problems . I want to switch the PC & monitor off if there is no ping and when I am switching everything OFF.
rule "Auto_OFF" when
Item Pir_Stat changed from ON to OFF then
Led_B1.sendCommand(0) Led_B2.sendCommand(0) Led_B3.sendCommand(0) Led_B4.sendCommand(0)
Gl1_1.sendCommand(0) Gl1_2.sendCommand(0) Gl1_3.sendCommand(0) Gl2_1.sendCommand(0)
Gl2_2.sendCommand(0) Gl2_3.sendCommand(0) Gl2_4.sendCommand(0)
sendCommand(Psu_1, OFF) sendCommand(Psu_2, OFF) sendCommand(Psu_3, OFF)
sendCommand(Ce_Fan1, OFF) sendCommand(Ce_Fan2, OFF) sendCommand(Es30_1, OFF)
sendCommand(Es30_1, OFF) sendCommand(Es30_2, OFF) sendCommand(Es30_3, OFF)
sendCommand(Audio, OFF) sendCommand(Sldr_1, OFF) sendCommand(Iso_Trf, OFF)
sendCommand(Tv, OFF) T_Ext.sendCommand(35)
if ( Ping_PC1.state == OFF ) { sendCommand(Pc1, OFF) sendCommand(Mon_1, OFF) } end
// if ( Ping_PC2.state != "ON" && Ping_PC3.state != "ON" ) { sendCommand(W_Plugs, OFF) } end
end
So my question is, is it posible to check a switch state with if statement in the .rules file ?
If things are not working as you expect, you might have to give a bit more detail about what does happen.
It’s a bit unclear with that formatting, but your rule seems to have two end statements. I’d expect that you’d see an error report if you look in your openhab.log at rules file load time.