2016-11-07 68 views
1

有了這個代碼:布爾錯誤的JavaScript

function checkIsNotOverHeating(context, surchauffe, offset, topic, node){ 
    let msg = null; 
    let overheating; 

    overheating = false; 

    if(checkTemperatureWithOffset(context.get("temperatureInt"), offset, surchauffe, "-") === 1){ 
     // Overheating 
     overheating = true; 
     msg = createMessageOverheat(topic); 
    } 

    node.error(overheating) 
    if(context.get("overheating") !== overheating) context.set("overheating", overheating); 

    return msg; 
} 

每node.error將在節點輸出參數的值。我無法理解爲什麼,但它會接受布爾值true,而不是假的,你可以在這個圖片中看到:

enter image description here

我使用NodeRED,並且你可以看到,代碼很簡單。我的功能每次都會觸發。

編輯:不要照顧-1的,它只是表明我2值

+0

不,我不知道這個問題。你能澄清嗎? – Liam

+0

@Liam在Node-RED的上下文中是有意義的。我將刪除應該幫助的javascript和node.js標記。我需要仔細檢查,但我認爲這可能是錯誤功能中的錯誤。 – hardillb

回答