Sending downlink using ACTION

Hi all,

I am testing the capabilities of a Milesight (formerly Ursalink) UC1114 Lora Remote I/O device and have successfully used analysis example “Sending downlink using dashboard” to control a relay on the UC1114 to switch ON/OFF. However, as the UC1114 has two digital inputs, I would like to use a motion sensor to control the relay by using an ACTION to run an analysis e.g. download environment variable ‘form_payload’ to activate the relay. I have tried to modify the “Sending downlink using dashboard” analysis to perform this action but the script must be run by a dashboard widget and my knowledge of Node.js LTS or Python 3.0 is very limited. When I run the analysis from an action, I get “Missing “form_payload” in the data scope.” in the console window.

How I can adapt the example analysis to perform the intended action?

Thanks in advance.

Kind Regards,
Michael Fleming

1 Like

Hi Michael,

If I understood correctly your scope, you need to every time the motion sensor sends a command, activate an action which will trigger an analysis?

If so, you can easily watch for a variable coming from that device, (e.g. set up a action to watch for presence = true). When you set an action to watch for a variable it will be triggered when one variable meets certain conditions. If your device has sent data and the variables are meeting those conditions, this action will be triggered.

Re: How do I encode a text string e.g. “relay2on” into a download payload variable to make use of this feature?

Using JS:

const myString = "This is my string to be encoded/decoded";
const encoded = new Buffer(myString).toString('hex'); // encoded === 54686973206973206d7920737472696e6720746f20626520656e636f6465642f6465636f646564

Using any encoder website:

1 Like

For UC1114 forget the comments in manual ie “you can send commands down”. Much simpler to use UL and Downlink protocol. The code to switch relays on and off is

Output 1
09 01 00 (off)
09 01 01 (on)

Output 2
0A 01 00 (off)
0A 01 01 (on)

1 Like

Hi Dayne,

Thanks for the info. I use those payloads with example analysis “Sending download using dashboard” to control the relay state. However, there is some ‘entanglement’ between the two Push Button widgets set up to switch each relay ON/OFF. Not a showstopper but would be nice to understand why this happens.

I figured out how to ‘message’ the UC1114 to use device specific IF-THEN behaviour commands so have more options to control the output e.g. If ‘message’ received then activate Relay 1 for 10 mins.

The only thing remaining to figure out is how to control the output depending on digital input status (high/low). I tried to modify the example analysis but ‘form_payload’ is missing when run from an action. It may be possible to use the device Configuration Parameters feature (set parameters and retrieve them later by making a request from the device) but have yet to explore this feature.

Regards,

Mike

1 Like

Hi Mike, I changed analysis to use ‘payload’ instead of frm_payload, since payload is already included. I can send you my analysis on Monday if you want. For widget I used a drop down box to send it. I haven’t tried via an action yet. (It took me a while to figure out how to make it work- a few simple things that needed to be changed in various places, so happy to help)

1 Like