• Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Wall switch - with Evok

    Scheduled Pinned Locked Moved Evok API
    2 Posts 2 Posters 1.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      devmicha
      last edited by devmicha

      I have a simple question. I have one wall switch (toggle wall switch type) connected to digital input and 6 lights connected to 6 relays / relay outputs to UniPi. I would like the wall switch to toggle (turn on or off) 6 lights when it's pressed. The lights can not be connected to one single relay because I would like to control lights separately from web interface ('direct switch' not very useful).
      What is the most optimal way to implement this scenario using evok (and python)? The most popular method is REST Api - however checking the digital input several times per second and switching on the lights when detecting changes on digital input (using GET requests) does not seem to be the optimal way... CPU consumption and temperature can be high. But what are the alternatives? Does using websockets from Evok Api cause a similar processor load as Rest Api and is this the best solution?
      Is it possible to directly communicate with hardware and read a single digital input using for example i2c or spi? Is it possible to read this in the evok code and if so in which files? This is what bothers me in the recent days

      Martin KudláčekM 1 Reply Last reply
      Reply Quote 0
      • Martin KudláčekM
        Martin Kudláček @devmicha
        last edited by

        Hello @devmicha,
        The infrastructure looks like this:

        IOs -> (SPI) -> ModbusTCP server -> (ModbusTCP) -> Evok -> (REST, WebSockets,...) -> your code

        • The ModbusTCP server (unipitcp service) is polling the complete status of underlying HW via SPI. This happens very quickly, in less than milisecond interval.
        • The Evok aggregates data from the ModbusTCP server and from the owfs (for 1-Wire devices).
        • Your application can poll data from the Evok in multiple ways (REST, WebSockets,...)

        As you can see, the Evok doesn't communicate with the HW directly. We discussed the possibility of custom software pulling the SPI in this thread: https://forum.unipi.technology/topic/711/reading-spidev

        I fully understand your concerns about infinite polling data over GET requests. This is generally slow and causes high load on the PLC. The WebSocket offers you a way to subscribe to updates of the IO. You can poll the complete status of the PLC at any time and yet you can listen to updates and act accordingly. Check the documentation and example: https://evok-9.api-docs.io/1.08/ubmjnyexu77wxwo4q/websocket.

        Martin

        1 Reply Last reply
        Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post