GithubHelp home page GithubHelp logo

python-sdk's People

Contributors

cojmeister avatar jeimison3 avatar kakopappa avatar thegoliathgeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python-sdk's Issues

Actions as class methods

something like shown below

class SinricProSwitch {
	
}

class SinricPro {

}

def on_power_state(state) {
 return true, newState
}

sinricpro_switch = SinricProSwitch("deviceId");
sinricpro_switch.on_power_state(on_power_state)

sinricpro = SinricPro();
sinricpro.add_device(sinricProSwitch);
sinricpro.start()

Error runing with websocket client

I am getting the error
AttributeError: module 'websocket' has no attribute 'client'

I am getting this error after running pip install websocket-client with Python 3.9 on Windows 10. I have got websocket-client 1.2.1 which contain this line:

self.connection = await websockets.client.connect('ws://ws.sinric.pro',

Checking the code in the repository I see that this line was changed here

self.connection = await client.connect('ws://ws.sinric.pro',

Maybe I am doing something wrong? or the last changes were not yet released in pip?

Connection to server lost

Hi!
I am using Sinric Pro to stimulate a python script that simulates a simple lamp, so I can control it with Alexa.
My code is pretty much one of your code examples in https://github.com/sinricpro/python-sdk.
It works fine for several hours, but after less than 24h the script shows an error message that says connection with the server has been lost.
I have restarted the process many times with the same outcome: in less than 24h the connection with the server is lost (no re-connection attempts but the python process does not terminate).
Is this a known issue?
Thanks!

Connection with Server Closed

I occasionally get the message “| INFO | sinric._sinricpro_websocket:receive_message:64 - Connection with server closed” and my device stops working. I would like my program to reconnect with sinricpro when this happens. Is there a way to do this in Python?

websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason

│       │                                   │       │    └ [<Task pending coro=<SinricProSocket.receiveMessage() running at /home/pi/scripts/python-sdk/sinric/_sinricprosocket.py:58> c...
│       │                                   │       └ <function wait at 0x76233d68>
│       │                                   └ <module 'asyncio' from '/usr/lib/python3.7/asyncio/__init__.py'>
│       └ <built-in function get_event_loop>
└ <module 'asyncio' from '/usr/lib/python3.7/asyncio/__init__.py'>

File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
self.run_forever()
│ └ <function BaseEventLoop.run_forever at 0x7618a030>
└ <_UnixSelectorEventLoop running=True closed=False debug=False>
File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
self._run_once()
│ └ <function BaseEventLoop._run_once at 0x7618ad68>
└ <_UnixSelectorEventLoop running=True closed=False debug=False>
File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
handle._run()
│ └ <function Handle._run at 0x76209df8>
└ <Handle <TaskWakeupMethWrapper object at 0x75df89d0>()>
File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
│ │ │ │ │ └ <member '_args' of 'Handle' objects>
│ │ │ │ └ <Handle <TaskWakeupMethWrapper object at 0x75df89d0>()>
│ │ │ └ <member '_callback' of 'Handle' objects>
│ │ └ <Handle <TaskWakeupMethWrapper object at 0x75df89d0>()>
│ └ <member '_context' of 'Handle' objects>
└ <Handle <TaskWakeupMethWrapper object at 0x75df89d0>()>

File "/home/pi/scripts/python-sdk/sinric/_sinricprosocket.py", line 51, in receiveMessage
message = await connection.recv()
│ └ <function WebSocketCommonProtocol.recv at 0x7609b108>
└ <websockets.client.WebSocketClientProtocol object at 0x765730f0>

File "/home/pi/.local/lib/python3.7/site-packages/websockets/protocol.py", line 509, in recv
await self.ensure_open()
│ └ <function WebSocketCommonProtocol.ensure_open at 0x7609b2b8>
└ <websockets.client.WebSocketClientProtocol object at 0x765730f0>
File "/home/pi/.local/lib/python3.7/site-packages/websockets/protocol.py", line 803, in ensure_open
raise self.connection_closed_exc()
│ └ <function WebSocketCommonProtocol.connection_closed_exc at 0x7609b270>
└ <websockets.client.WebSocketClientProtocol object at 0x765730f0>

websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason

Error on RaiseEvent setBrightness

I can't send setBrightness raise event becose te file sinric/_events.py have a error.

on line 67:

65            elif event_name == JSON_COMMANDS.get('SETBRIGHTNESS'):
66                queue.put([jsnHandle("setBrightness", deviceId, {
67                    "powerLevel": data.get('brightness')
68                }), 'setBrightness_event_response'])

the solution is to change "powerLevel" to "brightness".

Switch with Dimming Python None issue

Starting from this request or setting enable_log=True on SinricPro class, I found in file "_powerLevelController.py" in line 18 the following:

jsn.get("payload").get("powerLevel")

It's causing powerLevel None on event setPowerLevel, because powerLevel is inside "value" dict.
The solution is insert .get("value") in the middle, getting as follows:

self.power_level = jsn.get("payload").get("value").get("powerLevel")

_tkinter.TclError: character U+1f609 is above the range (U+0000-U+FFFF) allowed by Tcl

I am running the Python Pro Swith Demo using Thonny Python IDE on a Raspberry Pi 3 A+. The program runs ok, but when it starts I get a pop up labeled "Problem when handling 'ProgramOutput'" that contains the following message:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/thonny/workbench.py", line 1598, in event_generate
handler(event)
File "/usr/lib/python3/dist-packages/thonny/shell.py", line 393, in _handle_program_output
self._update_visible_io(None)
File "/usr/lib/python3/dist-packages/thonny/shell.py", line 501, in _update_visible_io
self._apply_io_event(data, stream_name)
File "/usr/lib/python3/dist-packages/thonny/shell.py", line 600, in _apply_io_event
self._insert_text_directly(data, tuple(tags))
File "/usr/lib/python3/dist-packages/thonny/shell.py", line 983, in _insert_text_directly
_insert_and_highlight_urls(line, tags)
File "/usr/lib/python3/dist-packages/thonny/shell.py", line 945, in _insert_and_highlight_urls
_insert(part, tags)
File "/usr/lib/python3/dist-packages/thonny/shell.py", line 939, in _insert
self.direct_insert("output_insert", txt, tags)
File "/usr/lib/python3/dist-packages/thonny/ui_utils.py", line 750, in direct_insert
return tktextext.EnhancedText.direct_insert(self, index, chars, tags=tags, **kw)
File "/usr/lib/python3/dist-packages/thonny/tktextext.py", line 719, in direct_insert
super().direct_insert(index, chars, tags, **kw)
File "/usr/lib/python3/dist-packages/thonny/tktextext.py", line 155, in direct_insert
self._original_insert(index, chars, tags, **kw)
File "/usr/lib/python3/dist-packages/thonny/tktextext.py", line 37, in original_function
self.tk.call((self._original_widget_name, operation) + args)
_tkinter.TclError: character U+1f609 is above the range (U+0000-U+FFFF) allowed by Tcl

Python example

Hello,
Can you put a python example with several devices like the MultiSwitch example in esp8266.
Thanks

Example Read Temperature

Hello,

I am looking for an example to read the temperature of a thermostat in python.

thank you in advance

Multiple range instances

I have defined a custom device with multiple range instances, all with unique instance id's. How can I tell which range was set in my onSetRangeValue callback?

CPU 100% busy on Raspberry

I have just started to use sinricpro python library on a Raspberry pizero and CPU is constantly at 100% with processor quite hot. Probably there is an event loop very tight. Is there a way to reduce CPU load? I basically use three lines of code:

client = SinricPro(appKey, deviceIdArr, callbacks, event_callbacks=None, enable_log=False, restore_states=True, secretKey=secretKey)
udp_client = SinricProUdp(callbacks,deviceIdArr,enable_trace=False)
client.handle_all(udp_client)

Question: Smart home control panel

I want to make a smart home control panel after I got my python program with the SinricPro library working. I want to do this with either a web server or PyGame. There is just 1 issue. Telling the Alexa service the current state of the device. When I push a button to turn on my lights using SinricPro, is there anyway to feed back to Alexa to show up on the app saying the current state? E.g. If I turned on my light from the control panel, I want the Alexa app to show that state change.

immediately disconnects on enigma2

I can't connect on my enigma2 revo 4k box.
I have taken all the steps and keep getting this message

root@revo4k:~# python /media/hdd/tv.py
/media/hdd/tv.py:62: DeprecationWarning: There is no current event loop
  loop = asyncio.get_event_loop()
2022-06-25 14:45:11.755 | SUCCESS  | sinric._sinricprosocket:connect:46 - Connected :)
2022-06-25 14:45:11.759 | ERROR    | sinric._sinricpro:connect:64 - 'NoneType' object is not callable
root@revo4k:~# python --version
Python 3.10.4

have used this tool
https://jungle-team.com/sinric-pro-conecta-tu-receptor-enigma2-a-alexa-o-google-home/

and your example
https://github.com/sinricpro/python-sdk/blob/master/examples/tv.py

how can I solve this?
i use openatv with google assistant which i added.
oh yeah new flash didn't work

Porting to Micropython

Hi, can this library be imported in micropython code? It would be amazing to run sonríe in python in the esp32.
If not, how can I help towards the process?

Energy Monitoring Sensor Python Example

Hello,
I also want to monitor Energy data in a project and query it with Alexa or Google Assistant.
I added "Energy Sensor" on the web side. But I am not able to send data in python back-end application.

Could you please share an example for "Energy Sensor"?

Running python script

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?

Missing dependency on setuptools

setuptools is no longer installed by default in python 3.12: python/cpython#101039

_sinricpro_websocket.py depends on it, causing this exception if not installed:

 File ".../_sinricpro_websocket.py", line 16, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

It should be added as an explicity dependency.

Cant get the sdk to run

Hi,
I have copied the basic example from the readme file, and filled all the details required.
After running it, it returns the following error:

File "sinric\_sinricprosocket.py", line 33, in connect self.connection = await websockets.client.connect('ws://ws.sinric.pro', File "\websockets\imports.py", line 92, in __getattr__ raise AttributeError(f"module {package!r} has no attribute {name!r}") AttributeError: module 'websockets' has no attribute 'client'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.