# Delay

Process
Delay
I
O

# 入力

ID略称名前デフォルト説明
inputIinputBOOLEANfalse

# 出力

ID略称名前デフォルト説明
outputOoutputBOOLEANfalse

# 設定

ID名前デフォルト単位説明
dondonNUMBER1s

詳細:

≥ 0
doffdoffNUMBER1s

詳細:

≥ 0

# 状態

ID名前デフォルト単位説明
last_input_statelast_input_stateBOOLEANfalse

# ソースコード

Volang ソースを表示
channel = input::channel()
value = input::value()

don_ms = math::round(config::get("don") * 1000)
doff_ms = math::round(config::get("doff") * 1000)

// Handle callback execution
extern fn onCallback(value) {
    if (value == 1) {
        // Delay on callback - set output to true
        output::set("output", true)
        return
    }
    
    if (value == 2) {
        // Delay off callback - set output to false
        output::set("output", false)
        return
    }
}

// Handle input changes - detect edges
if (channel == "input") {
    last_input_state = state::get("last_input_state")
    
    // Only react to state changes (edges)
    if (value != last_input_state) {
        state::set("last_input_state", value)
        
        if (value) {
            // Input went high - schedule delay on
            callback::clear()
            if (don_ms > 0) {
                callback::set(don_ms, "onCallback", 1)
            } else {
                // If delay is 0, set output immediately
                output::set("output", true)
            }
        } else {
            // Input went low - schedule delay off
            callback::clear()
            if (doff_ms > 0) {
                callback::set(doff_ms, "onCallback", 2)
            } else {
                // If delay is 0, set output immediately
                output::set("output", false)
            }
        }
    }
    return
}

Voldeno スマートホーム自動化における Delay Logic Block の動作、用途、設定方法を説明します。