Help understanding the API's



  • Greeting all:
    I need some help! Can some one explain, or better yet, point me to some documentation, on using the unipi. I have read the git hub page documentation, but am still confused. What is the relationship between evok (sudo service evok start) and the program /opt/evok/evok.py?
    I can get the web page to work, and get the program /opt/evok/evok.py to run, but not at the same time. Unless they can use different ports and run concurrently, and is there any reason to do so? And I'm not quite sure what /opt/evok/evok.py does??

    In addition, can some one help me with using inputs. I don't want to poll them, as this can be slow and resource wasting. Is there some interrupt driven method available? Maybe with websockets? I can set the relays and read the inputs via the web page and HTTP POST examples, so I know that the hardware/software install is OK. But now to incorporate this into some programs. (I prefer C, python, or Ruby)

    Sorry to ask such dumb questions, but I've been scratching my head for a couple of days, and making no progress!

    Thanks in advance!
    schenkl



  • Greeting all:
    I need some help! Can some one explain, or better yet, point me to some documentation, on using the unipi. I have read the git hub page documentation, but am still confused. What is the relationship between evok (sudo service evok start) and the program /opt/evok/evok.py?
    I can get the web page to work, and get the program /opt/evok/evok.py to run, but not at the same time. Unless they can use different ports and run concurrently, and is there any reason to do so? And I'm not quite sure what /opt/evok/evok.py does??

    In addition, can some one help me with using inputs. I don't want to poll them, as this can be slow and resource wasting. Is there some interrupt driven method available? Maybe with websockets? I can set the relays and read the inputs via the web page and HTTP POST examples, so I know that the hardware/software install is OK. But now to incorporate this into some programs. (I prefer C, python, or Ruby)

    Sorry to ask such dumb questions, but I've been scratching my head for a couple of days, and making no progress!

    Thanks in advance!
    schenkl



  • Hello,

    service command is used to start/stop daemons (the easy way for users) that should run at startup. It uses scripts in /etc/init.d/ folder where you can find a file name evok. This script takes care of running the /opt/evok/evok.py as a daemon, remembers its PID to kill it on request and other things.

    So basically if you run service evok start, it ends up running /opt/evok/evok.py in the backround.

    If you do not want to use polling mechanism, try WebSocket. You need a websocket client, connect to the WS of evok and it will automatically broadcas all changes + initial configuration of all devices to all connected clients. There are examples on the github page of doing it for python and many other languages.



  • tomas_hora:
    thanks for the prompt response. I have figured out more, but still need some help….
    when I try to run the python websocket example from the git-hub page, I get this error:

    Traceback (most recent call last):
    File "unipi-webocket.py", line 20, in <module>
    ws = websocket.WebSocketApp(url, on_message = on_message, on_error = on_error, on_close = on_close)
    AttributeError: 'module' object has no attribute 'WebSocketApp'

    I assume that I don't have a library installed, but not sure which one? I have installed websocket with
    sudo pip install websocket
    which seemed to install OK, but did not fix the error.

    Any suggestions?

    Thanks!



  • That example is for this library https://pypi.python.org/pypi/websocket-client/
    But it you will use python 3 you can test also this one https://github.com/aaugustin/websockets



  • Thanks, got it all working! And it seems very fast too. I am so happy with the board that I just ordered another one!