-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-smsgateway.py
More file actions
44 lines (32 loc) · 1.22 KB
/
script-smsgateway.py
File metadata and controls
44 lines (32 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
# Based on the excellent work of vil1driver
# Used to send notification by SMS using the "SMS Gateway Ultimate" android app
# INSTALLATION #
# Put this file in /path/to/domoticz/scripts/python
# Add this in the "HTTP/URLAction" of domoticz parameters :
# script:///path/to/domoticz/scripts/python/script-smsgateway.py #MESSAGE
# -*- coding: utf-8 -*-
# it need the requests module, install it with :
# sudo pip install requests
import requests
import os
import sys
#~~~~~~~~~~Phone numbers to send SMS to~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
phones=['PhoneNumber1','PhoneNumber2']
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~SMS Gateway Ultimate parameters~~~~~~~~~~~~~~~~~~~~~~~~~~~
ip_sms_gateway='192.168.0.xyz'
port_sms_gateway='12345'
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if len(sys.argv)==1:
message= 'message de Domoticz'
else:
message = sys.argv[1]
def send_sms (tel,message):
#http://192.168.x.y:12345/send.html?smsto=06XXXXXX&smsbody=tets&smstype=sms
requetesms='http://'+ip_sms_gateway+':'+port_sms_gateway+'/send.html?'+'smsto='+tel+'&smsbody='+message+'&smstype=sms'
r = requests.get(requetesms)
print (r.url)
for tel in phones:
#print (tel)
send_sms(tel,message)