I’m sorry if I come off a little angry, but I’m becoming frustraited with this and a couple of other threads where I have to play 20 questions for every new reply and half of my replies and links are not being read.
At this point I have no idea what you have done, what you have working and what is not working. I’m through trying to figure problems out with only “its broken” to go on.
Here is how I would do it. If it doesn’t work post here (and for any new problem you have) at a minimum:
- relevant Things
- relevant Items
- relevant Rules
- relevant sitemap entries
- relevant logs, especially if there are errors
#!/bin/bash
INPUT22=$(/home/openhabian/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 22)
TEMP22=$(echo $INPUT22|cut -d " " -f1 | sed 's/[^0-9.]*//g')
HUM22=$(echo $INPUT22|cut -d " " -f2 | sed 's/[^0-9.]*//g')
INPUT4=$(/home/openhabian/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 4)
TEMP4=$(echo $INPUT4|cut -d " " -f1 | sed 's/[^0-9.]*//g')
HUM4=$(echo $INPUT4|cut -d " " -f2 | sed 's/[^0-9.]*//g')
ADDW=5.00
if [ "$1" = "HUM22" ]; then
echo $HUM22 $ADDW | awk '{print $1 + $2}'
fi
if [ "$1" = "TEMP22" ]; then
echo $TEMP22
fi
if [ "$1" = "HUM4" ]; then
echo $HUM4 $ADDW | awk '{print $1 + $2}'
fi
if [ "$1" = "TEMP4" ]; then
echo $TEMP4
fi
I’m assuming that this string returns a parsable number with no stray characters and no leading or trailing white space.
Things:
exec:command:dht22temp4 [command="/srv/openhab2-conf/scripts/AM2302sensor.sh TEMP4", interval=120, timeout=10]
exec:command:dht22hum4 [command="/srv/openhab2-conf/scripts/AM2302sensor.sh HUM4", interval=110, timeout=10]
Items:
Number TEMP_Keller4 "Temp 4 Keller [%.1f]" <temperature> (gTemp) {channel="exec:command:dht22temp4:output"}
Number LUFT_Keller4 "Luftf. 4 Keller [%.1f]" <temperature> (gTemp) {channel="exec:command:dht22hum4:output"}
Rule:
rule "test123"
when
Item TEMP_Keller4 received update
then
logInfo("Test", "Bla: " + TEMP_Keller4.state.toString)
var tempPlusFive = (TEMP_Keller4.state as Number) + 5
logInfo("Test", "Plus 5: + tempPlusFive)
end
Sitemap:
Text item=TEMP_Keller4
If for some reason the script is not returning a value that can be parsed into a String (e.g. contains white space) see this posting for how to trim out the whitespace using a JavaScript transform.