yilmazogras / openhab

Automatically exported from code.google.com/p/openhab
0 stars 0 forks source link

sendCommand TOGGLE #519

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. Feature Description

Send a toggle command to an Item

2. Example Use Case

To toggle a Switch if a Contact has been changed.

Example to reduce a rule from:

<code>
rule "Switchtest"
    when
        Item Contact_GF_Kueche_Decke changed to OPEN
    then
        if (Licht_GF_Kueche_Decke.state == OFF)
            sendCommand(Licht_GF_Kueche_Decke, ON)
        else
            sendCommand(Licht_GF_Kueche_Decke, OFF)             
end
</code>

to:

<code>
rule "Switchtest"
    when
        Item Contact_GF_Kueche_Decke changed to OPEN
    then
        sendCommand(Licht_GF_Kueche_Decke, TOGGLE)              
end
</code>

Original issue reported on code.google.com by dercas...@googlemail.com on 17 Nov 2013 at 11:14

GoogleCodeExporter commented 9 years ago
I didn't introduce TOGGLE as a command as it is somewhat not deterministic - 
you do not know, what status the device will be in afterwards. Sending ON or 
OFF to the device is a much better approach (even if the rules are slightly 
more complex then).

Original comment by kai.openhab on 18 Nov 2013 at 8:07