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
ErikP 4
I want to have a kind of wakeup light that gradually increases intensity over a set amount of minutes. I tried this code:
--[[
Slowly increase light brightness over time
Adapted from code by Fibaro Forum user: iRobot
--]]
-- User-defined variables
local lightID = 1 -- ID of the light device to control
local duration = 10 -- Duration of the fade-in in seconds
-- Get current light level
local currentLevel = fibaro:getValue(lightID, "value")
-- Set initial brightness level to 0
fibaro:call(lightID, "setProperty", "ui.brightnessLevel.value", 0)
-- Calculate the brightness increment based on the duration
local brightnessIncrement = 100 / (duration * 10)
-- Loop through and gradually increase brightness level
for i=0,100,brightnessIncrement do
fibaro:sleep(100)
fibaro:call(lightID, "setValue", i)
end
-- Set the final brightness level
fibaro:call(lightID, "setValue", currentLevel)
But is does not seem to work. I get the following error:
"(load):11: Assertion failed: Expected number"
Can someone help me make this code work?
Thanks!
Link to comment
Share on other sites
5 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.