Phone Groups and Adding Using SMS

Hey Everyone,

I am currently working on a PLC product that we are wanting to give the clients the ability to get SMS alerts. I have a RUT241 connected up and it is sending modbus Alarms Via SMS using an phone group called Alarm_Group. What I am wanting to do is add and remove numbers to the group via SMS. I started with ChatGPT to give me a hand and it said to run a custom script with the following:

#!/bin/sh

GROUP=“$1”
NEW_NUMBER=“$2”

Check if group and number were provided

if [ -z “$GROUP” ] || [ -z “$NEW_NUMBER” ]; then
logger “SMS ADD: Invalid parameters - GROUP or NUMBER missing”
exit 1
fi

Check if group exists and get current numbers

CURRENT=$(uci get sms_utils.“$GROUP”.number 2>/dev/null)

If group doesn’t exist, create it

if [ $? -ne 0 ]; then
logger “SMS ADD: Group $GROUP does not exist, creating…”
uci add sms_utils group
uci rename sms_utils.@group[-1]=“$GROUP”
CURRENT=“”
fi

Check if number is already in the group

if echo “$CURRENT” | grep -q “$NEW_NUMBER”; then
logger “SMS ADD: $NEW_NUMBER already in group $GROUP”
else

Add the number to the group

uci add_list sms_utils.“$GROUP”.number=“$NEW_NUMBER”
uci commit sms_utils
logger “SMS ADD: $NEW_NUMBER added to group $GROUP”
fi

Using the CLI and running below showed that the numbers were being added into a group called Alarm_Group. However in the WebUI the exisitng group I had set up with a number in it was not being changed to show the new numbers.

Can anyone help with this?

Hello,

After this command try adding “reload_config” the thing is you are commiting the changes, but it seems you are not reloading the service. I am not familiar /etc/init.d/sms_utils restart or it is mobileutils as of now.