dht22 and trigger not in log

Begonnen von kroonen, 10 Februar 2015, 22:30:55

Vorheriges Thema - Nächstes Thema

kroonen

Hi,

I made a shell script to read a dht22 and put it into fhem as cul_ws. It looks like it works a little, but in the log, I don't get a value. The values in them are correct. any idea what goes wrong?


2015-02-10_22:11:47 Schuurtemp
2015-02-10_22:11:54 Schuurtemp
2015-02-10_22:12:46 Schuurtemp
2015-02-10_22:18:49 Schuurtemp
2015-02-10_22:22:12 Schuurtemp

#!/bin/sh
datum=$(date +%Y-%m-%d)
tijd=$(date +%H:%M:%S)
temp=`/usr/local//bin/loldht 7 | cut -d " " -f7 | awk '{printf "%.1f\n", $1}'`
hum=`/usr/local//bin/loldht 7 | cut -d " " -f3 | awk '{printf "%.1f\n", $1}'`
/opt/fhem/./fhem.pl localhost:7072 'trigger Schuurtemp; {\
  $defs{Schuurtemp}{STATE}="T: '$temp' H: '$hum'";;\
  $defs{Schuurtemp}{READINGS}{temperature}{VAL}="'$temp'";;\
  $defs{Schuurtemp}{READINGS}{temperature}{TIME}="'$datum' '$tijd'";;\
  $defs{Schuurtemp}{READINGS}{humidity}{VAL}="'$hum'";;\
  $defs{Schuurtemp}{READINGS}{humidity}{TIME}="'$datum' '$tijd'"}'

rudolfkoenig

You get what you asked for: "trigger Schuurtemp" generates exactly the events you see in the log.
You should not use $defs{XX}{READINGS} in your FHEM command (not even in your FHEM-module), as it wont generate events, and the generic event-on-*-reading attributes do not apply. Use the setreading FHEM command instead oder the readingsSingleUpdate function.
They generate events on their own, the use of trigger ist not needed.
Setting STATE directly is not recommended either, set the state reading via setreading instead, state is mapped automatically to STATE, and you have the possibility to modify STATE via stateFormat.