Logic Machine Forum
Modify a small sms script - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Modify a small sms script (/showthread.php?tid=1656)



Modify a small sms script - Kai-Roger - 16.10.2018

Hi.

I use this small script on a 1bit group address:

require('user.sms')
sendsms('12345678', 'test sms')

I then get a text message every time the group address value changes between 1 and 0.

What do i have to change in this script to only get a sms when the value is either 1 or 0?

if value = 0, then:
require('user.sms')
sendsms('12345678', 'test sms')

BR
Kai-Roger


RE: Modify a small sms script - admin - 16.10.2018

Value can be either true or false for booleans. You can write it like this:
Code:
if event.getvalue() == false then



RE: Modify a small sms script - Kai-Roger - 16.10.2018

Thanks.

Then i will write it like this:

if event.getvalue() == false then

require('user.sms')
sendsms('12345678', 'test sms')

Do i need to have a closure to the script in Lua, or is this not a normal practice? like:
if not then: exit

Okay. I just found out how it works. I need an "end" at the end Smile

if event.getvalue() == false then
require('user.sms')
sendsms('12345678', 'test sms')
end

When i run the script, i get a popup on my ipad with Visu.

It says

http://192.168.1.99
sending sms: 12345678 test sms

And i then have to press a OK button.

How to remove this message on visu?


RE: Modify a small sms script - Erwin van der Zwart - 16.10.2018

Hi,

There must be a alert() somewhere, probably in the user lib that you need to disable/remove.

Another option is to disable the popup in the vis config settings but then the alerts are still added to the alert tab.

BR,

Erwin


RE: Modify a small sms script - Kai-Roger - 16.10.2018

Thanks. Now i understand why this shows up on the Visu.

I could not find it in the script for deactivation. This is a script by admin 28.08.2015 09:20 in the below link.

https://forum.logicmachine.net/showthread.php?tid=68&highlight=sms

Maybe someone can point me in the right direction?  Smile


RE: Modify a small sms script - Erwin van der Zwart - 17.10.2018

Hi,

Its in the resident script..

Add — before the line to disable the alert.

alert('incoming sms: [%s] %s', tostring(sms.sender), tostring(sms.data))

BR,

Erwin


RE: Modify a small sms script - Kai-Roger - 17.10.2018

Hi.

That did not work, but thanks for pointing me in the right direction. I added -- in front of the first line of the following, and it works great  :)


    --alert('sending sms: ' .. msg)
    modem:sendsms(msg:sub(1, sep - 1), msg:sub(sep + 1))
  end
end