Closed mcuiobroker closed 3 weeks ago
Das Objekt val
enhält kein params
(bzw. ist dies undefined
), daher kommt Cannot read properties of undefined (reading on)
.
Versuch mal:
{
"value": "val=> {const v = JSON.parse(val || '{}'); const param = v && v.params && v.params.on; console.log(v); return v;}",
"on": "{\"id\": 1,\"src\":\"PlusPlugS-04\",\"method\":\"Switch.Set\",\"params\": {\"id\":0,\"on\":true}}",
"off": "{\"id\": 1,\"src\":\"PlusPlugS-04\",\"method\":\"Switch.Set\",\"params\": {\"id\":0,\"on\":false}}"
}
{
"value": "val=> {const v = JSON.parse(val || '{}'); if( v.params!=undefined && v.params.on!=undefined){ console.log(v); return v.params.on;}}",
"on": "{\"id\": 1,\"src\":\"PlusPlugS-04\",\"method\":\"Switch.Set\",\"params\": {\"id\":0,\"on\":true}}",
"off": "{\"id\": 1,\"src\":\"PlusPlugS-04\",\"method\":\"Switch.Set\",\"params\": {\"id\":0,\"on\":false}}"
}
Damit funktioniert es ohne Warnung. Danke.