I am currently utilizing a Teltonika device and its API to send alarm SMS messages. Specifically, I am using the system.alarm.getRosters() function to retrieve a list of users associated with a specific roster, along with their contact details.
However, I have encountered a challenge: rosters can consist of users from various sources, and when I access the roster information, it does not indicate which user source each user was added from. As a result, I am forced to use a static user source when retrieving contact information, rather than being able to programmatically access this metadata within my script.
This limitation complicates the setup of rosters that include users from different sources. Is there a way to obtain this user source information programmatically?
It's undocumented and only works in Gateway scope, but I think you can call system.alarm.getRoster(rosterName) to get a RosterModel object, which has actual User objects in it (RosterModel::getUsers()), which should include profile and contact info.
def test():
logger=system.util.getLogger('api_test')
ros='ROS_Test'
roster = system.alarm.getRoster(ros)
for user_object in roster.getUsers():
contacts= user_object.getContactInfo()
for contact in contacts:
if contact.contactType=='sms' or contact.contactType=='phone':
number=contact.getValue()
logger.info(str(number))
return