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

    Activate multiple relays in evok api

    Official EVOK API
    1
    1
    494
    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.
    • W
      Wim Stockman last edited by

      Hello,
      I'm trying to activate a few relays on one push button connected to digital input.
      but for a moment to flick on and the last one stays on.
      If I try with just one relay it works fine.

      here is my code
      I placed it in the evok.py

      callback generators for devents

      def gener_status_cb(mainloop, modbus_context):
      def status_cb_modbus(device, *kwargs):
      modbus_context.status_callback(device)
      if registered_ws.has_key("all"):
      map(lambda x: x.on_event(device), registered_ws['all'])
      pass

      def status_cb(device, *kwargs):
          if device.devtype == 1:
              print(device.bitvalue)
              # On DI Create Reaction
              # e.g. Toggle Relay
              if device.bitvalue == 1:
                  for x in range(1,5):
                      time.sleep(1)
                      dr = Devices.by_name('relay',str(x))
                      time.sleep(1)
                      dr.set(value=1) 
                      time.sleep(1)
          if registered_ws.has_key("all"):
              map(lambda x: x.on_event(device), registered_ws['all'])
          pass
      
      if modbus_context:
          return status_cb_modbus
      return status_cb
      

      i cannot figure it out

      thx

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