Not able to print the device status in python code

After writting python code the device status is not printing

@gladson2222 can you retype again using sudo nano filename.py and delete all line of code and re type the code again if not can you share ur problem via screenshot

Hi… i have typed the code for device status checking but it shows syntax error in line i.e. the api_key line

Hi @gladson2222,

Can you share the screenshot of your codes and screenshot of the output of your program?

image
Hi…@gladson2222
this is the result after running the program… i have deleted the file and again recoded it … but result is the same


and this is program…

In Python code identation and leading whitespace is more important it determines how the statements you given in the code is grouped together .check it once otherwise copy and paste it.

As shown in the error it is an invalid syntax.

the api_key is a string variable and hence it should be enclosed with double quotes or single quotes. However, In your screenshot, there are random characters at the beginning and end of the api_key.
The correct way of defining the api_key is below:

api_key = "your_api_key"

Please update the line in your code as shown above and change the your_api_key to your API key and run the program. It should work.

hi as the bolt api and device id is not in " " so, the value is not taken keep the apikey and device id in eg:deviceid = “BOLT*******”
:slight_smile: this will work

Sir, as i can see from your screenshot you forgot to put quotes in your api_key and device _id ,that’s why it is showing syntax error ,please correct it…Thanks

Hi,
Put the values for your api_key and device_id in double quotes " ".
This should solve the problem