Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team

Question
marius de jong 12
I found this scene. I got the open/close window part to work. if i open my window this part is triggerd elseif (trigger['type']=='property') then
But I can't seem to get the scene to trigger if global variable Niemandthuis is changed.
a change of Niemandthuis should activate his part if (trigger['type']=='global') then
--[[
%% properties
152 value
%% globals
Niemandthuis
--]]
--------------- Absenk-Temperatur bei Fenster-Öffnung-------------
local schedule = {
id = 10, --ID des Raumes im Heiz-Panel
idleTemp = 16 --Temperatur, die bei Fenster-Öffnung gesetzt werden soll
}
--------------- Absenk-Temperatur bei Abwesenheit ----------------
local scheduleAway = {
id = 10, --ID des Raumes im Heiz-Panel
idleTemp = 10 --Temperatur, die bei Abwesenheit gesetzt werden soll
}
sensorID = 152 --ID des Tür-/Fenstersensor
-- AB HIER NICHTS MEHR ÄNDERN
function Debug( color, message )
fibaro:debug(string.format('<%s style="color:%s;">%s<!--%s-->', "span", color, message, "span"));
end
local function getMethod(requestUrl, successCallback, errorCallback)
local http = net.HTTPClient()
http:request(requestUrl, {
options = {
method = 'GET'
},
success = successCallback,
error = errorCallback
})
end
local function putMethod(requestUrl, data, successCallback, errorCallback)
local http = net.HTTPClient()
http:request(requestUrl, {
options = {
method = 'PUT',
data = json.encode(data)
},
success = successCallback,
error = errorCallback
})
end
local function setVactionModeTrue(subjectToChange)
local url = 'http://127.0.0.1:11111/api/panels/heating/' .. subjectToChange.id
getMethod(url, function(resp)
if resp.status == 200 then
print('Er is verbinding met het heating panel ' .. resp.status)
local panel = json.decode(resp.data)
if panel.properties.vacationTemperature ~= nil then
panel.properties.vacationTemperature = subjectToChange.idleTemp
print('Zet de tempratuur naar ' .. subjectToChange.idleTemp .. ' C')
putMethod(url, panel, function(resp)
if resp.status == 200 then
print('verandering wordt toegepast.')
end
end,
function(err)
print('Error ' .. err)
end
)
else
print('heating panel niet gevonden')
end
else
print('verbinding kon niet worden gemaakt ' .. resp.status)
end
end,
function(err)
print('error ' .. err)
end
)
end
local function setVactionModeFalse(subjectToChange)
local url = 'http://127.0.0.1:11111/api/panels/heating/' .. subjectToChange.id
getMethod(url, function(resp)
if resp.status == 200 then
print('Er is verbinding met het heating panel' .. resp.status)
local panel = json.decode(resp.data)
if panel.properties.vacationTemperature ~= nil then
panel.properties.vacationTemperature = 0
print('programma word hervat.')
putMethod(url, panel, function(resp)
if resp.status == 200 then
print('verandering zijn toegepast.')
end
end,
function(err)
print('Error ' .. err)
end
)
else
print('heating panel niet gevonden')
end
else
print('verbinding kon niet worden gemaakt ' .. resp.status)
end
end,
function(err)
print('error ' .. err)
end
)
end
local trigger = fibaro:getSourceTrigger();
if (trigger['type']=='global') then
if (fibaro:getGlobalValue("PresentState") == "Afwezig") then
if (tonumber(fibaro:getValue(sensorID, 'value')) == 0) then
setVactionModeTrue(scheduleAway)
Debug("blue",'Afwezig, niemand thuis, verwarming verlagen.')
else
Debug("white",'Afwezig, niemand thuis, raam is open. Tempratuur blijft hetzelfde.')
end
elseif (fibaro:getGlobalValue("PresentState") == "Aanwezig") then
if (tonumber(fibaro:getValue(sensorID, 'value')) == 0) then
setVactionModeFalse(schedule)
Debug("red", 'aanwezig, er is weer iemand thuis. volgt programma.')
else
Debug("white",'aanwezig, er is weer iemand thuis. raam is open. Tempratuur blijft hetzelfde.')
end
end
elseif (trigger['type']=='property') then
if (tonumber(trigger['deviceID'])==tonumber(sensorID)) then
local sensor = fibaro:getValue(sensorID, 'value')
if (tonumber(sensor) == 1) then
Debug("yellow", 'raam is open.')
counter = 0
while (tonumber(fibaro:getValue(sensorID, 'value')) == 1 and counter < 60) do
counter = counter + 1
fibaro:sleep(1*1000)
end
if (tonumber(fibaro:getValue(sensorID, 'value')) == 1) then
Debug("blue",'raam is nog open., er word gelucht. verwarming naar laag.')
setVactionModeTrue(schedule)
else
Debug("yellow", 'raam is binnen een minuut weer dicht.')
end
else
fibaro:debug('raam s dicht.')
Debug("red", 'raam is dicht. volgt programma.')
setVactionModeFalse(schedule)
end
end
end
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.