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

    Websocket filter

    Official EVOK API
    2
    7
    2096
    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

      I am trying to filter only the "temp" message out of the websocket application.
      Unfortunately it does not work. please have a look at my little test program:

      #!/usr/bin/python
      # -*- coding: utf-8 -*-
      
      import websocket
      import json
      
      from time import *
      from datetime import *
      
      def on_message(ws, message):
          obj = json.loads(message)
          print(str(obj))
      
      def on_error(ws, error):
          now = datetime.now().strftime('%H:%M:%S')
          print (error + ": " + now)
      
      def on_close(ws):
          now = datetime.now().strftime('%H:%M:%S')
          print ("WS-Connection closed: " + now)
      
      #ws.send('{"cmd":"filter","devices":["ai","input"]}')
      def ws_receive():
          global ws
          global url
      
          ws = websocket.WebSocketApp(url, on_message = on_message, on_error = on_error, on_close = on_close)
          ws.run_forever()
      
      def ws_filter():
          global url
          ws = websocket.WebSocket()
          ws.connect(url)
          #ws.send('{"cmd":"filter","devices":["ai","input"]}')
          ws.send('{"cmd":"filter","devices":"temp"}') 
          ws.close()
      	
      #--------------------------------------------------------------------------------------
      	
      def main():
          global url
          
          host = "localhost"
          url = "ws://%s/ws" %(host)
          ws_filter()
          ws_receive()
      	
      if __name__ == "__main__":
          main()
      
      
      T 1 Reply Last reply Reply Quote 0
      • T
        tomas_hora administrators @juntiedt last edited by

        @juntiedt https://forum.unipi.technology/topic/518/setting-filter-corrupts-the-websocket-message/4

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

          sorry, but does it mean, that there is a bug in evok?

          I don't quite understand what I should do to filter temp devices.
          What is wrong with my test program?
          Please have another look.
          thanks

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

            @juntiedt please try it with

            ws.send('{"cmd":"filter","devices":"[temp]"}')
            
            1 Reply Last reply Reply Quote 0
            • J
              juntiedt last edited by

              no success with the command you send :-(

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

                @juntiedt ok, then please wait until @tomas_knot gets back after Christmas or try to investigate the issue in the code of Evok

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

                  ok. In which directory should I look for the evok software?

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post