Activate multiple relays in evok api



  • 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