@udo1toni
Hallo Udo,
Danke für dein feedback.
Ich hoffe ich habe dich richtig verstanden. Das Add-On "Exec transformation" habe ich installiert.
Meine dazugehörige Things-Datei sieht so aus:
Code: Alles auswählen
Thing exec:command:my_user "Angemeldet ist" @ "Buero"
[command="/bin/bash /etc/openhab/scripts/test.sh", interval=120, timeout=30, transform="REGEX((.*?))"]
Thing exec:command:cpu_temp "OH2-PI Temperatur" @ "Buero"
[command="/bin/bash /etc/openhab/scripts/cpu_temp.sh", interval=120, timeout=30, transform="REGEX((.*?))"]
Thing exec:command:cpu_temp_command "PI4 Temperatur.:" @ "Buero"
[command="echo \"scale=2;($(/bin/cat /sys/class/thermal/thermal_zone0/temp)/1000)\" | bc", interval=120, timeout=30, transform="REGEX((.*?))"]
Ein Item daz:
Code: Alles auswählen
String Dummy "Versucherle [%s]" (gPower,gPower1) ["WallSwitch", "Point_Control_Switch"] {channel="exec:command:cpu_temp:output"}
Das Item wird auch mit Werten befüllt.
Das Script (cpu_temp.sh) dazu sieht so aus:
Code: Alles auswählen
#!/bin/bash
INPUT=$(/bin/cat /sys/class/thermal/thermal_zone0/temp)
TEMP=$(echo "scale=2; $INPUT / 1000" | bc)
echo $TEMP
und läuft:
Code: Alles auswählen
hab3@oh3ssd:/etc/openhab/scripts $ ./cpu_temp.sh
40.89
hab3@oh3ssd:/etc/openhab/scripts $
Berechtigungen:
Code: Alles auswählen
hab3@oh3ssd:/etc/openhab/scripts $ ls -alF
insgesamt 48
drwxrwxr-x 2 openhab openhab 4096 23. Apr 18:11 ./
drwxrwxr-x 16 openhab openhab 4096 23. Dez 2021 ../
-rw-rw-r-- 1 openhab openhab 193 27. Jul 2018 cpuRasPi_Office_temp.sh
-rw-rw-r-- 1 openhab openhab 82 2. Jul 2018 cpu_temp1.sh
-rwxrwxr-x 1 openhab openhab 123 23. Feb 2020 cpu_temp.sh*
-rw-rw-r-- 1 openhab openhab 148 20. Mai 2021 fahrenheit.sh
-rw-rw-r-- 1 openhab openhab 176 17. Jul 2018 mount_check.sh
-rw-rw-r-- 1 openhab openhab 163 18. Sep 2019 mountusb.sh
-rw-rw-r-- 1 openhab openhab 166 2. Jul 2018 'Mount USB-Stick.txt'
-rw-rw-r-- 1 openhab openhab 1326 9. Aug 2020 oh_uptime.sh
-rw-rw-r-- 1 openhab openhab 236 12. Dez 2021 readme.txt
-rwxrwxr-x 1 openhab openhab 237 4. Jul 2022 test.sh*
Hab ich Infos vergessen ?