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

7 minutes ago, SmartHomeEddy said:

 

(Buitenradar Weather measures data within the Netherlands)


Ahh well, then it is useless for @Benrive (sorry for that)

Link to comment
Share on other sites

Guest Benrive

Hi ,

@ppeterr I'm from spain, 
I am also testing the script that has been recommended to me @SmartHomeEddy.

It is quite adapted to my needs, although from what I have seen in 1 hour.

I have been with it, the lux level is measured but nothing is done with it. I have to investigate because if I want to use this.

 

Thx

Link to comment
Share on other sites

19 minutes ago, Benrive said:

I have been with it, the lux level is measured but nothing is done with it. I have to investigate because if I want to use this.

The lux level can be used in the "DECLARATIONS (Conditions/Triggers)". In the script itself the lux level is only shown, to know why the lights went on, so you can finetune the conditions/triggers. 

 

So your condition will probably be "motion" and "lux level low enough". Then lux will be part of switching your lights on and off.

 

 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

Guest Benrive

Hi Again,

I have the lux sensor in <= 40 , but the light it's on ?¿?¿?, Why?. The value of lux sensor now its 69.,

 

 

{
      id = 27,   -- LUX
      isTrigger = false,
      operator = "<=",
      property = "value",
      type = "device",
      value = 40,
          } },
Edited by Benrive
Link to comment
Share on other sites

Guest Benrive

Hello,
I'm happy, it's working almost perfect for me.

But I would need to add one more condition, when the light is turned on manually, how could I go about skipping the off time as well as having the option to skip the lux level as well?

Link to comment
Share on other sites

Guest Benrive

SOLVED:

I think I found it, made a block scene and compared it.

The problem is in Operator is "all" nor Any.

 

Hello,
Can you help me know why it shoots, if the current lux level is 45?, I don't see any sense.

 

{
  conditions = { {
      id = 25-- Motion
      isTrigger = true,
      operator = "==",
      property = "value",
      type = "device",
      value = true
    }, {
      id = 27-- Lux
      isTrigger = false,
      operator = "<=",
      property = "value",
      type = "device",
      value = 300
    } },
  operator = "any"
}

 

Edited by Benrive
Link to comment
Share on other sites

Guest Benrive

Hello,
I am thinking about the idea that I commented previously to control if it is turned on manually.
I think we should create a variable that evaluates if the light has been turned on manually .

 

That is the idea, the problem is that I do not know how to create this variable, it must recognize if the light is on (I think this would not work because the scene run again), it would have to recognize if it was turned on manually, and this does not know how it should be done.

Any ideas?

Link to comment
Share on other sites

24 minutes ago, Benrive said:

The problem is in Operator is "all" nor Any.

 

I think it should be all. You want to turn on the light if there is motion and only if it is dark enough. 

 

11 minutes ago, Benrive said:

I am thinking about the idea that I commented previously to control if it is turned on manually.

 

It depend a bit on your situation. If you can turn on the light manually (or with an other script) without being detected by the motion sensor, it is different than first trigger the motion sensor and then turn on the light manually. 

 

In the other post, there is an alternative script that detects if the light was already on, before motion (and less lux) was detected. If so, the script won't turn off the light if there is no more motion. 

 

 

 

Link to comment
Share on other sites

Guest Benrive
1 hour ago, SmartHomeEddy said:

 

I think it should be all. You want to turn on the light if there is motion and only if it is dark enough. 

 

 

It depend a bit on your situation. If you can turn on the light manually (or with an other script) without being detected by the motion sensor, it is different than first trigger the motion sensor and then turn on the light manually. 

 

In the other post, there is an alternative script that detects if the light was already on, before motion (and less lux) was detected. If so, the script won't turn off the light if there is no more motion. 

 

 

 

 

Yes, Yes Yes.... Amazing!!.

 

This is just what I need, I have already adapted it and created 3 virtual lights to test.
I love it, I'm getting a taste for it and I'm learning fast

Link to comment
Share on other sites

Well done ?

 

If you start to understand the conditions and that lua code, the whole world is at your feet

 

 

 

 

At least a part of it ?

Link to comment
Share on other sites

Guest Benrive

Hi @SmartHomeEddy

 

Yes, for me it is being easy to understand it and even make modifications, but from that to create it from 0, I still have a few questions.
Thank you very much, until today I had not managed to do what I had in my mind.

 

As my grandfather said.
The important thing is not to know, it is to have the phone number you know.

Edited by Benrive
Link to comment
Share on other sites

Guest Benrive
I am implementing to be able to regulate the brightness depending on the lux level, but I am not doing the comparisons well, I have error in the Lux comparison.
Forgive, but I only know VBA and LUa is very different.
 
if ( LUX <= 100 ) then -- check Lux at moment
    BRIGHTNESS = 99
elseif ( LUX > 101 and < 150 ) then
    BRIGHTNESS = 80
elseif ( LUX >= 150 and < 200 ) then
    BRIGHTNESS = 60
elseif ( LUX >= 200 and <= 250 )  then
    BRIGHTNESS = 40
end    
Link to comment
Share on other sites

the second comparison should also contain LUX < 150 for all elseif

 

Please login or register to see this code.

 

 

(and maybe make the last elseif LUX >= 200, so you always have a value in BRIGHTNESS in case the lux level is greater than 250)

 

 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

Guest Benrive
32 minutes ago, SmartHomeEddy said:

the second comparison should also contain LUX < 150 for all elseif

 

Please login or register to see this code.

 

 

(and maybe make the last elseif LUX >= 200, so you always have a value in BRIGHTNESS in case the lux level is greater than 250)

 

 

 

 

it is not necessary, since the trigger does not pass it acts in case of light> 250. But I am going to put it like this anyway.

 

But I have and error.

 

This the funtion.

local function LUX(lux) return fibaro.getValue(lux,"value"end
local function BRIGHTNESS(Light) fibaro.call(light,'setValue',50 ) end

 

(load):32: attempt to compare function with number

Assertion failed: Expected number

Edited by Benrive
Link to comment
Share on other sites

Guest Benrive

Hello @SmartHomeEddy, can you help me again please.

 

He made some modifications, to adapt this script to dimmable lights, and regulate the intensity according to certain lux in the room.
I copy you the complete script, because I cannot make it work correctly.

 

I have changed the variable IsON and ON to adapt it to the dimmers, Value 99 or Value 0.

 

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 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","ON"end
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,"Setvalue"end
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
 
for _,lux in ipairs(lux) do -- Show lux level at this moment
  DEBUG("Actual nivel Lux %s = %d",NAME(lux),LUX(lux))
end
 
if LUX <= 100 then -- check Lux at moment
    ON = 99
elseif LUX > 101 and LUX < 150 then
    ON = 80
elseif  LUX >= 150 and  LUX < 200 then
    ON = 60
elseif  LUX >= 200 then
    ON = 40
end       
 
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
 
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

If you try to send a value to the function ON(), then you should loose the quotes:

 

Please login or register to see this code.

 

(I wouldn't call a variabel ON the same as the function ON, my brain cannot handle that :-) hope Fibaro can)

 

 

And I don't understand what you are trying to do with de lux level. You changed? 

 

Please login or register to see this code.

 

In this part

 

Please login or register to see this code.

 

is LUX a variable?

 

 

 

 

 

Link to comment
Share on other sites

  • 3 weeks later...
Guest Benrive

Hello @SmartHomeEddy
Sorry for the delay, I was on vacation for a few days and no connection.
I'm going to go back to this and make the changes you propose. Any questions I ask.
I have already changed the things that you have previously told me.
Thank you so much

Link to comment
Share on other sites

On 8/10/2021 at 9:54 AM, ppeterr said:

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

 

 

On 8/10/2021 at 9:54 AM, ppeterr said:

I made this only for the daytime, when it gets a little dark outside.

Its not anything special :) But here it is. I assume you can make a block scene

that turns on the light when it is below a certain lux value. For that i use a normal

lux sensor. Turning the lights of when its not needed anymore, i use the "light power"

value from the Buienradar Weather app that @SmartHomeEddy made. (only for europe i think)

That gives me values (like: the sun is shining) from a wheather station wich is about 15mins from my home.

 

4 blocks on the left.

 

the first checks if the light level inside the house is > 500 lux

the second checks the value from the sunpower outside > 150

the 3th checks if the lamp is atually on

the 4th is the daytime setting.

 

2 blocks on the right (action if all true)

 

1st - turn the lights of

2nd - Let my echo show in the living room say "i turned the lights of"

 

 

Please login or register to see this attachment.

 

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...