Receiving Commands

When in the Web App you click on a button in the device widget or issue a voice command through Alexa or a device status gets changed through an Action that command will be immediately sent to the device through the persistent communication channel it has with ChipChop.

The command format is a JSON object containing few bits of information that your device needs to parse and decide how to act on.
In case that your device is not connected to ChipChop at the time you have issued the command it will be saved in the device database and next time your little gadget connects to ChipChop it will be automatically forwarded.

This is a useful feature if you maybe have devices spending most of their time in deep sleep to preserve battery juice and only occasionaly connect to send their status and check if there are any commands waiting for them.


You can find examples for every device and its component in the Dev Console > Devices

Here is a "command" JSON example event sent to the device: {"status":"remote_command","target":"led_1","value":"ON","command_time":1668870710026,"timestamp":1668870714611}

Commands JSON explained
status
remote_command
target
The target normaly refers to a specific component in your device that you want to change the state of.
For example you could be sending a "ON" command to the "LED_1" component

You can also target the entire device in which case the target value will be set to any
This is also the only option when sending commands to a group of devices
value
The command value you are sending to the device

Can be a string or a number
timestamp
The ChipChop server timestamp in milliseconds formatted to match the correct time in the timezone specified for your device.
command_time
The timestamp in milliseconds when this command was issued.

The timestamp is formatted to match the correct time in the timezone specified for your device.

By calculating the difference between the server's "timestamp" and "command_time" you can figure out how "fresh" this command is and should your device react to it.
Normally the difference will be 0 (zero) meaning that the command was issued and sent at the same time