Logic Machine Forum
How to control the KNX bus via SMS and send notices via SMS? - 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: How to control the KNX bus via SMS and send notices via SMS? (/showthread.php?tid=68)

Pages: 1 2 3


RE: How to control the KNX bus via SMS and send notices via SMS? - admin - 11.09.2015

You can use HTTP (remote services) for communication and use an event script with object that has 255 byte string data type to pass the whole message. To make requests from SMS side you can install LuaSocket package.


RE: How to control the KNX bus via SMS and send notices via SMS? - RSV4 - 11.09.2015

I'll try to read about remote services but honestly currently have no idea how to this exactly. Did you mean "LM side" above not "SMS side"?

How are packages installed on the LM3?


RE: How to control the KNX bus via SMS and send notices via SMS? - admin - 11.09.2015

I mean you need to install Lua and LuaSocket on SMS handler side.

Basically, you need to send an internal KNX telegram on LM from SMS handler side. You can do this by using remote services and calling a simple HTTP request:
http://openrb.com/docs/remote.htm


RE: How to control the KNX bus via SMS and send notices via SMS? - RSV4 - 11.09.2015

Ah, I thought way to far! So I send http requests from the SMS-Linux Box. Sounds very logical.

I first thought that the Raspberry simply does the raw processing, i.e. sending and receiving messages. All scripting within the LM3 environment in order to have all scripts in one place, i.e. when editing group addresses in ETS4 I would just need to adapt things in the LM3 and its scripts without having to edit scripts on the Raspberry Pi as well. But at last it is probably better to have the SMS handling completely on the Raspberry and therefore it's own environment.

Thanks a lot for your support, will try to get this all running as soon as all hardware has arrived!


RE: How to control the KNX bus via SMS and send notices via SMS? - zoltan - 21.05.2016

It's an old thread, but the question belongs here. 

Using the scripts from previous page I made a configuration with Huawei modem, and it works on the test system. 

Now, the modem, powered USB hub and it's power supply are moved to the remote site, with the only difference in SIM card. And it won't work!
The setup is exactly the same, same HW/SW, known working modem and USB hub+cables. The SIM card is brand new, activated+PIN disabled, tested working/can send SMS from phone and make calls. The modem is unlocked, and the SIM is the same carrier as the modem (was before unlocking).

This line is repeated forever: 
Code:
May 21 20:43:50 homeLYnk kern.err kernel: [ 7416.514623] option1 ttyUSB1: option_instat_callback: error -71

Attached is the log after restart and unplug/replug of the modem.
Code:
May 21 18:41:15 homeLYnk user.notice usb-modeswitch: 1-1.4:1.5: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:15 homeLYnk user.notice usb-modeswitch: 1-1.4:1.4: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:14 homeLYnk user.notice usb-modeswitch: 1-1.4:1.3: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:14 homeLYnk user.notice usb-modeswitch: 1-1.4:1.2: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:14 homeLYnk user.notice usb-modeswitch: 1-1.4:1.1: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:14 homeLYnk user.notice usb-modeswitch: 1-1.4:1.0: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:13 homeLYnk user.notice usb-modeswitch: 1-1.3:1.0: Manufacturer=? Product=USB_2.0_Hub Serial=?
May 21 18:41:13 homeLYnk user.notice usb-modeswitch: 1-1:1.0: Manufacturer=? Product=USB_2.0_Hub Serial=?
May 21 18:41:12 homeLYnk user.notice usb-modeswitch: 1-1:1.0: Manufacturer=? Product=USB_2.0_Hub Serial=?
May 21 18:41:10 homeLYnk user.notice usb-modeswitch: 1-1.4:1.5: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:09 homeLYnk user.notice usb-modeswitch: 1-1.4:1.4: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:09 homeLYnk user.notice usb-modeswitch: 1-1.4:1.3: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:08 homeLYnk user.notice usb-modeswitch: 1-1.4:1.2: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:08 homeLYnk user.notice usb-modeswitch: 1-1.4:1.1: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:08 homeLYnk user.notice usb-modeswitch: 1-1.4:1.0: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:07 homeLYnk user.notice usb-modeswitch: 1-1.3:1.0: Manufacturer=? Product=USB_2.0_Hub Serial=?
May 21 18:41:07 homeLYnk user.notice usb-modeswitch: 1-1:1.0: Manufacturer=? Product=USB_2.0_Hub Serial=?
May 21 18:41:06 homeLYnk user.notice usb-modeswitch: 1-1:1.0: Manufacturer=? Product=USB_2.0_Hub Serial=?
May 21 18:41:04 homeLYnk user.notice usb-modeswitch: 1-1.4:1.5: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:04 homeLYnk user.notice usb-modeswitch: 1-1.4:1.4: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:03 homeLYnk user.notice usb-modeswitch: 1-1.4:1.3: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:03 homeLYnk user.notice usb-modeswitch: 1-1.4:1.2: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:02 homeLYnk user.notice usb-modeswitch: 1-1.4:1.1: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:02 homeLYnk kern.notice kernel: [ 48.205944] sd 7:0:0:0: [sda] Attached SCSI removable disk
May 21 18:41:02 homeLYnk kern.notice kernel: [ 48.191003] scsi 7:0:0:0: Direct-Access HUAWEI SD Storage 2.31 PQ: 0 ANSI: 2
May 21 18:41:02 homeLYnk kern.notice kernel: [ 48.186445] scsi 6:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
May 21 18:41:02 homeLYnk user.notice usb-modeswitch: 1-1.4:1.0: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.183299] scsi7 : usb-storage 1-1.4:1.5
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.182737] usb-storage 1-1.4:1.5: USB Mass Storage device detected
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.180401] scsi6 : usb-storage 1-1.4:1.4
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.176273] usb-storage 1-1.4:1.4: USB Mass Storage device detected
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.171861] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB2
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.170232] option 1-1.4:1.3: GSM modem (1-port) converter detected
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.165572] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB1
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.161950] option 1-1.4:1.2: GSM modem (1-port) converter detected
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.154640] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB0
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.151831] option 1-1.4:1.0: GSM modem (1-port) converter detected
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.145870] usb 1-1.4: Manufacturer: HUAWEI
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.145837] usb 1-1.4: Product: HUAWEI Mobile
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.145796] usb 1-1.4: New USB device strings: Mfr=3, Product=2, SerialNumber=0
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.145725] usb 1-1.4: New USB device found, idVendor=12d1, idProduct=1506
May 21 18:41:01 homeLYnk kern.info kernel: [ 47.140670] usb 1-1.4: not running at top speed; connect to a high speed hub
May 21 18:41:00 homeLYnk kern.info kernel: [ 47.035715] usb 1-1.4: new full-speed USB device number 14 using ci_hdrc
May 21 18:41:00 homeLYnk kern.info kernel: [ 46.942723] hub 1-1.3:1.0: 4 ports detected
May 21 18:41:00 homeLYnk kern.info kernel: [ 46.941495] hub 1-1.3:1.0: USB hub found
May 21 18:41:00 homeLYnk kern.info kernel: [ 46.938795] usb 1-1.3: Product: USB 2.0 Hub
May 21 18:41:00 homeLYnk kern.info kernel: [ 46.938754] usb 1-1.3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
May 21 18:41:00 homeLYnk kern.info kernel: [ 46.938686] usb 1-1.3: New USB device found, idVendor=03eb, idProduct=0902
May 21 18:41:00 homeLYnk kern.info kernel: [ 46.829707] usb 1-1.3: new full-speed USB device number 13 using ci_hdrc
May 21 18:41:00 homeLYnk kern.info kernel: [ 46.537653] hub 1-1:1.0: 4 ports detected
This text is not altered in any form. The text Serial=? is exactly copied from log.

Serial ports:
Code:
/dev/RS232
/dev/RS485
/dev/ttyUSB1 HUAWEI - HUAWEI Mobile
/dev/ttyUSB2 HUAWEI - HUAWEI Mobile
/dev/ttyUSB3 HUAWEI - HUAWEI Mobile

I've found some references on the internet regarding the usb-modeswitch bug, but can't access the device from CLI.

Edit:

Just noticed the error and the serial ports are changed while posting the original text. The new log:
Code:
/dev/RS232
/dev/RS485
/dev/ttyUSB0 HUAWEI - HUAWEI Mobile
/dev/ttyUSB1 HUAWEI - HUAWEI Mobile
/dev/ttyUSB2 HUAWEI - HUAWEI Mobile

May 21 21:02:50 homeLYnk kern.err kernel: [ 8556.495625] option1 ttyUSB0: option_instat_callback: error -71
May 21 21:02:50 homeLYnk kern.err kernel: [ 8556.359623] option1 ttyUSB0: option_instat_callback: error -71
May 21 21:02:49 homeLYnk kern.err kernel: [ 8556.287622] option1 ttyUSB0: option_instat_callback: error -71

Nothing was done to the device. It changed by itself while writing this post. It looks like the modem is restarting itself.

-- 
I know this is HomeLynk, but it's of no use to ask SE, they are useless in that matter - that's why we are switching to LM.


RE: How to control the KNX bus via SMS and send notices via SMS? - admin - 22.05.2016

Do you have this code in init script?
Code:
os.execute('echo 1 > /sys/bus/platform/devices/ci_hdrc.0/force_full_speed')
os.execute('echo 1 > /sys/bus/platform/devices/ci_hdrc.1/force_full_speed')
os.execute('usbreset /dev/bus/usb/001/001')



RE: How to control the KNX bus via SMS and send notices via SMS? - zoltan - 22.05.2016

(22.05.2016, 13:30)admin Wrote: Do you have this code in init script?
Code:
os.execute('echo 1 > /sys/bus/platform/devices/ci_hdrc.0/force_full_speed')
os.execute('echo 1 > /sys/bus/platform/devices/ci_hdrc.1/force_full_speed')
os.execute('usbreset /dev/bus/usb/001/001')

Yes, I've used the description and files from post #3 in this thread. 

I did some additional testing today (I have restricted access to the site, by navigating a non-technical person by phone), and it looks like the USB hub may be the source of the problem. The Raspberry Pi community have a long list of problematic USB hubs, some of them dropping ports when high power device is attached.
I have this installed, and from description it could be problematic. Anyway, I have to wait until tomorrow to test it further.


RE: How to control the KNX bus via SMS and send notices via SMS? - zoltan - 22.05.2016

Problem solved (part)!

After changing to another USB hub the modem is working reliably for now, without errors. The working model is HAMA 78472 USB 2.0 HUB 1:4.
Code:
May 22 19:30:26 homeLYnk user.notice usb-modeswitch: 1-1.4:1.5: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 22 19:30:25 homeLYnk user.notice usb-modeswitch: 1-1.4:1.4: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 22 19:30:25 homeLYnk user.notice usb-modeswitch: 1-1.4:1.3: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 22 19:30:25 homeLYnk user.notice usb-modeswitch: 1-1.4:1.2: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 22 19:30:24 homeLYnk user.notice usb-modeswitch: 1-1.4:1.1: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 22 19:30:24 homeLYnk user.notice usb-modeswitch: 1-1.4:1.0: Manufacturer=HUAWEI Product=HUAWEI_Mobile Serial=?
May 22 19:30:24 homeLYnk user.notice usb-modeswitch: 1-1:1.0: Manufacturer=? Product=USB_2.0_Hub Serial=?
May 22 19:30:23 homeLYnk kern.notice kernel: [ 861.445516] sd 13:0:0:0: [sda] Attached SCSI removable disk
May 22 19:30:23 homeLYnk kern.notice kernel: [ 861.431609] scsi 13:0:0:0: Direct-Access HUAWEI SD Storage 2.31 PQ: 0 ANSI: 2
May 22 19:30:23 homeLYnk kern.notice kernel: [ 861.425653] scsi 12:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.424813] scsi13 : usb-storage 1-1.4:1.5
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.424229] usb-storage 1-1.4:1.5: USB Mass Storage device detected
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.419922] scsi12 : usb-storage 1-1.4:1.4
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.419368] usb-storage 1-1.4:1.4: USB Mass Storage device detected
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.418014] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB2
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.415026] option 1-1.4:1.3: GSM modem (1-port) converter detected
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.413376] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB1
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.410076] option 1-1.4:1.2: GSM modem (1-port) converter detected
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.406802] usb 1-1.4: GSM modem (1-port) converter now attached to ttyUSB0
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.403886] option 1-1.4:1.0: GSM modem (1-port) converter detected
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.397314] usb 1-1.4: Manufacturer: HUAWEI
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.397283] usb 1-1.4: Product: HUAWEI Mobile
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.397243] usb 1-1.4: New USB device strings: Mfr=3, Product=2, SerialNumber=0
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.397173] usb 1-1.4: New USB device found, idVendor=12d1, idProduct=1506
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.392167] usb 1-1.4: not running at top speed; connect to a high speed hub
May 22 19:30:22 homeLYnk kern.info kernel: [ 860.287213] usb 1-1.4: new full-speed USB device number 17 using ci_hdrc
May 22 19:30:22 homeLYnk kern.info kernel: [ 859.992616] hub 1-1:1.0: 4 ports detected
May 22 19:30:22 homeLYnk kern.info kernel: [ 859.990046] hub 1-1:1.0: USB hub found
May 22 19:30:22 homeLYnk kern.info kernel: [ 859.987330] usb 1-1: Product: USB 2.0 Hub
May 22 19:30:22 homeLYnk kern.info kernel: [ 859.987289] usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
May 22 19:30:22 homeLYnk kern.info kernel: [ 859.987220] usb 1-1: New USB device found, idVendor=1a40, idProduct=0101
May 22 19:30:22 homeLYnk kern.info kernel: [ 859.983180] usb 1-1: not running at top speed; connect to a high speed hub
May 22 19:30:22 homeLYnk kern.info kernel: [ 859.850658] usb 1-1: new full-speed USB device number 16 using ci_hdrc

The other thing I found is that the modem will refuse to send a message if it contains some localized characters (čćšđž). Doesn't matter if it is only one character in the message or up to 70, if a single special character is in it won't send it. Edit: that's how it is configured at the beginning of the user.sms.lua script. 
I'm actively searching for a solution, but at least it works now.


RE: How to control the KNX bus via SMS and send notices via SMS? - ferrim - 26.06.2016

With this low cost USB 3G Modem I need to add one init string in the resident script:

Code:
    -- set to pdu mode
    modem:send('AT+CMGF=0')
    -- enable sms notifications
    modem:send('AT+CNMI=1,1,0,0,0')
    -- fixup encoding
    modem:send('AT+CSCS="GSM"')
    -- set preferred sms message storage to SIM
    modem:send('AT+CPMS="SM", "SM", "SM"')

and using the ttyUSB2 (the third USB) everything seems to work fine.
The Huawei E173 are a little expensive and hard to find...
HTH
Marcello


RE: How to control the KNX bus via SMS and send notices via SMS? - ferrim - 27.06.2016

(26.06.2016, 16:22)ferrim Wrote: I have verified that using an external USB power injector the LM3 Re:actor takes power through the USB port and this does not seem a good practice.

This could be a valid alternative?

Marcello



RE: How to control the KNX bus via SMS and send notices via SMS? - admin - 27.06.2016

Additional capacitors for 5V supply might work. But are you actually having any disconnects? These measures are optional and are not needed usually.


RE: How to control the KNX bus via SMS and send notices via SMS? - ferrim - 27.06.2016

(27.06.2016, 14:52)admin Wrote: Additional capacitors for 5V supply might work. But are you actually having any disconnects? These measures are optional and are not needed usually.

With Huawei USB sticks I've never seen a disconnect while with the cheap ones sometimes is happened during SMS receiving or transmitting.
From a few hours I'm trying the USB-CAP Olimex adapter and seems to work well...
Regards,
Marcello


RE: How to control the KNX bus via SMS and send notices via SMS? - luanpt - 15.07.2016

(27.06.2016, 17:15)ferrim Wrote:
(27.06.2016, 14:52)quản trị Wrote: Additional capacitors for 5V supply might work. But are you actually having any disconnects? These measures are optional and are not needed usually.

With Huawei USB sticks I've never seen a disconnect while with the cheap ones sometimes is happened during SMS receiving or transmitting.
From a few hours I'm trying the USB-CAP Olimex adapter and seems to work well...
Regards,
Marcello

Hi every one.


I'm using LM3 reactor are using sim 3g modem to send SMS but I encountered this phenomenon hope everyone help.

When using the LM message " SMS handler lost connection" according to attachments .

When converting " comport = ' ttyUSB0 ' " to " comport = ' ttyUSB2 ' " or " comport = ' ttyUSB1 " then turn off again " Script " the normal message .

Has anyone encountered this case does not help.


Thank you.


RE: How to control the KNX bus via SMS and send notices via SMS? - admin - 15.07.2016

Your modem is probably disconnecting due to high power consumption. This hardware might help: https://www.olimex.com/Products/USB-Modules/USB-CAP/


RE: How to control the KNX bus via SMS and send notices via SMS? - davidsilva - 24.06.2019

Hi,
In LM Reactor GSM with 3G modem built-in, what I have to change?

Best regards,


RE: How to control the KNX bus via SMS and send notices via SMS? - admin - 26.06.2019

Use ttyUSB2 and remove this line from user library:
Code:
os.execute('usbreset /dev/bus/usb/001/001')
Then fully restart resident script via disable/enable.


RE: How to control the KNX bus via SMS and send notices via SMS? - AlexLV - 10.01.2020

Hello,

I connected my modem to LM5 USB port. SMS sending is working, but I cannot start working SMS receiving with command from my phone.  What to check? In script I found "allowed numbers". I tried different formats - just phone number, phone number and country prefix and also +371 and number, it doesn''t help.

May be I should add something else to my scripts??


BR,

Alex


RE: How to control the KNX bus via SMS and send notices via SMS? - admin - 10.01.2020

Maybe you have to use another serial port (comport = 'ttyUSBX' line where X is port number). Some modems have several of them for AT commands but only one works for receiving.


RE: How to control the KNX bus via SMS and send notices via SMS? - AlexLV - 10.01.2020

OK, thanks, now will try to change port number to another.

BR,

Alex


RE: How to control the KNX bus via SMS and send notices via SMS? - michaelkessler - 03.07.2020

Hello, is there a Possibility to send an sms Notification with this script without a GSM Modem and us a API SMS Platform instead? And which Platform is working good?

Best Regards

Michi