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
Something weird is happening there , when I try and get the user notes it doesn't work?
I can see the notes data in the getRawValueMap() but not matter what I do cannot access it typecasting to python dictionary or using the get() method?
# get the roster model for using the roster name
roster = system.alarm.getRoster(roster)
# get the users found in the roster model
users= roster.getUsers()
# array for storing the numbers
roster_numbers=[]
# loop throught each user model found in the roster model
for user_object in users:
# extract the users contact information
notes= user_object.get("notes")
It would definitely be this form, just like accessing the property. If you make other edits, are those applied? Any errors in the gateway logs, or on the UIResponse object you get back?
Okay found the error [You are not authorized to modify the Gateway system user source.]
Is there a setting in the gateway to allow this to be done via scripting?