Hi i have an error of status switch, the result is UNDEF
The thing at the request reply me 0 or 1, and in the JS a transform in ON or OFF.
I created a second Channel to only read the status and we work correctly.
where is my error?
Thing
UID: http:url:RadianteWc23p
label: Radiante Bagno Ospiti 23p
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://url/ApiService/v3/
delay: 0
stateMethod: GET
refresh: 5
commandMethod: POST
contentType: application/json
timeout: 3000
bufferSize: 2048
channels:
- id: TemperaturaAmbienteWC23
channelTypeUID: http:string
label: Radiante WC 23p - Temperatura Ambiente
description: null
configuration:
mode: READONLY
stateExtension: getStatus?username=lli&userpass=Lli&1=BB-01-TERM3
- id: RadianteWc23pSwitch
channelTypeUID: http:string
label: Radiante Bagno Ospiti 23p - Switch
description: ""
configuration:
onValue: '{"setGuestFan":1}'
mode: WRITEONLY
offValue: '{"setGuestFan":0}'
stateExtension: getStatus?username=lli&userpass=Lli&p1=BB-01-TERM3
commandExtension: sendDeviceCommand?username=liguori&userpass=Liguori&device=BB-01-TERM3&commands=%2$s
- id: test
channelTypeUID: http:string
label: test
description: ""
configuration:
mode: READONLY
stateExtension: getStatus?username=lli&userpass=Lli&p1=BB-01-TERM3
md-readCurrentFan.js
(function(val){
var n = JSON.parse(val).value[0][2];
var m = JSON.parse(n).setGuestFan;
var reply = "";
if (m == "1") reply = "ON";
if (m == "0") reply = "OFF";
return reply;
})(input);
Item switch is set
Profile: JS
Javascript filename: md-readCurrentFan.js