ガレージのドアを制御している Siri プロキシを備えた Raspberry Pi があります。ガレージのドアには、開閉用のコマンドが 1 つしかありません。ガレージのドアが開いているかどうかを確認するために、マグネット スイッチを購入し、フラウト ポイント ボタンを作成しました。私はすでに試しました
doorstate = `gpio read 5`.chomp #gives value 1 or 0, 1 is opened, 0 is closed
print doorstate
if doorstate == "1"
print "The garage door is already opened.\n"
elsif doorstate == "0"
print "OK, I'll open it for you!\n"
else
print "Error, please open it manually.\n"
end
返された値または文字列が文字列doorstate = 'gpio read 5'
と等しいことを確認する方法を教えてください。