• Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Gradient
    G
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    Gradient

    @Gradient

    0
    Reputation
    228
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Gradient Unfollow Follow

    Latest posts made by Gradient

    • RE: JSON Bulk not working

      This is weird. Can you confirm that the following python script works for you (please adjust IP):

      #!/usr/bin/env python3
      # -*- coding: utf-8 -*-
      import websocket
      import json
      url = "ws://192.168.0.105:8080/ws"
      ws = websocket.WebSocket()
      ws.connect(url)
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "1", "value":1})) #, "timeout":10}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "2", "value":1}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "3", "value":1}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "4", "value":1}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "5", "value":1})) #, "timeout":10}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "6", "value":1}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "7", "value":1}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "8", "value":1}))
          
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "1", "value":0})) #, "timeout":10}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "2", "value":0}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "3", "value":0}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "4", "value":0}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "5", "value":0})) #, "timeout":10}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "6", "value":0}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "7", "value":0}))
      ws.send(json.dumps({"cmd":"set", "dev":"relay", "circuit": "8", "value":0})) 
      
      ws.close()
      

      Because with my device this will not turn off all relays. It is erratic which relays are kept on and which aren't.
      If it does work with your UniPi 1.1, then my device is broken and I would like a replacement/fix.

      posted in Official API - Evok
      G
      Gradient
    • JSON Bulk not working

      Hi I am having trouble getting group_assignments in JSON Bulk write to work.

      I follow the API and my code is as follows:

      import requests
      
      url = "http://127.0.0.1:8081/bulk"
      
      payload = XXX
      headers = {'content-type': 'application/json'}
      response = requests.request("POST", url, data=payload, headers=headers)
      
      print(response.text)
      

      Now if I do payload as individual_assignments, the API seems to accept that:

      payload ="""{
      	"individual_assignments":
      		[
      			{
      				"device_type":"relay",
      				"device_circuit":"1",
      				"assigned_values":{"value":1}
      			},
      			{
      				"device_type":"relay",
      				"device_circuit":"2",
      				"assigned_values":{"value":0}
      			}
      		]
      	}"""
      

      I get

      {"status": "success", "data": {"individual_assignments": [1, 0]}}
      

      However, if I do "the same" as group_assignments:

      payload ="""{
      	"group_assignments":
      		[
      			{
      				"device_type":"relay",
      				"device_circuits":["1","2"],
      				"assigned_values":{"value":1}
      			}
      		]
      	}"""
      
      

      I keep getting

      {"status": "error", "message": "Internal Server Error", "code": 500}
      

      I also tried to have assigned_values as an array, to have device_type as array etc.ect.

      Can someone please provide me a working example on how to simultaneously set N relays?

      Thanks!

      BTW.
      Do you also experience problems when setting multiple values in a fast fashion (e.g. as above in individual_assignments, it happens that the relays are not assigned the provided values - only after I run the command multiple times. This is very unfortunate for time critical control applications... (e.g. I want two relays to switch at the same time and erraticaly one of them doe snot get switched).

      posted in Official API - Evok
      G
      Gradient