This page last changed on Sep 22, 2014 by schaaf75.

Hoi,
I started with programming in rules, and have a problem i can't solve yet.

I have a virtual divice with
Command: Btn_up: on, off, status
Command: Vent_value: status
Sensor: Sensor_Up: status_up as switch
Sensor: Sensor_VALUE_custum: Vent_value as custom
custum state items: name:nul value:0 name:een value:1

I place some images in de design part on the Sensor_VALUE_custum
So far so good.

Know i'd like to toggle from value 0 to 1 and 1 to 0.
Later i will have 4 states for my ventilation system and turn on and of some relays with time delay.

I made a virtual switch with the Btn_up: on, off, status
I wrote the following rule:

-----------------------------------------------------------------
package org.openremote.controller.model.event

global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
global org.openremote.controller.statuscache.LevelFacade levels;
global org.openremote.controller.statuscache.RangeFacade ranges;
import org.openremote.controller.protocol.*;

rule "Up_Vent0"

when
Event (source == "Sensor_UP", value == "on" )

then

System.out.println( "Ventilatie BTN UP" );
execute.command( "BTN_UP_OFF" );
execute.command( "Vent_Value" , 1 );
System.out.println( "set 0->1==" );

end

-----------------------------------------------------------------
This part is working, de following part doesn't
I want an action on pushing on the switch button AND do some different actions depents on the Sensor_VALUE_custum

-----------------------------------------------------------------
package org.openremote.controller.model.event

global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
global org.openremote.controller.statuscache.LevelFacade levels;
global org.openremote.controller.statuscache.RangeFacade ranges;
import org.openremote.controller.protocol.*;

rule "Up_Vent0"

when
Event (source == "Sensor_UP", value == "on" )
Event (source == "Sensor_VALUE_custum", value == 0 )

then

System.out.println( "Ventilatie BTN UP" );
execute.command( "BTN_UP_OFF" );
execute.command( "Vent_Value" , 1 );
System.out.println( "set 0->1" );

end

rule "Up_Vent1"

when
Event (source == "Sensor_UP", value == "on" )
Event (source == "Sensor_VALUE_custum", value == 1 )

then

System.out.println( "Ventilatie BTN UP" );
execute.command( "BTN_UP_OFF" );
execute.command( "Vent_Value" , 0 );
System.out.println( "set 1->0" );

end
-----------------------------------------------------------------

Kind regards

Custom sensors hold strings so if your "Sensor_VALUE_custom" is updated then the following should work

Event (source == "Sensor_VALUE_custum", value == "0" )

Event (source == "Sensor_VALUE_custum", value == "1" ) etc

Posted by aktur at Sep 23, 2014 17:49
Document generated by Confluence on Jun 05, 2016 09:38