If a different mail-host than gmail should be used the class must change.
cellsynt provides a service where each sms costs 0,50 kr. That seems fitting since the alarms should not be sending a lot of sms:es, unless a place is frequently robbed?
Sms are sent using cellsynt through their API, very simple. Here's my code, just change the user, pass and originator to fit your needs. Se the document for what originator should be.
import requestsThat was all that was needed to send an SMS! Amazingly simple. Also, you need to register an account and fill it up with sms. 100 sms is the smallest amount to fill, but I think you start out with 20 sms since I had 120 after i did a refill. Didn't check the quota before that.
class SMSHANDLER():
"""Check https://www.cellsynt.com/pdf/Cellsynt_SMS_gateway_HTTP_interface_(Swedish).pdf
for more info on cellsynt web service"""
URL_STR = "https://se-1.cellsynt.net/sms.php"
POST_DATA_USER = ""
POST_DATA_PASS = ""
POST_DATA_ORIGINATOR = ""
@staticmethod
def send_sms(destination, content):
"""sends sms to destination. Destinations first 2 digits "00" followed
by landcode. For a swedish number "070 112233" write "004670 112233.
content should be UTF-8 (stick to english lanugage)"""
URL_str = SMSHANDLER.URL_STR
POST_headers = {'username':SMSHANDLER.POST_DATA_USER,
'password':SMSHANDLER.POST_DATA_PASS,
'type':'text',
'destination':destination,
'originatortype':'numeric',
'originator':SMSHANDLER.POST_DATA_ORIGINATOR,
'charset':'UTF-8',
'text':content}
r = requests.post(URL_str, data=POST_headers)
print("SMS_Post_status:", r.status_code, r.reason)
print("SMS_response_content:", r.content)
In the last minute a bug arised today that means some things has to be rethought. The frames from the CAN-card seems to save frames for later or so, so it needs to be emtied or something, otherwise the alarm will sound like 10 times eash time there is an alarm. I'll check into that on monday. Then I'll configure it for Kivos purposes and make an raspbian img file along with documents probably.
Until next time.
Inga kommentarer:
Skicka en kommentar