sinricpro / python-sdk

python3 sdk for sinric pro.
https://sinric.pro
23 stars 9 forks source link

Running python script #18

Closed ChopsKingsland closed 4 years ago

ChopsKingsland commented 4 years ago

I try to run the python script example with all the necessary IDs in it, but I get the following error

2020-03-31 19:16:15.095 | ERROR | sinric._sinricpro:__init__:34 - Device Id verification failed

Any ideas on how to fix this?

thegoliathgeek commented 4 years ago

@ChopsKingsland

This error occurs when the deviceId pattern is wrong. Can you share the code snippet by hiding your

ChopsKingsland commented 4 years ago

I’ve got it working now by changing the device type to light. How do I make it do something when it turns on/off?

thegoliathgeek commented 4 years ago
def onPowerState(did, state):
    # Alexa, turn ON/OFF Device
    if did == "<your deviceId>" and state=="ON":
             # Do something
    elif did == "<your deviceId>" and state=="OFF":
             # Do something
    return True, state

You can define logic like this.

ChopsKingsland commented 4 years ago

I did that, and I now get an error about indentation. I've tried every single combination of indentations and it still doesn't work >:(


    elif did == lightId and state=="OFF":
       ^
IndentationError: expected an indented block```
thegoliathgeek commented 4 years ago

Which editor do you use?

ChopsKingsland commented 4 years ago

Thonny on RPi

thegoliathgeek commented 4 years ago

Don't copy the code. Try typing it from scratch.

ChopsKingsland commented 4 years ago

it doesnt show an error anymore, but when i turn it on/off, nothing happens. How can I make it work?

thegoliathgeek commented 4 years ago

Just put a print statement and check what data you are getting.

ChopsKingsland commented 4 years ago

only on and off as i should be. i tried it printing 1 & 2 but nothing happened

thegoliathgeek commented 4 years ago

Did you try with web console?

thegoliathgeek commented 4 years ago

Or mail me your code at dhanushdazz@gmail.com . I'll check whats wrong

ChopsKingsland commented 4 years ago

app-for-github.txt

thegoliathgeek commented 4 years ago

@ChopsKingsland

Code is fine

Just change "ON" --> "On" and "OFF"-->"Off"

Screenshot 2020-04-02 at 12 32 40 AM
ChopsKingsland commented 4 years ago

THANKS! 😁 it works!