Send sms when motion is detected

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 there any changes required in code?

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.

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

Please try 0044

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

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) ?

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.

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.

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

[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.

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.

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