1

Trouble getting the sensors info from units

Topic: Trouble getting the sensors info from units

Good afternoon.
Today i was doing some testing trying to get some sensor values from one of my units using the API search_items by property, I was reading and apparently using the next query it should give me the values of the sensors or at the very least show me the sensors on the unit, the query i used is the following:

-/ https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items&params={"spec":{"itemsType":"_unit","propName":"unit_sensors","propValueMask":"*XXUNITXX*","sortType":"unit_sensors"},"force":1,"flags":1439,"from":0,"to":0}&sid="sid" /-

The problem is that in the response it gives me an empty response, it returns nothing not even an error message either.
My question is what I’m I doing wrong, or what im malinterpretating here?

also i'll like to ask if there's a way using the API to know for when there's conectivity with the unit.

Thank you, any help is appreciated.

2

Trouble getting the sensors info from units

Re: Trouble getting the sensors info from units

jornadadgps22 wrote:

Good afternoon.
Today i was doing some testing trying to get some sensor values from one of my units using the API search_items by property, I was reading and apparently using the next query it should give me the values of the sensors or at the very least show me the sensors on the unit, the query i used is the following:

-/ https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items&params={"spec":{"itemsType":"_unit","propName":"unit_sensors","propValueMask":"*XXUNITXX*","sortType":"unit_sensors"},"force":1,"flags":1439,"from":0,"to":0}&sid="sid" /-

The problem is that in the response it gives me an empty response, it returns nothing not even an error message either.
My question is what I’m I doing wrong, or what im malinterpretating here?

also i'll like to ask if there's a way using the API to know for when there's conectivity with the unit.

Thank you, any help is appreciated.

Hello,
With the search_items request you can get sensors' properties and internal IDs.
If you want to arrange search by the prop item (e.g. unit_sensors), you need to add corresponding parameter in the request -- "propType":"propitemname"
propValueMask - should contains name or part of the name of sensor.
Here is the example: https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items&params={"spec":{"itemsType":"avl_unit","propName":"unit_sensors","propValueMask":"*New*","sortType":"sys_name","propType":"propitemname"},"force":1,"flags":4097,"from":0,"to":0}&sid=

Also, pay attention to the flags value, to get a sensors it should contains 4096.
This request respond with all units with the sensors that include "New" in their names.

In order to get sensors values from the last message, you can use 'unit/calc_last_message' request -- https://sdk.wialon.com/wiki/en/sidebar/ … st_message
You can set specific sensor ID in the array or leave it empty to get values of all sensors. 

Second option to get sensors values is 'unit/calc_sensors' request -- https://sdk.wialon.com/wiki/en/sidebar/ … lc_sensors
But this request work with the messages from loader, so you need to request messages first -- https://sdk.wialon.com/wiki/en/sidebar/ … s/messages


Regarding the connectivity - you can try to use search_items request by avl_unit with flags values 2097153 -- https://sdk.wialon.com/wiki/en/sidebar/ … connection

Anton Zinovyev
Technical Care Engineer (L1)
Wialon