Python3 SDK for Sinric Pro
How to set it up? click here
pip install sinricpro --user
pip install sinricpro --upgrade --user
from sinric import SinricPro
from sinric import SinricProUdp
from time import sleep
appKey = '' # d89f1***-****-****-****-************
secretKey = '' # f44d1d31-1c19-****-****-9bc96c34b5bb-d19f42dd-****-****-****-************
device1 = '' # 5d7e7d96069e275ea9******
device2 = '' # 5d80ac5713fa175e99******
deviceIdArr = [device1,device2]
def Events():
while True:
# Select as per your requirements
# REMOVE THE COMMENTS TO USE
# client.event_handler.raiseEvent(device1, 'setPowerState',data={'state': 'On'})
pass
def onPowerState(did, state):
# Alexa, turn ON/OFF Device
print(did, state)
return True, state
eventsCallbacks={
"Events": Events
}
callbacks = {
'powerState': onPowerState
}
if __name__ == '__main__':
client = SinricPro(appKey, deviceIdArr, callbacks,event_callbacks=eventsCallbacks, enable_log=False,restore_states=True,secretKey=secretKey)
udp_client = SinricProUdp(callbacks,deviceIdArr,enable_trace=False) # Set it to True to start logging request Offline Request/Response
client.handle_all(udp_client)
Credentials file (credential.py)
appKey = 'd89f1***-****-****-****-************'
secretKey = 'f44d1d31-1c19-****-****-9bc96c34b5bb-d19f42dd-****-****-****-************'
deviceId1 = '5d7e7d96069e275ea9******'
deviceId2 = ' 5j7e7d96069e275ea9******'
deviceId3 = ' 5d7e7d96069e275ea9******'
lock = ' 5d7e7d96069e275ea9******'
deviceIdArr = [deviceId1, deviceId2, deviceId3, lock]
from sinric import SinricPro
from sinric import SinricProUdp
from credentials import appKey, deviceIdArr, secretKey
from time import sleep
def Events():
while True:
# Select as per your requirements
# REMOVE THE COMMENTS TO USE
# client.event_handler.raiseEvent(device1, 'setPowerState',data={'state': 'On'})
pass
def onPowerState(did, state):
# Alexa, turn ON/OFF Device
print(did, state)
return True, state
eventsCallbacks={
"Events": Events
}
callbacks = {
'powerState': onPowerState
}
if __name__ == '__main__':
client = SinricPro(appKey, deviceIdArr, callbacks,event_callbacks=eventsCallbacks, restore_states=False,secretKey=secretKey)
udp_client = SinricProUdp(callbacks,deviceIdArr,enable_trace=False) # Set it to True to start logging request Offline Request/Response
client.handle_all(udp_client)