Skip to main content

RelayHardware UCMVirtual UCM

The relay library provides an interface for controlling relays. This is high level API for controlling digital outputs with human-friendly naming.

The relay library is available for:

relay.new

-- @param connection_string string Connection URI
-- @return object|nil, string|nil
function relay.new(connection_uri)
end

Returns a new relay client. The connection URI should specify the desired relay (digital output) device.

Use port schema to access hardware ports. On Virtual UCM you may also use gio schema for Generic IO.

On failure, it returns nil and an error message string.

client Object

client:close

-- @return string|nil
function client:close()
end

Closes the relay contact.

On success, the function returns nil. On failure, it returns an error message string.

client:open

-- @return string|nil
function client:open()
end

Opens the relay contact.

On success, the function returns nil. On failure, it returns an error message string.

client:impulse

-- @param duration number Impulse duration in milliseconds
-- @return string|nil
function relay:impulse(duration)
end

Triggers a relay impulse for a specified duration. This function is non-blocking, meaning it returns immediately, before the impulse ends.

On success, the function returns nil. On failure, it returns an error message string.

client:is_closed

-- @return boolean, string|nil
function relay:is_closed()
end

Checks if the relay is closed. Returns true if relay is closed, false if relay is open.

On failure, it returns false and an error message string.

All Rights Reserved © 2025 Enapter AG.