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

Basic Code Clips for LUA starters


Question

Posted

To help those that are not familiar with LUA a starter library of clips that work in Fibaro.

Please add any you find useful.

  • Answers 151
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Posted Images

Recommended Posts

  • 0
Posted

HansW, yes that is a comment line but we took from that information for our scene engene

  • 0
Posted

Please login or register to see this code.

Cool!

Tested this one. Brilliant!! Many thanks

Is there a list somewhere of the Fibaro functions and their syntax to be used?. It works fine but I don't understand for instance what the fibaro:call(2,.. so the value 2, actually does.

Regards,

Hans

  • 0
Guest deraaij
Posted

Based on jompa68 code. I changed the code bit so it will:

* Run every 5 minutes

* Logs if it finds a device which is dead.

* Tries to wake the device.

* If waking the devices fails, send's an email.

* If no issues are found it also log's it.

Please login or register to see this code.

BTW did not do extensive testing....

  • 0
Posted

Please login or register to see this code.

Cool!

Tested this one. Brilliant!! Many thanks

Is there a list somewhere of the Fibaro functions and their syntax to be used?. It works fine but I don't understand for instance what the fibaro:call(2,.. so the value 2, actually does.

Regards,

Hans

the fibaro:call(2, "sendEmail",.... is the ID of users 2 emailaddress.

To see what id a certain user have you use

Please login or register to see this link.

and search for the email address you want to send to and put that ID in after fibaro:call

[ Added: 2013-03-19, 19:44 ]

Battery Level and sendPush

Please login or register to see this code.

Have not test it 100%, i don't have battery operated things

Please login or register to see this image.

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

  • 0
Posted

I made the following code for emailing all dead nodes in one email message. I don't want a separate email for each dead device in case of power failure.

Please login or register to see this code.

This works. However, when the number of Devices gets larger (about 8 ID's in the Devices array) the system crashes. When I delete the SendEmail line everything works correct (including the fibaro:debug statement) and no crash occurs.

Is it possible there is a restriction on the number of characters in an email using SendEmail? Or maybe a bug?

  • 0
Posted

Here is a simple code that will notify you when any window/door is opened and make additional check every 30 minutes to remind you if it's still open.

Good for cold winter days

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" />

Please login or register to see this code.

  • 0
Guest dsilletti
Posted

Please login or register to see this code.

Cool!!!

Now that we can know names, better use names, isn't it?

Please login or register to see this code.

Now a question, how to write in LUA that scene must run every 1 hour?

(I don't want to copy all the times the text generated by blocks and converted to LUA

Please login or register to see this image.

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

ok I got it, via fibaro:sleep(milliseconds)

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" />

Regards

Domenico

  • 0
Posted

If i go LUA will that affect ALL my scenes or can i try it out on only the scenes i choose to switch to LUA?

  • 0
Guest PJ
Posted

I used Jonny's code and changed it so it reports all battery operated devices and also sends push with information about all of them

Please login or register to see this code.

I have one question - is it possible in this case to loop push command somehow, so it can be send using only one message (information about single device in new line)?

EDIT:

I use polish words in my code: nazwa=name, urzadzenie=device, poziom baterii=battery level - but it should be clear anyway.

  • 0
Guest PJ
Posted

Thank you very much:) It just took me 10 minutes on google to search for function that append strings, just to find out I have to use ".."

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" />

I have not tested the max size of message you can push but would expect a limit.

Yep, that's right. I was able to make list for only 6 devices (with their names) in single push (but I have quite long names of devices :-> When I used only devices' IDs list could be longer) The problem is, that if there is more devices, it doesn't show any error. It just doesn't send push.

Please login or register to see this code.

  • 0
Guest PJ
Posted

Yes, that is very good idea, thanks.

  • 0
Posted

Battery Level and sendPush

Please login or register to see this code.

Hi, I tested this code and it's working well. A question how to have name instead of id device in email/push sent?

  • 0
Guest PJ
Posted
Hi, I tested this code and it's working well. A question how to have name instead of id device in email/push sent?

Just use fibaro:getName(i) instead of i

  • 0
Posted
Just use fibaro:getName(i) instead of i
Where exactly in the code? Sorry I'm just starting to learn LUA code

Please login or register to see this image.

/emoticons/default_icon_redface.gif" alt=":oops:" />
  • 0
Guest PJ
Posted
Where exactly in the code? Sorry I'm just starting to learn LUA code

Please login or register to see this image.

/emoticons/default_icon_redface.gif" alt=":oops:" />

Sorry, me too

Please login or register to see this image.

/emoticons/default_icon_redface.gif" alt=":oops:" />

This is correct code:

Please login or register to see this code.

I changed it in these two lines:

fibaro:debug("DeviceID = "..i)

fibaro:call(2, "sendPush", "Low battery on id:"..i)

it should work now

  • 0
Posted

Hi, I have modified a bit this code as in case of FGK door_sensors it was showing Slave devices with NILL battery levels. Additionally in case of Danfoss Thermostats if the battery is very low it shows the value 255. I also prefer to receive the info by e-mail. I hope it helps.

Please login or register to see this code.

  • 0
Guest dsilletti
Posted

Hi all,

how to add message to the emails sent by LUA?

with the previos code (e.g. the Dead Nodes code), only the subject of the email is provided,

I need to fill the email message too.

This can be very useful in my case using Clickatell EMAIL to SMS API, but can be the solution to provide in 1 single email a long text (to report all dead nodes or all battery op. devices with low battery, etc etc)

regards

Domenico

[ Added: 2013-03-28, 22:46 ]

Another question,

Please login or register to see this code.

doesn't work?

Thanks in advance

Domenico

  • 0
Posted
how to add message to the emails sent by LUA?

with the previos code (e.g. the Dead Nodes code), only the subject of the email is provided,

I need to fill the email message too.

Use fibaro:call(2, "sendEmail", "Email subject", "Email content"), The text in the last argument is the content of the email message.

[ Added: 2013-03-28, 22:46 ]

Another question,

Please login or register to see this code.

doesn't work?

Must be elseif.

  • 0
Guest dsilletti
Posted
how to add message to the emails sent by LUA?

with the previos code (e.g. the Dead Nodes code), only the subject of the email is provided,

I need to fill the email message too.

Use fibaro:call(2, "sendEmail", "Email subject", "Email content"), The text in the last argument is the content of the email message.

[ Added: 2013-03-28, 22:46 ]

Another question,

Please login or register to see this code.

doesn't work?

Must be elseif.

thank you gilbert, the Email content works like a charm,

the elseif, insted, return me an error:

Please login or register to see this code.

maybe I'm wrong... My scene should monitor 3 motion sensors and if armed and breached, send Notifications with the room name, then sleep 30 seconds (Usually motion sensors generate a lot of alarm in few seconds when motion is detected)

is this code correct?

Please login or register to see this code.

regards

Domenico

  • 0
Posted

look here

Please login or register to see this code.

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