Jump to content

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


Automatic Lightning System for HC3 (Motion/Average Lux)


chiel-s

Recommended Posts

12 hours ago, okidoki said:

@ppeterr: how did you make Alexa speak? I have a google via sonos, could that also work?

 

 

 

 

 

I managed to do that with the help of a number of posts already here on the forum.

There are a number of smart users who have put it together. I've tweaked that a bit here and there for my purpose. When I search on TTS and Sonos, I get enough results that shows it will be possible for you too.

 

I'd say get on with it. Open a topic and I'll take a look with you.

I don't have a google home myself, but I'm pretty sure others will help.

 

[edit] I just found this, a sonos player with TTS, you only need something to run Node.js on - like a rpi.

 

 

Edited by ppeterr
Link to comment
Share on other sites

Hi again @SmartHomeEddy,

 

How are you?.
I have returned to my small changes to regulate the intensity when turning on depending on the amount of lux.
I must have a problem with the variables or how I interpret them, because I can't get the routine to work.

Can you give me some advice?.

 

This is a variables.

 

 

local lux = {65-- ID's the Lux just the show the lux level, nothing more
local Bridgness = 99 -- Next change this value 
 
Local Funtion.
local function ON(light) fibaro.call(light,"value","Bridgness"end -- Send on witch value bridgness , 99 and then xx
local function LUX(lux) return fibaro.getValue(lux,"value"end -- Get value for lux level
 
Then Get value
 
for _,lux in ipairs(lux) do -- Show lux level at this moment
  DEBUG("Actual nivel Lux %s = %d",NAME(lux),LUX(lux))
end
 
conditional for change value in ON Bridgness.
 
if LUX(lux) <= 100 then -- I have and error , but o dont know , i have lux ( id of luxsensor ), funtion LUX(lux) , I think get value sensor ... Yes or not?.
    Bridgness = 99
elseif LUX(lux) > 101 and LUX(lux) < 150 then
    Bridgness = 80
elseif LUX(lux) >= 150 and LUX(lux) < 200 then
    Bridgness = 60
elseif LUX(lux) >= 200 then
    Bridgness = 40
end      
 
 
Many Thank's
 
 

 

 

Link to comment
Share on other sites

13 hours ago, SmartHomeEddy said:

@Benrive can you post your complete code? 

Yes, Of course.

 

local light = {55,59,60-- ID's of all the lights to turnOn and turnOff
local garageLight = 59 -- ID Garage light to exclude if already on
local laundryLight = 60 -- ID Laundry light to exclude if already on
local motion = {64-- ID's the Motions
local lux = {65-- ID's the Lux just the show the lux level, nothing more
local maxTime = 1*10  -- Maximum time to wait to turnOff the lights
local sleepTime = 5 -- Check motioon interval (default = 5)
local safeTime = 0 -- Default value to count until maxTime is reached
local debug_TAG = "Temporizador de luces: " ..sceneId -- Tag for the debug messages
local Bridgness = 99 -- Next change this value 
 
local function DEBUG(fmt,...) fibaro.debug(debug_TAG,string.format(fmt,...)) end
local function isON(light) return fibaro.getValue(light,"value"end
local function ON(light) fibaro.call(light,"value","Bridgness"end -- Send on witch value bridgness
local function OFF(light) fibaro.call(light,"value",0end
local function NAME(dev) return ""..dev..":"..fibaro.getName(dev) end
local function LUX(lux) return fibaro.getValue(lux,"value"end -- Get value for lux level
local function BREACHED(sensor) return fibaro.getValue(sensor,"value"end
 
if isON(garageLight) > 0 and isON(laundryLight) > 0 then -- Check if the garage and Laundry lights is allready on
  light = {55-- ID's of all the lights to turnOn and turnOff
elseif isON(laundryLight) > 0 then -- Check if the Laundry lights is allready on
  light = {55,59-- ID's of all the lights to turnOn and turnOff
elseif isON(garageLight) > 0 then -- Check if the Garage light is allready on
  light = {55,60-- ID's of all the lights to turnOn and turnOff
end
 
local luxAverage = 0;
for i = 1,#lux do 
    luxAverage = luxAverage + tonumber(fibaro.getValue(lux[i], "value"));
end
luxAverage = roundit( (luxAverage / #lux), 0 );             
return luxAverage;
 
for _,light in ipairs(light) do -- Turn On the lights and dimmer
  DEBUG("Enciende %s durante %d segundos",NAME(light),maxTime)
  ON(light)
end
 
for _,lux in ipairs(lux) do -- Show lux level at this moment
  DEBUG("Actual nivel Lux %s = %d",NAME(lux),LUX(lux))
end
 
if luxAverage <= 100 then 
    Bridgness = 99
elseif luxAverage > 101 and luxAverage < 150 then
    Bridgness = 80
elseif luxAverage >= 150 and luxAverage < 200 then
    Bridgness = 60
elseif luxAverage >= 200 then
    Bridgness = 40
end      
 
while safeTime < maxTime do -- Loop until maxTime is reached
  fibaro.sleep(sleepTime*1000)                 
  safeTime=safeTime+sleepTime 
  DEBUG("Segundos encendido %d hasta %d segundos",safeTime,maxTime)
  for _,motion in ipairs(motion) do 
    if BREACHED(motion) then -- Check se Motion violado(s)
      DEBUG("Hay movimiento,reseteo tiempo %s",NAME(motion))
      safeTime = 0 -- Reset safeTime 
    end
  end
end 
 
for _,light in ipairs(light) do
  DEBUG("Apago %s",NAME(light))
  OFF(light)           -- TurnOff the lights
end
Link to comment
Share on other sites

I think you have to put the “if luxAverage <= 100 then ” part above the “for _,light in ipairs(light) do” part. That way you first set the brightness level and then you turn on the lights at the right brightness level. 
 

Or do you get an error message?

Link to comment
Share on other sites

On 9/10/2021 at 10:12 PM, SmartHomeEddy said:

I think you have to put the “if luxAverage <= 100 then ” part above the “for _,light in ipairs(light) do” part. That way you first set the brightness level and then you turn on the lights at the right brightness level. 
 

Or do you get an error message?

 

Hi, @SmartHomeEddy.

 

I have reset my home center to change the motor to Zwave 3. I have to reconnect all the zwave, when I have it I will try again. Luckily I only had 4 or 5 units connected out of the almost 40 that I will have.

 

I'll try everything and tell you, but I remember I had an error with a conditional.

I tell you as soon as it purifies to try

Link to comment
Share on other sites

  • 3 weeks later...

Thansk for sharing this Chiel-S!

 

I used the code to build my own countdown solution. It is more basic then you created (only 1 LUX sensor, no difference in day and night).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...