Python Code- Help me in writing code

HI, I am also using my bulb as an indicator. I need to send a Twilio SMS if my bulb turns ON. I am using my VMware and ubuntu server iso on my pc. Can anyone send the code for the above statement.

@manishraj200015
Your program should be to check whether the bulb is on or off. If the bulb is on you should get SMS notification.

Hope you get it. Do reply me for further if any issue arises.

@nazirahammed98 Yes. I want the code for the same scenario. Help me in, If bulb is ON I should get sms. Ignore the scenario of bulb turning OFF.

@nazirahammed98 I hope that works. But I am turning ON my led by IFTTT with google assistant and webhooks. The code part is just to send messages knowing that my led is ON.
Whether the following code is ok to do that:
py

If not correct me with the exact code required.

@manishraj200015
The query which you are asking then you have to you use while loop which will run infinitely and provide you sms after every loop until your led is switched off.

Where to insert while Sir? Whether the code is correct so that it meets my requirements?

@manishraj200015
insert while statement before the time.sleep() statement and also do check for rest of the indentation.
Example:
while True:
time.sleep(10)
so on…

@nazirahammed98 Sir what class should I import to make use of calling in twilio.
Pls help me and expecting a reply since it’s urgent.

@meenadhruvan
Sorry for the late reply, to make use of twilio you have to import
from twilio.rest import Client
then in client class there is a function called calls function
client = Client(conf.TWILIO_SID,conf.TWILIO_AUTH_TOKEN)
call = client.calls.create(conf.TO_NUMBER, conf.FROM_NUMBER,url=“http://demo.twilio.com/docs/voice.xml”)
print(call.sid)

if any assistance do reply

2 Likes

Thanks sir for your reply.I have been searching a lot for this.I will try this code and respond.