Skip to content

Commit

Permalink
Merge pull request #34 from sinricpro/2.5.1
Browse files Browse the repository at this point in the history
clean up
  • Loading branch information
kakopappa authored Feb 14, 2022
2 parents 2e805a3 + 6590c04 commit c31e7ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 151 deletions.
103 changes: 1 addition & 102 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
## Dependencies
* Python 3.9.7 or newer
* websockets 8.1

### Check the examples [here](https://github.com/sinricpro/Python-Examples)

### How to set it up? click [here](https://dev.to/imdhanush/automation-with-alexa-jo)

### Install

pip install sinricpro --user
Expand All @@ -22,100 +17,4 @@

pip install sinricpro --upgrade --user

### Simple example

```python
from sinric import SinricPro
from sinric import SinricProUdp
import asyncio

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__':
loop = asyncio.get_event_loop()

client = SinricPro(appKey, deviceIdArr, callbacks,event_callbacks=eventsCallbacks,
enable_log=False,restore_states=True,secretKey=secretKey)

udp_client = SinricProUdp(callbacks,deviceIdArr,
enable_trace=False, loopInstance=loop) # Set enable_trace to True to start logging request Offline Request/Response

loop.run_until_complete(client.connect(udp_client=udp_client))

```

### Credentials file (credential.py)

```python
appKey = 'd89f1***-****-****-****-************'
secretKey = 'f44d1d31-1c19-****-****-9bc96c34b5bb-d19f42dd-****-****-****-************'
deviceId1 = '5d7e7d96069e275ea9******'
deviceId2 = ' 5j7e7d96069e275ea9******'
deviceId3 = ' 5d7e7d96069e275ea9******'
lock = ' 5d7e7d96069e275ea9******'
deviceIdArr = [deviceId1, deviceId2, deviceId3, lock]
```

### Pro Switch [Demo](https://github.com/sinricpro/Python-Examples/tree/master/pro_switch_example):

```python
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__':
loop = asyncio.get_event_loop()

client = SinricPro(appKey, deviceIdArr, callbacks,event_callbacks=eventsCallbacks,
enable_log=False,restore_states=True,secretKey=secretKey)

udp_client = SinricProUdp(callbacks,deviceIdArr,
enable_trace=False, loopInstance=loop) # Set enable_trace to True to start logging request Offline Request/Response

loop.run_until_complete(client.connect(udp_client=udp_client))
```
### Check the examples [here](https://github.com/sinricpro/Python-Examples)
50 changes: 4 additions & 46 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
SINRIC PRO
===============

This is a python library for alexa home automation skill
SINRIC PRO https://sinric.pro/


Python-2.7 Not Supported
========================


Functions:
----------
* Automate your home using alexa with sinricpro
Automate your home using Amazon Alexa, Google Home, SmartThings with Sinric Pro https://sinric.pro/

Installation :
--------------
Expand All @@ -23,39 +13,7 @@ Python3

python3 -m pip install sinricpro --user

Examples :
--------------

Pro Switch Demo:
~~~~~~~~~~~~~~~~~

::

from sinric import SinricPro
from sinric import SinricProUdp
from credentials import appKey, deviceId, secretKey
from time import sleep

def Events():
while True:
# Select as per your requirements
# REMOVE THE COMMENTS TO USE
# client.event_handler.raiseEvent(deviceId1, 'setPowerState',data={'state': 'On'})
sleep(2) #Sleep for 2 seconds

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, deviceId, callbacks,event_callbacks=eventsCallbacks, enable_trace=False,secretKey=secretKey)
udp_client = SinricProUdp(callbacks,deviceId,enable_trace=False) # Set it to True to start logging request Offline Request/Response
client.handle_all(udp_client)
https://github.com/sinricpro/python-examples
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
if sys.version_info < (3,6):
sys.exit('Sorry, Python < 3.6 is not supported')

VERSION = "2.4.2"
VERSION = "2.5.1"

with open('README.rst', 'r') as f:
long_description = f.read()
Expand All @@ -20,11 +20,13 @@
version=VERSION,
author="Dhanush",
author_email="dhanushdazz@gmail.com",
description="A python package for your sinric-pro alexa skill",
maintainer = 'sinric',
maintainer_email = 'support@sinric.com',
description="A python package for your Sinric Pro",
long_description=long_description,
url="https://github.com/sinricpro/python-sdk",
packages=['sinric'],
install_requires=["websockets","loguru"],
install_requires=["websockets==8.1","loguru"],
keywords=['alexa', 'alexa-skill', 'sinric', 'sinric-alexa-skill', 'alexa-home-automation', 'sinric-pro',
'sinric-pro-alexa-skill'],
classifiers=[
Expand Down

0 comments on commit c31e7ce

Please sign in to comment.