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

    Websocket filter

    Scheduled Pinned Locked Moved Official API - Evok
    7 Posts 2 Posters 3.6k 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

      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

                  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