UserReadings problem

Begonnen von newb, 03 Mai 2020, 09:09:11

Vorheriges Thema - Nächstes Thema

newb

Hi, I've got a CustomReadings which pulls the ISS date and time and I've set user readings inside the device as:

attr iss userReadings joinedData {sprintf("%s,%s,%d",ReadingsVal("iss","date",0),ReadingsVal("iss","time",0),ReadingsVal("iss","duration",0))}
The sprintf command seems to get the values correctly, however the joinedData does not appear in the readings of the device when I do update on the device. The individual date, time and duration readings get updated. What am I doing wrong?

Also when I'm trying to do a reference to this joinedData reading from an AT device with [iss:joinedData] what I'm getting is the raw '[iss:joinedData]' string and not the reading value.

I'll appreciate any help. Thank you.

Icinger

Zitatattr iss userReadings joinedData {sprintf("%s,%s,%d",ReadingsVal("iss","date",0),ReadingsVal("iss","time",0),ReadingsVal("iss","duration",0))}

You are missing the trigger for your userreading.

Something like
attr iss userReadings joinedData:time.* {sprintf("%s,%s,%d",ReadingsVal("iss","date",0),ReadingsVal("iss","time",0),ReadingsVal("iss","duration",0))}
Verwende deine Zeit nicht mit Erklärungen. Die Menschen hören (lesen) nur, was sie hören (lesen) wollen. (c) Paulo Coelho

newb

#2
Thanks! On update, I can see the reading in the Event Monitor now, but the reading does not appear in the "Readings" section of the device and state of this reading is not preserved anywhere. Is this the normal behaviour of userReadings? the AT device still can't find the reading using [iss:joinedData]


rudolfkoenig

It works for me:
fhem> define iss dummy
fhem> attr iss userReadings joinedData {sprintf("%s,%s,%d",ReadingsVal("iss","date",0),ReadingsVal("iss","time",0),ReadingsVal("iss","duration",0))}
fhem> setreading iss date 2020-05-03
fhem> setreading iss time 13:39
fhem> setreading iss duration 5   
fhem> l iss joinedData
iss                  2020-05-03 13:39:59    2020-05-03,13:39,5


Note: if duration contains something, which is not a number, you get a warning in the FHEM-log, and joinedData wont be changed.
fhem> setreading iss duration 5min
2020.05.03 13:40:30 1: PERL WARNING: Argument "5min" isn't numeric in sprintf at (eval 26) line 1.
fhem> l iss joinedData
iss                  2020-05-03 13:40:30    2020-05-03,13:39,5