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


  • 0

Ceiling Fan VD


Question

Posted

Good Day,

Can someone please help me with a script to achieve the following:

I have a ceiling fan with a light and 3 speed settings. I have created a VD with 4 buttons, One that turns the fan Off and the other 3 for the speed settings (Slow, Medium, Fast) using global cache ip2ir as the fan is controlled by infrared.

Now, i would like to make a scene that checks the Fibaro motion sensor's temperature and turn on or off the fan accordingly.

So, IF temp is above 26 Degrees - Turn on fan to low speed (Push button 2 on VD)

IF temp is above 29 Degrees - Turn on fan to Medium speed (Push button 3 on VD)

IF temp is above 31 Degrees - Turn on fan to High speed (Push button 4 on VD)

and if temp falls below 26 degrees turn OFF fan!

How can i do this?

Any help would be highly appreciated.

Thank You,

9 answers to this question

Recommended Posts

  • 0
Posted

Hi,

I'll help you - I'm on holidays and am learning LUA myself.

Just need a bit of time to sort an issue - I'm using 4.024 and I get "ACCESS DENIED" whenever I try to run a scene as admin

Please login or register to see this image.

/emoticons/default_sad.png" alt=":(" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

EDIT: ok.. it seems that even though the Alarm panel was showing "DISARMED", I had a motion sensor active and it was stopping me running / saving scenes.. I'll post where I'm up to soon.

[ Added: 2014-12-28, 10:52 ]

ok.. here is my first attempt..

Assumptions / Instructions

1) Not sure if you have labels on the virtual device. The follow note is published:

" Each element of a virtual device has a unique number starting from 1. If your virtual device has two labels followed by two buttons, the buttons will be numbered 3 and 4."

You may need to play around with the button numbers.

In this example, the button number is 4

Please login or register to see this code.

2) Everywhere you see the number 74, replace with the device ID of your temp sensor

3) Everwhere you see 31 [not 31.0], replace that with the device ID of your virtual device that controls the fan

4) There used to be a "start scene when Home Center boots" or something similar on the general tab. If you see that, make sure it's checked.

5) NOTE: I have programmed this without checking it as I don't have your virtual device. Let me know how you go, any problems etc.

6) Welcome any advice if anyone else notices something I did wrong

Please login or register to see this image.

/emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

Please login or register to see this code.

Let me know how you go. I can PM you my email address / skype details if it gets a bit difficult

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

  • 0
  • Inquirer
  • Posted

    Hi Scottm,

    Thank you for the help. Apologies for late reply. I was away on holiday.

    I get the following error below in screenshot. I am on latest firmware 4.024

    Please login or register to see this attachment.

    • 0
    Posted

    Change line 14 to:

    Please login or register to see this code.

    See if that helps.

    • 0
    Posted

    Thanks

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    Casting to a number should work .

    • 0
    Posted
    Thanks

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    Casting to a number should work .

    But maybe the 26.0 parts throw it off.

    Personally I wouldn't use the .0 part if it is a whole number your using anyway.

    But I can see in the example you maybe want to show it can be used or something like that.

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" />

    • 0
  • Inquirer
  • Posted

    Thank you guys!

    This seems to work. Not getting the error anymore. Will test properly and give feedback.

    • 0
    Posted
    Thank you guys!

    This seems to work. Not getting the error anymore. Will test properly and give feedback.

    Awesome!

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    Your welcome!

    • 0
    Posted

    I just noticed looking at your screenshot the first if statement is for >26 degrees, second is >28 etc. You need to do it in the order I did in my example or it will not work correctly.

    That's because 31 is greater than 26. Currently it will Push button 2 if hotter than 26 or off if < 26 but never react to other temps.

    • 0
    Posted

    Or you can change the lines to check for both values so like: (temp > 26) and (temp <= 28).

    Join the conversation

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

    Guest
    Answer this question...

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