Send sms when motion is detected


(Nali preethi) #1

can anyone help me with the code for sending sms whenever motion is detected in motion sensor. the sample code which i tried has no errors but i didn’t get any sms in my mobile.is there any changes required in code?


(Kevin) #2

This is unrelated, but you should put “unsubscribe()” above the “initialize()” line in the “updated” method.

Besides that, I don’t see any issues with the visible code in the screenshot. Are you receiving the push notification?

The simulator might not be able to send SMS messages, but I’m not sure because I’ve always found the simulator to be really slow and flaky so I usually just test my SmartApps by installing them.

If this is all that the SmartApp is going to do, there are already SmartApps like “Notify Me When” that can do this.


(Bob) #3

Are you in the UK?
Just wondering as I never receive any sms messages despite putting in as follows as per instructions.
+447850xxxxxx.


(James) #4

Please try 0044


(Bob) #5

@foggy Tried that but no joy.
I have tried all sorts of variations but it never works.


(James) #6

Actually I was in error. Just tried it in Rule Mchine and entered +447980… And it worked. For info I am using iOS. I think I read some where if you are using Android. Try a different keyboard (layout) ?


(Bob) #7

I’m afraid as soon as I click on the field to input the number a number keyboard appears and I can’t change it.


(Nali preethi) #8

I am able to get push notification but not the sms. I have given a mobile number but still not able to get any sms. I want the app to send sms any given number even when smart app is not installed.


(Nali preethi) #9

I am not in UK.where should i use this no 0044.


(Kevin) #10

[quote=“preethi, post:9, topic:43607, full:true”]
I am not in UK.where should i use this no 0044
[/quote]If you’re not in the UK, all you should be entering is the 10 digit phone number. I usually enter it like ###-###-####, but I doubt the formatting matters.

Try installing the SmartApp and if the SMS messages work, you’ll know that the simulator doesn’t support SMS and there’s nothing wrong with your code.


(Bob) #11

Ok here goes. In what format do none US people enter the phone information.
0044785xxxxxxx or +44785xxxxxxx or 0044-785-xxxx xxxx etc etc.
I have tried numerous combinations with no success.


(Nali preethi) #12

thanks for suggestion. I tried with a virtual UK number and got the SMS.