Automatic attribute recognition

device-recipes
#1

Unlike other platforms, Losant does not recognize sensors, if the corresponding attribute is not applied (manually). This may be useful in some cases, but in some cases it is not. We can see from the logs, that data heve been imported, but are not used, as long as the attribute is not defined.

It would be helpful to have an automatic attribute recognition during setup, that could be switched off after the initial phase.

1 Like

#2

Hello @Eckehard_Fiedler,

Thank you for your request, I will pass it over to our dev team and keep you updated in the future should this functionality become available!

Though it may not assist in your use case, I recommend checking out Device Recipes if you have many similar sensors with the same attributes; Device Recipes make it easier and faster by bulk creating devices with attributes. Again, it may not be applicable for your use case, but it could cut down on the time you are spending if you do have many similar sensors. :smile:

Thanks,
Julia

0 Likes

#3

Hello Julia,

thank you for your hint, which may be very helpful. It only does not help much with new devices or if the device uses sensor ID´s.

Best regards

Eckehard

1 Like

#4

@Eckehard_Fiedler-

A few more resources here:

The first, a blog post on How Devices Can Register Themselves in Losant, which could come in handy for your use case. You can validate (with something like a device’s serial number or id) and create a new device from it with specific attributes.

The other is a workflow I am creating, I will invite you to it so you can check it out! Essentially, it is similar to the workflow above, but uses deviceId and sets state if the device is not a new device.

Thanks!
Julia

0 Likes

#5

Hello Julia,

nice to see this is possible. Anyway some things could be covered under the hood anyway. While this was requested before (and is standard for other platforms)
we sould see if it is possible to get a button on the right place for this.

One question: How could a device get updated?? An attribute maybe found or not, but if it´s found, how can it be changed?:

Best regards,

Eckehard

0 Likes

#6

Hello!

The Device: Update node leads to a conditional with a valueByKey expression. This expression is a tad complicated, but it leads to another “Device Update” that will change the device attributes. The conditional returns true when there is a new attribute, and will take the path to update the device attributes if a new one is found.
06%20AM

The conditional statement is !{{valueByKey device.attributes data.body.name "name" "dataType"}}. This statement looks at the attributes object and returns the value of dataType when “name” equals data.body.name. So when the attribute does not exist, the path is true, and a new attribute is created.

Hopefully this answers your question, let me know if not!

Julia

0 Likes

#7

Currently it is possible to have a device with multiple attributes, that represent multiple sensors. But these attributes cannot have separate tags.

I wonder if it was useful to automatically create separate devices for each sensor in that case.

Let assume we have a single device that can measure temperature and humidity, called SENSOR1. To be able to use different tags for different sensors we can create two new devices: SENSOR1_TEMP and SENSOR1_HUM. Maybe this is a bit awkward, but fits best to the current Losant data model.

1 Like

#8

Hi,

Thanks for your suggestion! I will pass it along to our devs and keep you updated if it is selected for implementation.

Thanks,
Julia

0 Likes

#9

I have started defining all of the sensor characteristics in Datatables, and have been driving MODBUS reads (type, input , holding etc) on the Edge Agent and transformations (scale, etc, bit definitions) on the Edge Agent. This definition is sent via a table update event via a command and stored as Json in redis.

Thinking out aloud, would data tables provide enough flexibility on a per sensor/device basis to store the various tranforms/types etc…

The issue then would be how to combine these two things device/state and the corresponding data table definition. Using custom charts should be straighforward, but can’t see how that could work for standard widgets.

1 Like

#10

Hy Julia,

my question was more, if you think it is possible to do this programmatically with the device:Create block? Additionally we would need some kind of dispatcher that can move incoming data forward to the new devices.

0 Likes

#11

Hi @Eckehard_Fiedler,

Let me know if this is not what you are thinking, but I am reading your question as “can I programmatically create a new Losant device for each sensor on my physical device.” I think this could be accomplished with some conditional nodes, a Device: Create Node, and a Device State Node. Essentially, the workflow would be triggered and look for the existing Losant device, if it is not found, it would make a new one, if it is found, it will update the state of that device.

Let me know if this is not what you had in mind!
Thanks,
Julia

0 Likes

#12

Hello Julia,

you are right. Usually our sensors use one gateway on site, so a telegram contains data from multiple sensors:

Gateway1: {

Sensor 1: xxx

Sensor 2: xxx

Sensor 3: xxx

}

So we have to think about a way organize the data flow and to store metadata for each sensor. Any suggestions are welcome.

Best regards,

Eckehard

0 Likes

#13

Hi @Eckehard_Fiedler,

I think separate devices with tags would be the best approach to this if you need to filter and redirect workflows based on metadata. It is very easy to route workflows by tags and device names, so when the gateway reports you could report state to each device and then access the tags after reporting. Another (more difficult) way, if you would like to keep them as attributes on one device, would be by naming conventions, then you could do some string operations on the attribute name to get that metadata. Again, not the easiest approach, but if having one device makes sense for your use case, that could be a way around it.

Thinking out loud here, but let me know if anything is unclear!
Julia

0 Likes

#14

Well, using separate devices inside Losant can be an advantage.

Let assume, we have a “gateway” sending some data from different sensors:

"HW_H00":23.69
"HW_H05":34.63
"HW_H10":39.25
"Vorlauf":34.5
"Ruecklauf":31.88
"HW_Oben":51.75

Data will arrive via the gateway device, so as far as I can see, we will need a corresponding attribute on the gateway for every sensor, right?

Any suggestion how to forward data from a gateway to other devices in a consistent way? I suppose this will include some Programming to get the data from a gateway to the “virtual” device which has the same “attribute”?!?

If I do all the jobs manually, renaming a single datasource means:

  • Renaming the gateway attribute
  • create a new “virtual” device to receive the data
  • Adding an attribute to the “virtual” device
  • changing the transport mechanism to copy the data from the gateway to the new device

Is there any other way to use gateway devices I did not recognize?

Best regards,
Eckehard

0 Likes