My http bindings asks a python script ( garage door opener script) which returns the status:
request :
String GarageStatusLeft2 "[%s]" <garage> {http="<[http://192.168.1.55:8888/st?id=left:1000:REGEX((.*))]"}
return d.last_state
The rule says
rule garageStatusLeft2
when
Item GarageStatusLeft2 received update
then
if (GarageStatusLeftDisp2.state.toString.toUpperCase != GarageStatusLeft2.state.toString.toUpperCase) {
GarageStatusLeftDisp2.postUpdate(GarageStatusLeft2.state.toString.toUpperCase);
}
end
This works. Now I would like to show the status along with the status date and time . So I have updated the python script to return:
return d.last_state + " # " + last_time
Return example : closed # 2018-05-01 07:57:13
I have changed the rule:
rule garageStatusLeft2
when
Item GarageStatusLeft2 received update
then
# val GarageStatusLeft3 = GarageStatusLeft2.split("#")
val GarageStatusLeft4 = GarageStatusLeft2.get(0)
val GarageStatusLeft5 = GarageStatusLeft2.get(1)
if (GarageStatusLeftDisp2.state.toString.toUpperCase != GarageStatusLeft4.state.toString.toUpperCase) {
GarageStatusLeftDisp2.postUpdate(GarageStatusLeft4.state.toString.toUpperCase);
}
end
I know that it is a very often asked question, but I have tried several answers without success:
- val GarageStatusLeft3 = GarageStatusLeft2.split("#")
gives errors (split is unknown) - val GarageStatusLeft4 = GarageStatusLeft3.get(0)
gives errors âRule âgarageStatusLeft2â: âgetâ is not a member of 'org.eclipse.smarthome.core.library.items.StringItemâ.
I am a Python and openhab begineer. I have read that using json may help, but I donât know how.
Any help or example is welcomed.
Gilles94