Hello at all
i just started with openhab 3 days ago and i tried an example:
enter link description here
It shows me the whole Data-String but not the weight and temperature separately how it should…
Can somebody help me please?
Rules:
rule "Arduino"
when
Item Arduino received update
then
var String ArduinoUpdate = Arduino.state.toString.trim
var int weightStartsOn = ArduinoUpdate.indexOf(“weight:”) + “weight:”.length
var String weight = ArduinoUpdate.mid(weightStartsOn, ArduinoUpdate.indexOf(’_’)-weightStartsOn)
Arduino_weight.postUpdate(weight)
var int temperatureStartsOn = ArduinoUpdate.indexOf("temperature:") + "temperature:".length
var String temperature = ArduinoUpdate.mid(temperatureStartsOn, ArduinoUpdate.indexOf(';')-temperatureStartsOn)
Arduino_temperature.postUpdate(temperature)
end
Item:
String Arduino “Arduino [%s]” (arduino) {serial="/dev/ttyACM0"}
String Arduino_weight "Weight [%s]"
String Arduino_temperature “Temperature [%s]”
Sitemap:
sitemap demo label=“demo”
{
Frame label=“Data” {
Frame{
Text item=Arduino
Text item=Arduino_temperature
Text item=Arduino_weight
}
}
}