Dear community,
I need some advice: I have a script that results in a string:
bash /etc/openhab2/scripts/vclient.sh
Aussentemperatur:
-3.300000 Grad Celsius
Pufferspeichertemperatur:
40.599998 Grad Celsius
Warmwassertemperaturoben:
48.900002 Grad Celsius
Warmwassersolltemperatur:
50.000000 Grad Celsius
Zirkulationspumpe:
0
Raumsolltemperaturnormal:
22.000000 Grad Celsius
RaumsolltemperaturreduzierterBetrieb:
16.000000 Grad Celsius
NeigungderHeizkennlinie:
0.500000
NiveauderHeizkennlinie:
5.000000
VorlauftemperaturHK2:
39.900002 Grad Celsius
VorlauftemperaturSek:
41.200001 Grad Celsius
RuecklauftemperaturSek:
37.799999 Grad Celsius
VorlauftemperaturPrimaer:
3.800000 Grad Celsius
RuecklauftemperaturPrimaer:
0.700000 Grad Celsius
I created items with the same name as the lines with ā:ā e.g. Aussentemperatur.
I tried to create a rule that splits the string into several values using an array:
rule "heizung alle 5 minuten"
when
Time cron "0 */1 * ? * *"
then
var List<String> array2 = new ArrayList
val results = executeCommandLine("/etc/openhab2/scripts/vclient.sh",5000)
val array = results.toString.split("\n|\r\n")
array.forEach[ value |
if (value.toString.contains("Grad")) {
array2 = value.toString.split(" ").get(0)
}
]
postUpdate(HeizungAussentemperatur,array2.get(0))
postUpdate(Pufferspeichertemperatur,array2.get(1))
postUpdate(Warmwassertemperaturoben,array2.get(2))
postUpdate(Zirkulationspumpe,array2.get(3))
postUpdate(Raumsolltemperaturnormal,array2.get(4))
postUpdate(RaumsolltemperaturreduzierterBetrieb,array2.get(5))
postUpdate(NeigungderHeizkennlinie,array2.get(6))
postUpdate(NiveauderHeizkennlinie,array2.get(7))
postUpdate(VorlauftemperaturHK2,array2.get(8))
postUpdate(VorlauftemperaturSek,array2.get(9))
postUpdate(RuecklauftemperaturSek,array2.get(10))
postUpdate(VorlauftemperaturPrimaer,array2.get(11))
postUpdate(RuecklauftemperaturPrimaer,array2.get(12))
//logInfo("Exec", "Results from vclient fuer Aussentemperatur: " + results)
//postUpdate(HeizungAussentemperatur,results)
end
Currently my log file shows:
2019-12-27 15:39:00.009 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'heizung alle 5 minuten': An error occurred during the script execution: null
Is there an easier way to handle this? Maybe an array is not the best.
Thank you.
Michael