Switch Node.Question

workflow
#1

Switch Node is a method we try to establish our payload read with
The payload have a section that specify four distinct addresses
Each address is associated with a data string that need to be read separately into device state attributes.

The Function Block section that designate the four addresses is specified in the following manner:

payload.data.body.ChaNum1=parseInt(fullString.substring(1, 2),16);
payload.data.body.ChaNum2=parseInt(fullString.substring(3, 4),16);

The following work flow was set up to create the four addresses and associated Device States

The switch was set up with the following case templates:

Under each case template all device states have the same configuration:
image

How should each device state differentiate from one to another? What is your recommendation?

#2

Hi there,

I previously suggested the Switch Node for the functionality to perform specific actions or mutate data based on the Channel Number. However, if you only need to report state data to one device, you can likely remove your Switch and have one path to report state, as you are reporting to the same device from four workflow paths. If you were to have four devices, one for each channel, a Switch Node would be ideal for reporting to those 4 different devices.

Thanks!
Julia

#3

understood, thank you.

the device we have is reporting 4 different values (one value will be reported every 10 min)
each value will be associated with a different address (which is arriving as part of the payload):

payload.data.body.ChaNum1=parseInt(fullString.substring(1, 2),16);
payload.data.body.ChaNum2=parseInt(fullString.substring(3, 4),16);

payload.data.body.ChaNum1=0, payload.data.body.ChaNum1=1 Payload will have data that will represent sensor 1
payload.data.body.ChaNum1=0, payload.data.body.ChaNum1=2 Payload will have data that will represent sensor 2
payload.data.body.ChaNum1=0, payload.data.body.ChaNum1=3 Payload will have data that will represent sensor 3
payload.data.body.ChaNum1=0, payload.data.body.ChaNum1=4 Payload will have data that will represent sensor 4

All sensors are connected to a single device, with one payload and a changing “Chanel” address , the device toggle between the sensors, sending one sensor value every 10 min:

For Example:
@13:00 payload.data.body.ChaNum = payload.data.body.ChaNum1 + payload.data.body.ChaNum2 (=01) will have a sensor value of 20[C]

@13:10 payload.data.body.ChaNum = payload.data.body.ChaNum1 + payload.data.body.ChaNum2 (=02) will have a sensor value of 45[%RH]

@13:20 payload.data.body.ChaNum = payload.data.body.ChaNum1 + payload.data.body.ChaNum2 (=03) will have a sensor value of 105[M]

@13:30 payload.data.body.ChaNum = payload.data.body.ChaNum1 + payload.data.body.ChaNum2 (=03) will have a sensor value of 5.68[Psia]

Your idea of the switch node seem to be the right choice, the question is regarding the Device State Implementation which require further elaboration on (current configuration will not allow multiplexing to take place).

your assistance is appreciated

#4

Hi @tirosh_gutte,

I would recommend creating either a Losant device or attribute for the four sensors, as it would make it easier to display data in a dashboard. Then, with the Switch Node, you could assign values to each Losant device based on which channel number is coming through. You would keep your current workflow set up, but each Device State Node would report to a different device. The sensors also seem to have different measurements (percent relative humidity, pressure, etc), so you could also have each device with different attributes based on what measurement values are coming in for the particular channel number.

If this does not sound like a way you would want to go, you could keep the single device and have attributes for C, %RH, M, and psia on the same device. The Switch Node would still be implemented as is, but each Device State Node would set a different attribute based on which channel number is coming in.

Thanks!
Julia

#5

The Device (Device 1) have been cloned and given 4 distinct names:
Device1_1
Device1_2
Device1_3
Device1_4

All attributes under each device have been kept the same

Connecting the Function to the Switch Node was by using:

Switch Template: {data.body.ChaNum}, and Case Template: 01,02,03,04

With the hope that the following channel values will be routing the payload to each created device:
data.body.ChaNum=“01” --> Device1_1
data.body.ChaNum=“02” --> Device1_2
data.body.ChaNum=“03” --> Device1_3
data.body.ChaNum=“04” --> Device1_4


This did not allow for these devices to be populated with the payload as expected.

When the Function Logic was tested bypassing the switch node, connected to each device state output the payload is arriving as expected.

Your assistance is appreciated

#6

Would like to add that just found out we have two field devices (trough SigFox) that are sharing the same trigger URL to this work flow webhook (triggering is set up on a Device Type level in SigFox Web Cloud, we have two devices under this device type, both are set with the same payload). Should we add another Switch Node to differentiate them?

To make sense of this finding:
Field Device 1 and Field Device 2 share a Webhook Trigger

Field Device 1 Address:
01: Sensor “A”
02: Sensor “B”
03: Sensor “C”
04: Sensor “D”

Field Device 2
01: Sensor “E”
02: Sensor “F”
03: Sensor “G”
04: Sensor “H”