HTTPMOD Strings schreiben

Begonnen von Muschelpuster, 17 September 2021, 23:17:08

Vorheriges Thema - Nächstes Thema

Muschelpuster

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
fhem @ ZBOX mit 1,6MHz Celeron, 4GB RAM & 120GB SSD mit Debian Bullseye # MiLight # Homematic via CCU3 # W&T WebIO # Rademacher DuoFern # ESPeasy # logdb@mysql # configdb@mysql # Shelly @ MQTT2 # go-eCharger mit PV-Überschussladung via DOIF

StefanStrobel

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

Muschelpuster

Danke Stefan,

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

Niels
fhem @ ZBOX mit 1,6MHz Celeron, 4GB RAM & 120GB SSD mit Debian Bullseye # MiLight # Homematic via CCU3 # W&T WebIO # Rademacher DuoFern # ESPeasy # logdb@mysql # configdb@mysql # Shelly @ MQTT2 # go-eCharger mit PV-Überschussladung via DOIF