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

    unipi 1.1 - Digital input counters

    Scheduled Pinned Locked Moved Evok API
    8 Posts 2 Posters 12.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.
    • J
      juntiedt
      last edited by

      Hi,
      how can I use the digital counters. Do I have to configure it in evok.conf or is it possible to use the evok interface. Is there some documentation about setting and reading counters? This command did not work. (with real data of course)

      conn = http.client.HTTPConnection("your-ip-goes-here:8080")
      
      payload = "{\"debounce\":\"number (optional)\",\"mode\":\"string (optional)\",\"counter\":\"number (optional)\",\"counter_mode\":\"string (optional)\",\"ds_mode\":\"string (optional)\",\"alias\":\"string (optional)\"}"
      
      headers = { 'content-type': "application/json" }
      
      conn.request("POST", "/json/input/%7Bcircuit%7D", payload, headers)
      
      1 Reply Last reply
      Reply Quote 0
      • T
        TomasKnot
        last edited by TomasKnot

        You need to set counter_mode to either "rising" or "falling", as per our documentation (the last version linked in Github):

        counter_mode
        string
        "rising","disabled" and "falling" applies only to the UniPi 1.1
        
        Allowed Values: Disabled, Enabled, rising, falling, disabled
        
        required
        

        https://evok-2.api-docs.io/1.02/rest/get-digital-input-state

        Edited: I think you are using the old version of documentation. Unfortunately api-docs doesn't allow amending older versions for legacy API reasons.

        see below

        1 Reply Last reply
        Reply Quote 0
        • J
          juntiedt
          last edited by

          Hi Tomas,

          this funtion works:

              def json_set_relay(self,CIRCUIT,VALUE,TIMEOUT):
                  if TIMEOUT == 0:
                      payload = '{"value":"%s"}' %(str(VALUE))
                  else:
                      payload = '{"value":"%s","timeout":"%s"}' %(str(VALUE),str(TIMEOUT))
                  with self._lock:          
                      self._conn = http.client.HTTPConnection("%s:%s" %(self._host, self._port))
                      self._conn.request("POST", "/json/relay/%s" %(str(CIRCUIT)), payload, self._headers) 
                      res = self._conn.getresponse()
                      data = res.read()
                      #print(data.decode("utf-8"))
                      self._conn.close()
          

          this does not work:

              def set_input(self,CIRCUIT):
                  payload = '{"counter_mode":"rising"}' 
                  with self._lock:      
                      self._conn = http.client.HTTPConnection("%s:%s" %(self._host, self._port))		
                      self._conn.request("POST", "/json/input/%s" %(str(CIRCUIT)), payload, self._headers) 
                      res = self._conn.getresponse()
                      data = res.read()
                      self._conn.close()	
          

          Why?

          It still shows "counter_mode": false

          1 Reply Last reply
          Reply Quote 0
          • T
            TomasKnot
            last edited by TomasKnot

            @juntiedt
            Oh! It does look like the counter_mode is forced to be set from the configuration file for the UniPi 1.1. Apologies for the confusion, I'll add the option of setting it through the API as in Neuron in the next update.

            1 Reply Last reply
            Reply Quote 0
            • J
              juntiedt
              last edited by

              Hi Tomas,

              when will the update be done for the counter problem on unipi1.1?

              Also I am still not successful in filtering devices in the evok web-socket interface. I found an example on your web site doing the filtering in the on.open function of web-socket. Unfortunately it does not work.

              T 1 Reply Last reply
              Reply Quote 0
              • T
                TomasKnot @juntiedt
                last edited by

                @juntiedt

                We are working on it. Currently we have been very busy with other development efforts, so there hasn't been the time to vet the update a little bit. It should be up by the end of the week.

                1 Reply Last reply
                Reply Quote 0
                • J
                  juntiedt
                  last edited by

                  counter on unipi1.1 is now working. I had to configure it in etc/evok.conf for rising or falling edge. Done this I could set and read debounce and counter. Still one question left. What is time actually representing. Number of ticks from edge to edge?

                  1 Reply Last reply
                  Reply Quote 0
                  • T
                    TomasKnot
                    last edited by TomasKnot

                    It's the number of milliseconds for which a signal has to hold; there is a good explanation of it here: https://www.kernel.org/doc/Documentation/gpio/driver.txt (section titled
                    "GPIOs with debounce support"). The idea being to filter out harmonics which occur due to electro-mechanical interference.

                    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