FHEM Forum

FHEM => Sonstiges => Thema gestartet von: Muschelpuster am 17 September 2021, 23:17:08

Titel: HTTPMOD Strings schreiben
Beitrag von: Muschelpuster am 17 September 2021, 23:17:08
Moin zusammen,

ich muss ein Boolean-Feld in meinem Ziel ändern. Da werden im HTTP-Get-Befehl nur die Strings true und false akzeptiert. Das HTTPMOD sagt mir aber, dass es nur numerische Werte akzeptiert. Nun könnte ich auch mit 0 und 1 arbeiten, denn so gibt es mir das Gerät eh zurück, doch das wird eben im set nicht akzeptiert. Und wenn ich jetzt ein Replace 0->false und 1->true mache, dann greift das ja über das ganze Mod, wenn ich das richtig verstanden habe, was ja auch etwas zu global wäre. Ich dürfte die Modifikation ja nur beim Schreiben machen.

Niels
Titel: Antw:HTTPMOD Strings schreiben
Beitrag von: StefanStrobel am 20 September 2021, 19:54:47
Hallo Niels,

dafür gibt es ein Attribut:
Zitat
(get|set)[0-9]*TextArg
For a get command this defines that the command accepts a text value after the option name. By default a get command doesn't accept optional values after the command name. If TextArg is specified and a value is passed after the get name then this value can then be used in a request URL, header or data as replacement for $val or in a user defined replacement that uses the internal "value" ($hash->{value}).
If used for a set command then it defines that the value to be set doesn't require any validation / conversion. The raw value is passed on as text to the device. By default a set command expects a numerical value or a text value that is converted to a numeric value using a map.

Gruss
   Stefan
Titel: Antw:HTTPMOD Strings schreiben
Beitrag von: Muschelpuster am 20 September 2021, 22:38:33
Danke Stefan,

das werde ich mit diesem Hinweis sicher auch umsetzen können.

Niels