userReading aus unixtime erstellen

Begonnen von rvideobaer, 25 Dezember 2016, 17:52:59

Vorheriges Thema - Nächstes Thema

rvideobaer

Hallo,

ich möchte ein userReading erstellen das die Unixtime aus einem Reading liest in lesbare Form z.b.  So 25.12.2016 20.15 umwandelt und als userReading ausgibt.

attr userReadings recordings_next_human  {ReadingsVal("DM_7020","recordings_next",0) ,POSIX::strftime('%a %d.%m.%Y %H:%M',localtime)}
gibt mir leider nur die Aktuelle Zeit aus. Ich weis leider nicht wie ich es so umschreiben muss das er recordings_next als qelle benutzt. Es wäre noch schön wenn die Tagesangabe Deutsch So,Mo,Di,Mi usw wäre.

Gruß Rolf
Raspberry Pi 2, HM-Uart,1x HM-LC-Sw1PBU-FM, 1x HM-RC-2-PBU-FM,1x HM-LC-SW4-DR,1x HM-LC-Sw1-Pl-DN-R1,1x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN und noch mehr

justme1968

z.b.: attr userReadings recordings_next_human  {FmtDateTime(ReadingsVal("DM_7020","recordings_next",0))}

oder eben das ReadingsVal da einsetzen wo du beim strftime das localtime stehen hast.

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

rvideobaer

Hallo,

danke für den Tip, so geht es schon mal aber die Formatierung gefällt mir nicht.
wenn ich dann versuche
recordings_next_human  { POSIX::strftime ("%a %d.%m.%Y %H:%M"), ReadingsVal("DM_7020","recordings_next",0)}
geht es leider nicht.

Gruß Rolf
Raspberry Pi 2, HM-Uart,1x HM-LC-Sw1PBU-FM, 1x HM-RC-2-PBU-FM,1x HM-LC-SW4-DR,1x HM-LC-Sw1-Pl-DN-R1,1x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN und noch mehr

justme1968

deine klammern stimmen nicht. die klammer hinter dem zeit format muss ans ende.  das sollte auch im log zu sehen sein.

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

rvideobaer

Hallo,

ich habe schon verschiedene Varianten probiert,bei;
recordings_next_human  {POSIX::strftime ("%a %d.%m.%Y %H:%M", ReadingsVal("DM_7020","recordings_next",0))}
bekomme ich diese Fehlermeldung:2016.12.26 10:23:34 1: Error evaluating DM_7020 userReading recordings_next_human: Usage: POSIX::strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) at (eval 71739) line 1.
Meine Wissen über Perl ist faktisch null, deshalb komme ich hier allein nicht weiter und bin dankbar über jede Hilfe.

Gruß Rolf
Raspberry Pi 2, HM-Uart,1x HM-LC-Sw1PBU-FM, 1x HM-RC-2-PBU-FM,1x HM-LC-SW4-DR,1x HM-LC-Sw1-Pl-DN-R1,1x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN und noch mehr

justme1968

sorry. ich habe nicht aufgepasst. da fehlt noch ein localtime:
{POSIX::strftime ("%a %d.%m.%Y %H:%M", localtime(ReadingsVal("DM_7020","recordings_next",0)))}

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

rvideobaer

Hallo,

Super jetzt past es, ich habe noch setlocale ergänzt das die Wochentage noch in Deutsch angezeigt werden:
recordings_next_human  {setlocale(LC_TIME,"de_DE.utf8");
POSIX::strftime ("%a %d.%m.%Y %H:%M", localtime(ReadingsVal("DM_7020","recordings_next",0)))}


Nochmals Vielen Dank für Deine Hilfe.

Gruß Rolf
Raspberry Pi 2, HM-Uart,1x HM-LC-Sw1PBU-FM, 1x HM-RC-2-PBU-FM,1x HM-LC-SW4-DR,1x HM-LC-Sw1-Pl-DN-R1,1x HM-TC-IT-WM-W-EU, 5x HM-CC-RT-DN und noch mehr