Autor Thema: UserReadings problem  (Gelesen 1213 mal)

Offline newb

  • New Member
  • *
  • Beiträge: 10
UserReadings problem
« am: 03 Mai 2020, 09:09:11 »
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.

Offline Icinger

  • Developer
  • Hero Member
  • ****
  • Beiträge: 1392
Antw:UserReadings problem
« Antwort #1 am: 03 Mai 2020, 09:39:27 »
Zitat
attr 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

Offline newb

  • New Member
  • *
  • Beiträge: 10
Antw:UserReadings problem
« Antwort #2 am: 03 Mai 2020, 10:03:51 »
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]

« Letzte Änderung: 03 Mai 2020, 10:10:21 von newb »

Offline rudolfkoenig

  • Administrator
  • Hero Member
  • *****
  • Beiträge: 23852
Antw:UserReadings problem
« Antwort #3 am: 03 Mai 2020, 13:42:46 »
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

 

decade-submarginal