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

25 minutes ago, Sjakie said:

if you want I can send in pm something I use for curtains but I have used something similar also for blinds

 

@Sjakie yes please! thank you so much in advance

Link to comment
Share on other sites

This works as a charm for myIPhone.

for Iphone this works great

Home:

Rule.eval([[#location{id=20,property=219,value='enter'} => 
    $Locatie_Sjaak = 'Thuis';
        log('#C:aqua#  $Locatie_Sjaak is - Thuis');
        fibaro.call(1209"sendMessage""302 - Let Op: Sjaak is Thuis",817111904)
]]).start()
Away:
Rule.eval([[#location{id=20,property=219,value='leave'} => 
    $Locatie_Sjaak = 'Vertrokken'
        log('#C:aqua#GV $Locatie_Sjaak - Vertrokken');
        fibaro.alert('push', user, '302 -Let Op: Sjaak20 vertrokken')
]]).start()
Link to comment
Share on other sites

12 minutes ago, jgab said:

Well, profile as not very well managed in ER4.

You need to get the id of the Home profile and then compare that id to the active profile's id. Like this

 

Please login or register to see this code.

 

ah ok thanks. that seems simple enough.  I do have scenes that run tests on motion sensors to determine profiles such as Home/Away/Vacation etc so I guess I can use ER to trigger those scenes

 

Any suggestions on how i can use Weather to trigger blinds while i trouble @Sjakie to show me his examples? :)  

Link to comment
Share on other sites

this what I use, don't forget to create Global Variables.

--https://openweathermap.org/weather-conditions

 

Please login or register to see this code.

 


 

Link to comment
Share on other sites

  • Topic Author
  • 19 minutes ago, Angelus said:

    ah ok thanks. that seems simple enough.  I do have scenes that run tests on motion sensors to determine profiles such as Home/Away/Vacation etc so I guess I can use ER to trigger those scenes

     

    Any suggestions on how i can use Weather to trigger blinds while i trouble @Sjakie to show me his examples? :)  

    Well, ER4 doesn't have anything special for weather but it can react on system weather events.

    rule("#weather{property=<prop>, value=<newValue>, old=<oldValue>} => ....")

    What you can do is setup some trigger variables for some of the weather data you are interested in.

    Please login or register to see this code.

     

    Edited by jgab
    Link to comment
    Share on other sites

    18 hours ago, jgab said:

     

    Try to make a api.post('/service/reboot',{recovery=false}) outside the rule somewhere in main() and see if it works.

    ER just translates it to a standard Lua api.post('/service/reboot',{recovery=false}) and calls it.

    it's dont  work anywhere

    Edited by fastvd
    Link to comment
    Share on other sites

  • Topic Author
  • 12 minutes ago, fastvd said:

    it's dont  work anywhere

    Then it's not ER's fault :-)

     

    I know that there has been discussions about api reboot and shutdown have had issues - have a search in the forum...

    Link to comment
    Share on other sites

    10 hours ago, jgab said:

    Then it's not ER's fault :-)

     

    I know that there has been discussions about api reboot and shutdown have had issues - have a search in the forum...

    thanks...i found lua command for this:

    fibaro.homeCenter.systemService.reboot() 

    Link to comment
    Share on other sites

  • Topic Author
  • 6 hours ago, fastvd said:

    thanks...i found lua command for this:

    fibaro.homeCenter.systemService.reboot() 

    but that's not available from QuickApps ?

    Link to comment
    Share on other sites

    4 hours ago, jgab said:

    but that's not available from QuickApps ?

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • Yes, that function is not available from QuickApps for some strange reason - only Scenes. Maybe Fibaro will add it to QuickApps in the future...

    Link to comment
    Share on other sites

    @jgab

    Hello Jan

    Can we construct complex variables using rules? Can we uise rules for defining table type variables?

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 12 hours ago, Neo Andersson said:

    @jgab

    Hello Jan

    Can we construct complex variables using rules? Can we uise rules for defining table type variables?

     

    Please login or register to see this code.

     

    Well, you can only have complex key-value tables where the key is a symbol - which means that you can't have a number as the key. (array table {'a','b','c'} has implicit number keys)

     

    rule("remoteButtonToBlinds = { office_remote_controller = { key3 = office_blinds1, key4 = office_blinds2}, livingroom_remote_controller = {key1 = livingroom_blinds1, key2 = livingroom_blinds2}}")

    works, so construct a symbol index to address the table

    rule(" ...  remoteButtonToBlinds[controller]['key'++keyId] ... ")

     

    In Lua in general it is usually not a good idea to have complex tables with numbers as key, because you have in effect created a table with holes in them (for entries with no index)

    Your remoteButtonToBlinds table will end up as  { [1]=nil, [2] = nil, [3] = office_blinds1, [4] = office_blinds2} in Lua

    The problem one can encounter is that we can't json encode the tables (json don't allow sparse arrays), and we can't loop over the tables with something like for _,e in ipairs(<table>) do ...

     

    ...but I understand your need and I have created those tables myself. See if you can use the 'key'+ trick above.

     

    In ER5 I allow expression as keys like Lua does... ;-) 

    • Like 1
    Link to comment
    Share on other sites

    6 hours ago, jgab said:

    Well, you can only have complex key-value tables where the key is a symbol - which means that you can't have a number as the key. (array table {'a','b','c'} has implicit number keys)

     

    rule("remoteButtonToBlinds = { office_remote_controller = { key3 = office_blinds1, key4 = office_blinds2}, livingroom_remote_controller = {key1 = livingroom_blinds1, key2 = livingroom_blinds2}}")

    works, so construct a symbol index to address the table

    rule(" ...  remoteButtonToBlinds[controller]['key'++keyId] ... ")

     

    In Lua in general it is usually not a good idea to have complex tables with numbers as key, because you have in effect created a table with holes in them (for entries with no index)

    Your remoteButtonToBlinds table will end up as  { [1]=nil, [2] = nil, [3] = office_blinds1, [4] = office_blinds2} in Lua

    The problem one can encounter is that we can't json encode the tables (json don't allow sparse arrays), and we can't loop over the tables with something like for _,e in ipairs(<table>) do ...

     

    ...but I understand your need and I have created those tables myself. See if you can use the 'key'+ trick above.

     

    In ER5 I allow expression as keys like Lua does... ;-) 

    Jan i have tried your suggestion

    Please login or register to see this code.

    but it still throws the same error, table index is nil
    Link to comment
    Share on other sites

  • Topic Author
  • You'd couldn't use the computed index so take away the brackets and use a precomputed key (no 'ctrl'++...)

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, Neo Andersson said:

    Jan i have tried your suggestion

    Please login or register to see this code.

    but it still throws the same error, table index is nil

     

    ...or you build the table in Lua.

    Please login or register to see this code.

    This assumes that you already declared the office_remote_controller, office_blinds1 etc. with rules or Util.defvars so that they are visible in ER rules. The EV function fetches the declared ER variables.

     

     

    Then you can have easier rules I guess...

    Please login or register to see this code.

    Link to comment
    Share on other sites

    33 minutes ago, jgab said:

     

    ...or you build the table in Lua.

    Please login or register to see this code.

    This assumes that you already declared the office_remote_controller, office_blinds1 etc. with rules or Util.defvars so that they are visible in ER rules. The EV function fetches the declared ER variables.

     

     

    Then you can have easier rules I guess...

    Please login or register to see this code.

     

    Please login or register to see this code.

     

    Edited by Neo Andersson
    • Like 1
    Link to comment
    Share on other sites

    @jgab Hello Jan

    What is the best way to add 14 day to a given date (using rules)

    Please login or register to see this code.

     

    Edited by Neo Andersson
    Link to comment
    Share on other sites

    @jgab Hello Jan. The IF THEN END pattern for rule is || <condition> >> <action>. But how to append the ELSE logic? || <condition> >> <action1> else???? <action2>

    What is the syntax?

    thanks

    Link to comment
    Share on other sites

  • Topic Author
  • Well, the ||>> is already an if-then-else

     

    Please login or register to see this code.

    ...etc

     

    Note, no ';' after last expression in then-do-this

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