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
Roberto R. 0
Here is my problem:
I have to create a scene for my greenhouse that lets me start a heater and so far everything is simple.
I have a smart meter and I would like the heater to start only under certain conditions such as temperature type below 15 degrees, in a certain amount of time and consumption in watts less than 2900W.
No problem for the temperature and time interval but when I enter the consumption the scene "stripping".
Transforming a block scene I made this code that seems to work but actually runs only once even if there is the autostart.
What am I doing wrong?
Here is the lua code I am setting up:
--[[
%% autostart
%% properties
551 value
719 energy meter
%% weather
%% events
%% globals
--]]
local energyMeterID = 719
local sourceTrigger = fibaro:getSourceTrigger();
function tempFunc()
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
powerNow=api.get("/energy/now-1/now/single/devices/power/"..energyMeterID)
if (
( (tonumber(os.date("%H%M")) >= tonumber(string.format("%02d%02d", "16", "00")) and tonumber(os.date("%H%M")) <= tonumber(string.format("%02d%02d", "08", "59"))) and (math.floor(os.time()/60)-math.floor(1550131200/60))%1 == 0 )
and
( tonumber(fibaro:getValue(551, "value")) <= 15 and powerNow.W <= 2900 )
)
then
fibaro:call(619, "turnOn");
end
setTimeout(tempFunc, 60*1000)
end
if (sourceTrigger["type"] == "autostart") then
tempFunc()
else
local energyMeterID = 719
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
powerNow=api.get("/energy/now-1/now/single/devices/power/"..energyMeterID)
if (
( (tonumber(os.date("%H%M")) >= tonumber(string.format("%02d%02d", "16", "00")) and tonumber(os.date("%H%M")) <= tonumber(string.format("%02d%02d", "08", "59"))) )
and
( tonumber(fibaro:getValue(551, "value")) <= 15 and powerNow.W <= 2900 )
or
startSource["type"] == "other"
)
then
fibaro:call(619, "turnOn");
end
end
1 answer 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.