Change phone number in multiple SMS modbus alarms

I have a similar application to YouRQ

and OlafVBR

where I have a RUT200 monitoring a number of alarm bits over Modbus TCP and sending SMS messages to a mobile phone. This works ok to a fixed mobile number, but I need to give my client the ability to change the mobile number that all these alarm messages are sent to.
It would also be good to be able to send the SMS to different numbers on a timed basis to correspond with working shift changes.

Can either of these be done without manually editing the configuration of every Modbus alarm each time?

Thanks.

Hello,

The most optimal way to automatically update the phone number for Modbus alarms would be through a script. This script would change the number by using commands like uci set modbus_client.3.telnum='XXXXXXXXXXX' followed by uci commit modbus_client for the first alarm (or whichever alarm you need to edit). You can set this script to run at specific times using crontab, which will allow you to change the number based on shifts or other schedules. More information on User scripts and Crontabs can be found in these articles:

An alternative, though less convenient method, would be to use SMS utilities. In this case, you could send an SMS to the router with the command:
"<password> uci set modbus_client.3.telnum=<your number>" whenever the number needs to be updated.

Additionally, if suitable, you can add multiple phone numbers to the same Modbus alarm, as suggested in the OlafVBR topic.

Best regards,

Thank you for your prompt reply Martynas,

So if my client were to send a single SMS message to the router in the format:

“ uci set modbus_client.3.telnum=”

would it change the number for all of the Modbus alarms at the same time?

David.

Hello David,

No, it would only change the phone number for the first Modbus alarm. To change the second one, you would need to use modbus_client.4, and so on for the others.

Best regards,

Thank you for your help Martynas,

I like the idea of changing the number that alarms report to by sending a SMS as this is very simple to explain to a customer, however it would be better if they could send one message to the system to change all alarms message settings at the same time.

Is it possible to send a single ‘change number’ command SMS message to the RUT200 that calls a script to change all Modbus alarm messages to send to a number contained within the ‘change number’ command SMS?

David.

Hello David,

Yes, it is possible to send a single SMS command to execute a script that will change all Modbus alarm numbers at once. To achieve this, you can configure it through the WebUI by navigating to Services → Mobile Utilities → SMS Utilities.

Please follow the steps outlined in the screenshot provided below. In the configuration window, use the Custom Script field to enter the script that changes all alarm numbers according to your requirements. Don’t forget to include the other alarms with your updated numbers.

I hope this helps! If you need further assistance, feel free to reach out.

Best regards,

Thank you once again Martynas.

Are the new numbers ‘number’ and ‘+number’ in your example hardcoded into the script?

What I am hoping for was to send a SMS to the RUT200 that also passed the new number to be used by the script via the message.

e.g.
Sending SMS ‘MyPassword123 change_numbers1 +01 2345 678901’ to change all alarm messages to report to +01 2345 678901.
or
Sending SMS ‘MyPassword123 change_numbers1 +12 3456 789012’ to change all alarm messages to report to +12 3456 789012.

Is it possible for the script to read the new number from the message?
and/or
Is it possible for the script to read the caller ID of the SMS message triggering the script?

Thanks again.

David.

Hello,

Thank you for your response.

In the script, ‘number’ and ‘+number’ are placeholders that need to be replaced with your desired phone number, to which the alarm notifications will be changed. For example, you would use the following command for the first alarm:

uci set modbus_client.3.telnum='+012345678901'

And so on, depending on how many alarms you have, you would continue with:

uci set modbus_client.5.telnum='<number>'
uci set modbus_client.6.telnum='<number>'

To change the number back to a different one, such as +12 3456 789012, you’ll need to create a second SMS rule with the new specified number. The command would look like:

uci set modbus_client.3.telnum='+123456789012'

And so on for the remaining alarms. At the end of every script, don’t forget to add:

uci commit modbus_client

Regarding your last questions, could you clarify if you’re looking to read the new Modbus alarm number within the same SMS rule’s script, or do you have a different method in mind?

Best Regards,

Hi Martynas,

I was hoping to read the new Modbus alarm number from the SMS message sent to call the script.

For example sending SMS ‘MyPassword123 change_numbers1 +01 2345 678901’ would change the number for all Modbus alarms to +01 2345 678901.

If this cannot be done, is there any other way for a non-technical person to easily change the number for all Modbus alarms ?

Thanks,

David.

Hello,

Unfortunately, within the SMS Utilities command, it is not possible to specify a phone number to which the alarms will be changed. This process is handled by the script that is called when you send this SMS to the router.

As I mentioned earlier, the simplest way to change the numbers for all Modbus alarms would be by setting up two SMS Utilities rules: one for changing the number to, e.g., +01 2345 678901, using the command “<password> change_numbers1”, and another rule for changing to a previous (first one) number using the command “<password> change_numbers2”.

I hope this clarifies the process. If you need further assistance or have any additional questions, please feel free to reach out.

Best regards,

Thank you once again Martynas.

I have one final question as my client will probably need to change the numbers when the systems are installed on a site by site basis.

Is it possible to have a variable or string within the script to hold the new number so if the number that the script uses needs to change we only need to make the change to 1 line and not multiple lines ?

so instead of :
uci set modbus.client.3.telnum=‘+012345678901’
uci set modbus.client.4.telnum=‘+012345678901’
uci set modbus.client.5.telnum=‘+012345678901’
uci set modbus.client.6.telnum=‘+012345678901’
uci set modbus.client.7.telnum=‘+012345678901’
etc.

could we have :
new_number= ‘+012345678901’
uci set modbus.client.3.telnum=new_number
uci set modbus.client.4.telnum=new_number
uci set modbus.client.5.telnum=new_number
uci set modbus.client.6.telnum=new_number
uci set modbus.client.7.telnum=new_number
etc.

so if my client needed to change the number that the script uses he would only have to change the variable/string value and not each line.

new_number= ‘+987654321098’
uci set modbus.client.3.telnum=new_number
uci set modbus.client.4.telnum=new_number
uci set modbus.client.5.telnum=new_number
uci set modbus.client.6.telnum=new_number
uci set modbus.client.7.telnum=new_number
etc.

Thanks,

David.

Hello,

Yes, it is absolutely possible to declare a variable to hold the phone number, allowing you to easily update it in just one place whenever needed. Below is an example script with your desired setup:

#!/bin/sh

# Define a variable for the phone number
number='+XXXXXXXXX'

# Use the variable in the uci commands
uci set modbus_client.3.telnum="$number"
uci set modbus_client.4.telnum="$number"
uci set modbus_client.5.telnum="$number"
uci set modbus_client.6.telnum="$number"
uci set modbus_client.7.telnum="$number"

# Commit changes
uci commit modbus_client

I hope this helps! If you need any further assistance, feel free to reach out.

Best regards,

Hi Martynas,

I have made two Scripts each identical except for the definition of the variable ‘number’. I have a total of 12 Modbus alarms on which I want to change the SMS number.

The scripts are called SMSNumber1 and SMSNumber2. I have set the ‘Enable status code’ to ON on both SMS rules. Both scripts are as follows

#!/bin/sh

Define a variable for the phone number

number=‘+44xxxxxxxxxx’

Use the variable in the uci commands

uci set modbus_client.3.telnum=“$number”
uci set modbus_client.4.telnum=“$number”
uci set modbus_client.5.telnum=“$number”
uci set modbus_client.6.telnum=“$number”
uci set modbus_client.7.telnum=“$number”
uci set modbus_client.8.telnum=“$number”
uci set modbus_client.9.telnum=“$number”
uci set modbus_client.10.telnum=“$number”
uci set modbus_client.11.telnum=“$number”
uci set modbus_client.12.telnum=“$number”
uci set modbus_client.13.telnum=“$number”
uci set modbus_client.14.telnum=“$number”

Commit changes (if required by your configuration)

uci commit modbus_client

If I send either SMSNumber1 or SMSNumber1 script command SMS, I get the following reply to my phone:

uci: Invalid argument
Status code: 0

The SMS number that the Modbus alarms are sent to does not change.

Thanks,

David.

Hello,

Thank you for providing additional details regarding your issue. I’ve reviewed and tested the setup based on your description once again and couldn’t replicate the problem exactly as described. The only inconsistency I noted is that it returns "Status code: 0", but despite this, the Modbus alarm number is successfully changed on my end.

To help pinpoint the issue, could you please provide a screenshot of Services → Mobile Utilities as well as your current SMS rule configuration window (please press Edit on it)? Additionally, please check the single quote symbol you’re using in the script – sometimes a different character may be used by mistake. It should be this ' one. One more note: please make sure that the comments “Define a variable for the phone number”, “Use the variable in the uci commands”, and “Commit changes” are prefixed with the # symbol at the beginning of line to avoid any interpretation issues.

Best regards,

Hi Martynas,

Please see SMS rule configuration and Modbus Alarm configuration screenshots below.

Many thanks,

David.










Hello David,

Could you please confirm the exact SMS text you’re sending to the router to execute your script? In your current setup, the Authorization method is set to Serial Number, so the text message should be formatted as follows: <S/N> SMSNumber1.

For easier management, I’d recommend changing the Authorization method to use the Admin Password instead. This way, your SMS text would simply be: <current admin password> SMSNumber1. You can adjust this setting under the Authorization tab in your SMS rule configuration. Please refer to the screenshot below for guidance:

Let me know if this helps or if you need further assistance.

Best Regards,

I use the serial number as I would rather the end-user not know the admin password.
I am selling these systems to my client who is then reselling to the end-user.

I am happy for my client to know the admin password but not the end-user.

The message I am sending is 6000XXXXX SMSNumber1

If I send the massage with the incorrect or no serial number then I do not get any SMS reply message from the RUT200, so I think the authorisation is working ok.

Firmware version: RUT2M_R_00.07.10
Internal modem firmware version: C200AEUHAR01A22M16_01.200.01.200
Kernel version: 5.15.165

MODBUS Client version: 2024-10-08-4caaf553db-1

Changing the authorisation to Admin Password makes no difference - I still receive

uci: Invalid argument
Status code:0

David.

Thank you for providing the additional information.

Could you confirm if your router’s SIM card has sufficient storage to receive messages? This can be checked in Services → SMS Utilities → Messages tab.

Additionally, could you connect to the router’s CLI via the WebUI (System → Maintenance → CLI, login as root with your admin password) or through SSH, and execute the following command:

uci show modbus_client

Please share the output here, with any private information hidden.

Best regards,

Thank you Martynas, I’ve made a bit of progress.
Typing uci show modbus_client highlighted that I do not have a client 3 but I do have a client 15.

root@RUT200:~# uci show modbus_client
modbus_client.main=main
modbus_client.main.debug=‘0’
modbus_client.main.enabled=‘1’
modbus_client.1=tcp_server
modbus_client.1.server_id=‘1’
modbus_client.1.port=‘502’
modbus_client.1.dev_ipaddr=‘192.168.0.3’
modbus_client.1.reconnect=‘1’
modbus_client.1.name=‘Siemens-Logo’
modbus_client.1.enabled=‘1’
modbus_client.1.delay=‘0’
modbus_client.1.frequency=‘period’
modbus_client.1.timeout=‘1’
modbus_client.1.period=‘1’
modbus_client.3=alarm_1
modbus_client.3.action=‘0’
modbus_client.3.modem=‘1-1’
modbus_client.3.enabled=‘1’
modbus_client.3.redundancy_protection=‘0’
modbus_client.3.data_type=‘bool’
modbus_client.3.actionfrequency=‘1’
modbus_client.3.register=‘8297’
modbus_client.3.msg=‘Test Mode - Boiler 1’
modbus_client.3.f_code=‘1’
modbus_client.3.condition=‘4’
modbus_client.3.value=‘1’
modbus_client.3.telnum=‘+4479XXXXXXXX’
modbus_client.5=alarm_1
modbus_client.5.action=‘0’
modbus_client.5.modem=‘1-1’
modbus_client.5.msg=‘Test Mode - Boiler 2’
modbus_client.5.f_code=‘1’
modbus_client.5.actionfrequency=‘1’
modbus_client.5.redundancy_protection=‘0’
modbus_client.5.register=‘8298’
modbus_client.5.data_type=‘bool’
modbus_client.5.condition=‘4’
modbus_client.5.value=‘1’
modbus_client.5.enabled=‘1’
modbus_client.5.telnum=‘+4479XXXXXXXX’
modbus_client.6=alarm_1
modbus_client.6.action=‘0’
modbus_client.6.modem=‘1-1’
modbus_client.6.msg=‘Test Mode - Boiler 3’
modbus_client.6.f_code=‘1’
modbus_client.6.value=‘1’
modbus_client.6.actionfrequency=‘1’
modbus_client.6.redundancy_protection=‘0’
modbus_client.6.register=‘8299’
modbus_client.6.data_type=‘bool’
modbus_client.6.condition=‘4’
modbus_client.6.enabled=‘1’
modbus_client.6.telnum=‘+4479XXXXXXXX’
modbus_client.7=alarm_1
modbus_client.7.action=‘0’
modbus_client.7.modem=‘1-1’
modbus_client.7.msg=‘Test Mode - Boiler 4’
modbus_client.7.f_code=‘1’
modbus_client.7.value=‘1’
modbus_client.7.actionfrequency=‘1’
modbus_client.7.redundancy_protection=‘0’
modbus_client.7.register=‘8300’
modbus_client.7.data_type=‘bool’
modbus_client.7.condition=‘4’
modbus_client.7.enabled=‘1’
modbus_client.7.telnum=‘+4479XXXXXXXX’
modbus_client.8=alarm_1
modbus_client.8.action=‘0’
modbus_client.8.modem=‘1-1’
modbus_client.8.msg=‘Test Mode - Boiler 5’
modbus_client.8.f_code=‘1’
modbus_client.8.value=‘1’
modbus_client.8.actionfrequency=‘1’
modbus_client.8.redundancy_protection=‘0’
modbus_client.8.register=‘8301’
modbus_client.8.data_type=‘bool’
modbus_client.8.condition=‘4’
modbus_client.8.enabled=‘1’
modbus_client.8.telnum=‘+4479XXXXXXXX’
modbus_client.9=alarm_1
modbus_client.9.action=‘0’
modbus_client.9.modem=‘1-1’
modbus_client.9.msg=‘Test Mode - Boiler 6’
modbus_client.9.f_code=‘1’
modbus_client.9.value=‘1’
modbus_client.9.actionfrequency=‘1’
modbus_client.9.redundancy_protection=‘0’
modbus_client.9.register=‘8302’
modbus_client.9.data_type=‘bool’
modbus_client.9.condition=‘4’
modbus_client.9.enabled=‘1’
modbus_client.9.telnum=‘+4479XXXXXXXX’
modbus_client.10=alarm_1
modbus_client.10.action=‘0’
modbus_client.10.modem=‘1-1’
modbus_client.10.msg=‘Alarm - Boiler 1’
modbus_client.10.f_code=‘1’
modbus_client.10.value=‘1’
modbus_client.10.actionfrequency=‘1’
modbus_client.10.redundancy_protection=‘0’
modbus_client.10.register=‘8307’
modbus_client.10.data_type=‘bool’
modbus_client.10.condition=‘4’
modbus_client.10.enabled=‘1’
modbus_client.10.telnum=‘+4479XXXXXXXX’
modbus_client.11=alarm_1
modbus_client.11.action=‘0’
modbus_client.11.modem=‘1-1’
modbus_client.11.msg=‘Alarm - Boiler 2’
modbus_client.11.f_code=‘1’
modbus_client.11.value=‘1’
modbus_client.11.actionfrequency=‘1’
modbus_client.11.redundancy_protection=‘0’
modbus_client.11.condition=‘4’
modbus_client.11.register=‘8308’
modbus_client.11.enabled=‘1’
modbus_client.11.data_type=‘bool’
modbus_client.11.telnum=‘+4479XXXXXXXX’
modbus_client.12=alarm_1
modbus_client.12.action=‘0’
modbus_client.12.modem=‘1-1’
modbus_client.12.msg=‘Alarm - Boiler 3’
modbus_client.12.f_code=‘1’
modbus_client.12.value=‘1’
modbus_client.12.actionfrequency=‘1’
modbus_client.12.redundancy_protection=‘0’
modbus_client.12.condition=‘4’
modbus_client.12.register=‘8309’
modbus_client.12.enabled=‘1’
modbus_client.12.data_type=‘bool’
modbus_client.12.telnum=‘+4479XXXXXXXX’
modbus_client.13=alarm_1
modbus_client.13.action=‘0’
modbus_client.13.modem=‘1-1’
modbus_client.13.msg=‘Alarm - Boiler 4’
modbus_client.13.f_code=‘1’
modbus_client.13.value=‘1’
modbus_client.13.actionfrequency=‘1’
modbus_client.13.redundancy_protection=‘0’
modbus_client.13.condition=‘4’
modbus_client.13.register=‘8310’
modbus_client.13.enabled=‘1’
modbus_client.13.data_type=‘bool’
modbus_client.13.telnum=‘+4479XXXXXXXX’
modbus_client.14=alarm_1
modbus_client.14.action=‘0’
modbus_client.14.modem=‘1-1’
modbus_client.14.msg=‘Alarm - Boiler 5’
modbus_client.14.f_code=‘1’
modbus_client.14.value=‘1’
modbus_client.14.actionfrequency=‘1’
modbus_client.14.redundancy_protection=‘0’
modbus_client.14.register=‘8311’
modbus_client.14.condition=‘4’
modbus_client.14.enabled=‘1’
modbus_client.14.data_type=‘bool’
modbus_client.14.telnum=‘+4479XXXXXXXX’
modbus_client.15=alarm_1
modbus_client.15.action=‘0’
modbus_client.15.modem=‘1-1’
modbus_client.15.msg=‘Alarm - Boiler 6’
modbus_client.15.f_code=‘1’
modbus_client.15.value=‘1’
modbus_client.15.actionfrequency=‘1’
modbus_client.15.redundancy_protection=‘0’
modbus_client.15.telnum=‘+4479XXXXXXXX’
modbus_client.15.register=‘8312’
modbus_client.15.condition=‘4’
modbus_client.15.enabled=‘1’
modbus_client.15.data_type=‘bool’

I changed both SMSNumber1 and SMSNumber2 scripts to remove reference to client 3 and add client 15 and now I get the following reply to both messages:

Status code:0

If I send a SMS to run SMSNumber 2 script and then type uci show modbus_client it shows that every number has changed, but if I then cause an alarm to occur, it sends an SMS to the original number and not the new one.

I have found that if I reboot the system after sending the SMS script command (by power cycling the control panel), the Modbus alarm number changes to the new one. Is there a way to change the number without power cycling the whole control panel ?