Skip to content
Snippets Groups Projects
Commit 169aba33 authored by René Schöne's avatar René Schöne
Browse files

Workaround for Switch synchronization with openHAB.

- change state representation of SwitchItem to ON/OFF
- resolves issue #20
parent 65c28eb6
Branches
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@ aspect ItemHandling {
eq ColorItem.getStateAsString() = getState().toString();
eq DateTimeItem.getStateAsString() = getState().toString();
eq ItemWithBooleanState.getStateAsString() = Boolean.toString(getState());
eq SwitchItem.getStateAsString() = getState() ? "ON" : "OFF";
eq ItemWithDoubleState.getStateAsString() = Double.toString(getState());
eq ItemWithStringState.getStateAsString() = getState();
......@@ -67,6 +68,13 @@ aspect ItemHandling {
public void ItemWithBooleanState.setStateFromString(String value) {
this.setState(Boolean.parseBoolean(value));
}
public void SwitchItem.setStateFromString(String value) {
switch (value) {
case "ON": this.setState(true); break;
case "OFF": this.setState(false); break;
default: super.setStateFromString(value);
}
}
public void ItemWithDoubleState.setStateFromString(String value) {
this.setState(Double.parseDouble(value));
}
......
Color Item: id="Go1_item" label="Go 1" state="0,0,0" category="Lighting" ;
Switch Item: id="Rule_Switch" state="false" ;
Switch Item: id="Rule_Switch" state="OFF" ;
Number Item: id="Color_Manual_Slider" state="0.0" ;
Number Item: id="watch_acceleration_x" label="Watch Acceleration X" state="0.0" ;
Number Item: id="watch_acceleration_y" label="Watch Acceleration Y" state="0.0" ;
......
......@@ -12,7 +12,7 @@ Color Item: id="iris1_item" label="Iris 1" state="253,0,0" category="Lighting" m
Number Item: id="moto_360_brightness" label="Moto 360 Brightness" state="0.0" category="Brightness" ;
Number Item: id="polar_brightness" label="Polar Brightness" state="0.0" category="Brightness" ;
String Item: id="samsung_brightness" label="Samsung Brightness" state="" category="Brightness" ;
Switch Item: id="Rule_Switch" state="false" ;
Switch Item: id="Rule_Switch" state="OFF" ;
Number Item: id="Color_Manual_Slider" state="0.0" ;
Number Item: id="watch_acceleration_x" label="Watch Acceleration X" state="6.264883611883931E-10" ;
Number Item: id="watch_acceleration_y" label="Watch Acceleration Y" state="1.5765462769316607E-19" ;
......
......@@ -17,5 +17,6 @@ Player Item : id="player1" label="a Player Item" state="jkl" topic="item/str/pla
RollerShutter Item : id="rollerShutter1" label="a RollerShutter Item" state="false" topic="item/str/rs1/state";
String Item : id="string1" label="a String Item" state="mno" topic="item/str/string1/state";
Switch Item : id="switch1" label="a Switch Item" state="true" topic="item/bool/switch1/state";
Switch Item : id="switch2" label="a second Switch Item" state="OFF" topic="item/bool/switch2/state";
Item : id="default1" label="a Default Item" state="pqr" topic="item/str/default1/state";
Influx: host="localhost" ;
......@@ -9,11 +9,12 @@ Player Item: id="player1" label="a Player Item" state="jkl" topic="item/str/play
Number Item: id="number1" label="a Number Item" state="456.0" topic="item/double/number1/state" ;
RollerShutter Item: id="rollerShutter1" label="a RollerShutter Item" state="false" topic="item/str/rs1/state" ;
String Item: id="string1" label="a String Item" state="mno" topic="item/str/string1/state" ;
Switch Item: id="switch1" label="a Switch Item" state="true" topic="item/bool/switch1/state" ;
Switch Item: id="switch1" label="a Switch Item" state="ON" topic="item/bool/switch1/state" ;
Switch Item: id="switch2" label="a second Switch Item" state="OFF" topic="item/bool/switch2/state" ;
Group: id="my-first-group" items=["color1", "contact1", "image1", "location1"] aggregation="AND" ("ON", "OFF") ;
Group: id="my-second-group" items=["datetime1", "default1"] ;
Group: id="my-third-group" items=["dimmer1", "player1"] ;
Group: id="my-empty-group" ;
Group: id="Unknown" items=["number1", "rollerShutter1", "string1", "switch1"] ;
Group: id="Unknown" items=["number1", "rollerShutter1", "string1", "switch1", "switch2"] ;
Mqtt: incoming="ppc3/" outgoing="oh2/in/" host="localhost" ;
Influx: host="localhost" ;
......@@ -10,7 +10,7 @@ Number Item: id="number1" label="a Number Item" state="456.0" topic="item/double
RollerShutter Item: id="rollerShutter1" label="a RollerShutter Item" state="false" topic="item/str/rs1/state" ;
Activity Item: id="activity" ;
String Item: id="string1" label="a String Item" state="mno" topic="item/str/string1/state" ;
Switch Item: id="switch1" label="a Switch Item" state="true" topic="item/bool/switch1/state" controls=["rollerShutter1"] ;
Switch Item: id="switch1" label="a Switch Item" state="ON" topic="item/bool/switch1/state" controls=["rollerShutter1"] ;
Group: id="my-first-group" items=["color1", "contact1", "image1", "location1"] aggregation="AND" ("ON", "OFF") ;
Group: id="my-second-group" items=["datetime1", "default1"] ;
Group: id="my-third-group" items=["dimmer1", "player1"] ;
......
Thing: id="min-thing" type="min-thing-type" ;
Thing: id="max-thing" label="Max Thing" type="max-thing-type" channels=["min-channel", "max-channel"] ;
Number Item: id="min-item" state="0.0" ;
Switch Item: id="max-item" label="Item with all members set" state="true" category="not used" topic="items/max" controls=["min-item"] metaData={"one":"true", "zero":"false"} ;
Switch Item: id="max-item" label="Item with all members set" state="ON" category="not used" topic="items/max" controls=["min-item"] metaData={"one":"true", "zero":"false"} ;
Group: id="min-group" ;
Group: id="max-group" groups=["min-group"] items=["min-item", "max-item"] aggregation="AND" ("one", "two") ;
ThingType: id="min-thing-type" ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment