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


Recommended Posts

Guest Benrive
Posted
On 1/10/2022 at 7:22 PM, SmartHomeEddy said:

You get an error: 
(load):18: Assertion failed: Expected number

 

Your variabel:

luxSensor = {216}

 

Try:

luxSensor = 216

 

Thank's @SmartHomeEddy 

I have installed All in One and it is true that it is much easier for me to be able to do what I need. It is a great utility... I imagine that it will also have its limitations. But so far I have achieved this without much effort.
Thank you.

  • 9 months later...
Posted (edited)

Hi all!

 

I would like to turn on/off lights in the rooms based on lux (average) and motion of course and different light settings for day, evening when it's dark, but we can watch tv ... , and night when for example the motion trigger the lights on special mode - like in the bedroom,...

 

Can  you recommend a script which I can duplicate in every room to control the lights?

Fibaro Motion sensor  and for switching > Fibaro Dimmer 2 with only light on/off and dimming >2,3 leds/device 

On HC3

Edited by iTibor
add more info
  • 3 months later...
Posted
On 8/2/2020 at 9:20 PM, chiel-s said:

 

Hi,

 

I want to share my automatic lightning system with the community. It controls my lights in a room based on motion sensors and average lux in the room. It’s build for HC3.

 

Goals:

-    I don’t want to use any buttons in this room, lights should turn on automatic by motions sensors
-    I want to measure the lux average and based on this value the lights turn on.
-    I want to have the ability to include exceptions, such as TV is on or Sonos is playing. In that case I don’t want the script to turn off the lights when there is no motion.
-    I want different light settings for day and night. I also want to reuse these light settings and don’t want it to integrate it into the motion script.
-    I want to reuse the scripts easily for other rooms.

 

Good to know:

-    The basic of the

Please login or register to see this link.

is from

Please login or register to see this link.

 
-    I was also inspired by this

Please login or register to see this link.

(but it's build for HC2) 
-    I bought a HC3 couple of weeks ago and I am totally new into LUA.
-    I am not a professional software engineer. I am sure my code is not the best and can be improved. Feel free.
-    I post this information for beginners and amateurs like me. Spent a lot of time finding the correct information because most of the scripts are created for HC2 and is not always easy to migrate to HC3.
-   Below a step by step guide to achieve above goals.
 

Step 1: Measure the average lux in the room

-    Create a global variable. In my script “luxAverageKitchen”.
-    Make sure to change Fibaro Motion Sensor parameter 40 (set it to 5lux) and parameter 42 (set it to 900s) of all the motions sensors that you want to use for calculating the average lux in the room. In my script I use sensor 69 and 38.

- Make sure to set this script to automatic.

 

Calculate average lux scene

 

Triggers

Please login or register to see this code.

Actions

 

Please login or register to see this code.

 

 

Step 2: Set TV Status

In the motion script we need the TV status. I use Fibaro wall plugs for my TV in the living room and the TV in the bedroom.

-    Create a global variable for each TV (tvLivingStatus and tvBedroomStatus in my script)

-    Device ID 44 is my TV in the living room and is used in the motion script.

- Make sure to set this script to automatic.

 

Set TV Status scene

 

Triggers

Please login or register to see this code.

Actions:

 

Please login or register to see this code.

Step 3: Motion script
- Now finally the script that runs after motion detection. Please make sure that you fill in the correct global variables and id’s.

- Make sure to set this script to automatic.

 

Motion Scene:

 

Triggers

 

Please login or register to see this code.

Actions

 

Please login or register to see this code.

 

Step 4: Manage all room lights from 1 Quick app (optional)

 

-   As you can see I only use 1 light in the motion script, id 65 refers to a quick app managing all the lights of the ground floor.

-  This way I can easly switch on all lights using Google home, the app or maybe in the future a button.
-    Make sure to create a global variable for the Day/Night settings (from 06:00 till 02:00 Day is set, from 02:00 till 06:00 Night is set in the script). In my script the global variable it is called “SetTimeOfDayLights” and only has two variables: Day or Night.
-    Below you can find the scripts.

 

SetTimeOfDayLights scene

 

Triggers

 

Please login or register to see this code.

Actions

 

Please login or register to see this code.

 

Quick app (Lights switch for whole room)

-    Create a quick app by using the Binary switch template.

- Go to the device --> Edit & Preview --> Edit

- Paste below code.

 

Please login or register to see this code.

 

 All these scripts are working great on my HC3 (5.040.37) . But in my log file I see (sometimes) an error is occurring in the motion scene without any information in the debug line. If someone knows what it is, let me know ;-)


That's it. Enjoy! 

 

 


 

 

 

 

Hi 

The  "Step 1: Measure the average lux in the room"  and "Step 3: Motion script"   I have to write to each room separately?

  • 8 months later...
Posted

Hi 

 

Periodically I get this  on debug console : [ERROR] [SCENE96]:

the light on off controls working but I get this error

 

 

  • 6 months later...
Posted

Hi all

 

I use these Lua scripts, on HC3, and I use 24V power supply and RGBW Controllers 2  (7 devices )to command  LED lights and I use only 2 outputs to not to overload the controller.

 

Everything works fine, the lights turn on and off , but sometimes about once a week all the lights starts turn on only after 30 sec delay, all of them, and after a day they came back to work okay ( instant on ).

 

Any clue?

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