FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: reibuehl am 14 Oktober 2018, 13:19:12

Titel: {Gelöst] HTTPMOD stateFormat mit if/else abhängig vom Internal "code"?
Beitrag von: reibuehl am 14 Oktober 2018, 13:19:12
Ich würde gerne bei einem HTTPMOD Device stateFormat abhängig vom HTTP Status Code setzen. Wenn das Internal "code" == 200 ist, möchte ich den Wert des Readings "feed_status" als stateFormat verwenden. Für alle anderen HTTP Status Codes würde ich gerne den Status Code selbst ausgeben.

Ich hab es mit diesem Wert versucht:

attr fr24pi stateFormat {if(ReadingsVal($name,"code",0)==200) {ReadingsVal($name,"feed_status","not connected")} else {ReadingsVal($name,"code",0)}}


Da erhalte ich als state dann aber nur 0, obwohl das Internal "code" auf 200 ist.

Ich hab statt ReadingsVal auch schon ReadingsNum für "code" verwendet, das hat aber auch nichts geändert. Brauche ich für die Internal einen ganz anderen Befehl?

Gruß,
Reiner
Titel: Antw:HTTPMOD stateFormat mit if/else abhängig vom Internal "code"?
Beitrag von: Otto123 am 14 Oktober 2018, 13:31:15
Hallo Reiner,

Zitat von: reibuehl am 14 Oktober 2018, 13:19:12
Ich hab statt ReadingsVal auch schon ReadingsNum für "code" verwendet, das hat aber auch nichts geändert. Brauche ich für die Internal einen ganz anderen Befehl?
Ja :)
InternalVal -> https://commandref.fhem.de/commandref_DE.html#perl

Gruß Otto
Titel: Antw:HTTPMOD stateFormat mit if/else abhängig vom Internal "code"?
Beitrag von: reibuehl am 14 Oktober 2018, 13:50:49
Autsch! Da hätte ich auch drauf kommen müssen...

Danke Otto!