Hello Marlan,
Thank you for reaching out to our Community Forum.
No, our API does not support text as variable values. It can support numbers in the form of a string, but not text itself. Nonetheless, the Context field of a Dot does support Text, so if you want to send an OPEN or CLOSE, then you’ll have to include that in the Context of the Dot being sent. For more information on this, please view this arcticle.
On to how it can be done, in this case, you can use the Decoder (or Payload Format) to change the format of the payload being sent to Ubidots. Also, you should map the OPEN or CLOSED to 1 or 0, respectively.
I hope you’re well and thank you for reaching out.
You can send strings as part of an Ubidots dot inside a context object, for example:
{
"value":1,
"context":{
"state":"open"
}
}
Regarding the integration with the TTS network server, you can modify the decoder for your device in a way that its payload contains a dot for the variable of interest for example this decoder:
function Decoder (bytes, port) {
var decoded = {}
for (var i = 0; i < bytes.length; ) {
var channel_id = bytes[i++]
var channel_type = bytes[i++]
// BATTERY
if (channel_id === 0x01 && channel_type === 0x75) {
decoded.battery = bytes[i]
i += 1
}
// PIR
else if (channel_id === 0x03 && channel_type === 0x00) {
decoded.pir = bytes[i] === 0 ? {'value':0, context:{'state':'normal'}} : {'value':1, context:{'state':'trigger'}};
i += 1
}
// DAYLIGHT
else if (channel_id === 0x04 && channel_type === 0x00) {
decoded.daylight = bytes[i] === 0 ? {'value':0, context:{'state':'dark'}} : {'value':1, context:{'state':'light'}};
i += 1
} else {
break
}
}
return decoded
}
Originally, the decoding part of the PIR section suggested by the manufacturer was like this.