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

  • Topic Author
  • Ok, pushed V3 B40

     

    Be aware you need to fix your Hue setup.

    Hue.connect(<hue name>,<ip>)

    Hue.define(name, nil,id) -> Hue.define(name,id)

     

    Change nodered() to Nodered() if you used it.

    I encourage you to start using Nodered.post() instead of remote(...)

     

    Link to comment
    Share on other sites

    Please login or register to see this code.

    Please login or register to see this image.

    /monthly_2019_08/image.png.b4c195d67af7e442e454ca25127a5653.png" />

    should it not be user on line 2562 instead of username?

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • 12 minutes ago, jompa68 said:

    Please login or register to see this code.

    Please login or register to see this link.

    should it not be user on line 2562 instead of username?

     

     

    Yes, you can remove _HueHubs and just do

    Hue.connect(_HueUserName,_HueIP)

    The third optional argument to Hue.connect is to name the Hub if you connect to many bridges.

    Ex. Hue.connect(_HueUserName1,_HueIP1,"Hub1"); Hue.connect(_HueUserName2,_HueIP2,"Hub2")

     

    and while you are at it do

    Nodered.connect(_defaultNodeRed)

    too.

    and start using Nodered.post(<event>) instead of remote(_myNodeRed,<event>)

     

     

    Edited by jgab
    Link to comment
    Share on other sites

    i have this line for define and does not work,

    Please login or register to see this code.

    Please login or register to see this image.

    /monthly_2019_08/image.png.512386c5ed4a73952dcda7a8b903aa81.png" />

     

    my hometable looks like this for hue

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 6 minutes ago, jompa68 said:

    i have this line for define and does not work,

    Please login or register to see this code.

    Please login or register to see this link.

     

    my hometable looks like this for hue

    Please login or register to see this code.

     

     

    No, I just discovered that... I'm working on a fix - soon back...

    Link to comment
    Share on other sites

  • Topic Author
  • Hmm, Hue is broken now.

    The problem I have is that all calls to Hue is asynchronous. It means that when we do a call to Hue it takes a while and then we get a result. Meanwhile the rest of the code is executing,

    When we do a Hue.connect() it will take a while before we get the answer that among other things updates what devices are available in the Hue hub.

    If we directly afterward do a Hue.define it will not find the device as the previous connect has not completed yet.

     

    Previously I did the Hue setup and waited for it to complete before we called main() so then it worked. Now we call Hue.connect() in main() and it doesn't...

    One way is to move it back like it was before but it was a bit complicated too and I kinda liked to have a uniform model for Hue, Nodered, and Telegram...

     

    Ok, a fix. I pushed V3, B42.

    So, the way I have solved it for now is to have an extra function before main where you add your Hue.connect() commands.

    Only the Hue.connect(), Hue.define etc you do in main() as usual. I make sure that the connect() done in HueSetup() will finish before calling main()

    Ex.

    Please login or register to see this code.

     

    I will try to slow down with changes that break your scenes now :-) 

    Edited by jgab
    Link to comment
    Share on other sites

    54 minutes ago, jgab said:

    Ok, a fix. I pushed V3, B42.

    So, the way I have solved it for now is to have an extra function before main where you add your Hue.connect() commands.

    Only the Hue.connect(), Hue.define etc you do in main() as usual. I make sure that the connect() done in HueSetup() will finish before calling main()

    Working again, thanks @jgab

    54 minutes ago, jgab said:

    I will try to slow down with changes that break your scenes now :-) 

    OH NO! please don't slow down your excellent work and support on ER

    Link to comment
    Share on other sites

    On 8/8/2019 at 8:18 AM, jgab said:

    function main() Nodered.connect("http://192.168.1.50:1880/eventrunner") -- or Nodered.connect(myNodeRedVar) rule("Nodered.post(#echo{value=9})") -- post asynchronous rule("Nodered.post(#echo{value=9},true).value") -- post synchronous

    updated your example

     

    Please login or register to see this code.

     

    Edited by jompa68
    Link to comment
    Share on other sites

    Guest kallecux

    Hi there,

    i have an simple question in the "ER-community".

     

    How do you update the ER-Lua-Scripts in a smart way?

     

    It is not enough to replace the code after the end of 

    main().....end

     

    Greetings

    Karl Heinz 

    Link to comment
    Share on other sites

  • Topic Author
  • Just now, kallecux said:

    Hi there,

    i have an simple question in the "ER-community".

     

    How do you update the ER-Lua-Scripts in a smart way?

     

    It is not enough to replace the code after the end of 

    main().....end

     

    Greetings

    Karl Heinz 

     

    Normally it is. You also need to change the _version number.

    Link to comment
    Share on other sites

  • Topic Author
  • 17 hours ago, jgab said:

     

    Normally it is. You also need to change the _version number.

     

    ..and there is an even simpler way. 

    If you uncomment these lines in the ER scene' main() function

    Please login or register to see this code.

    It will check every morning at 06:00 if there is a new version of ER (look at my Github) and if so log a message to make you aware that there is.

    Then you can add another rule

    Please login or register to see this code.

    ...and it will download the latest version and patch the scene and restart.

    The two first rules are harmless to have enabled. The third should only be enabled when you decide to upgrade. Especially for V3 that is rapidly

    updated these days and sometimes (in the Fibaro tradition :-) ) comes with new bugs.

    However, I have the feeling that V3 is starting to stabilise...

     

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

  • Topic Author
  • posted V3, B44.

    The structure for ER now looks like

    Please login or register to see this code.

    Define your Hue, Nodered, and Telegram data in the beginning if you need them

    Please login or register to see this code.

    In HueSetup() you make the Hue.connect(_HueUserName,_HueIP) if they are defined. If you have many Hue bridges you can add mode Hue.connects here.

    (don't forget that Hue.define(name, var,id) has changed to Hue.define(name,id) )

     

    In main() do Nodered.connect(_NodeRed) if you need nodered functionality.

    Change your "remote(<nodered URL>,<event>)" to "Nodered.post(<event>).

    I will soon remove the possibility to do remote(<url>,<event>) and remote() will only be for sending events to other scenes and will only accept a SceneID (number) as first argument.

    I will soon also add (synchronous) http request if you need to call other urls.

     

    Telegram setup is a bit more involved.

    You can only do one Telegram.bot(_TelegBOT) as Telegram don't like that a bot is polled from multiple instances.

    However, you can still send Telegram messages without needing to do Telegram.bot(TelegBOT)

    It requires that you have the chat id and the bot key.

    Telegram.msg({_TelegCID,_TelegBOT},<message>)

    If you need to do that in a rule I recommend that you define a telegram ID variable. _TelegCID,_TelegBOT are local and not accessible inside rules.

    Util.defvar("TID",{_TelegCID,_TelegBOT}) -- define ER script variable with Telegram ID

    then you ca do

    rule("@sunset => Telegram.msg(TID, 'Time to wakeup!')")

    Because Telegram is setup in main() after HT is read in you can store telegram credentials in you HT table if you want.

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

    Jan, perhaps an automatic backup before the update to a newer version?

    Link to comment
    Share on other sites

    6 hours ago, jgab said:

    rule("#ER_version => log('Will update and restart...'); Util.patchEventRunner()")

    Wow thait is just wonderful. Your work is Awesome  ?

    Link to comment
    Share on other sites

    @jgab is my dwSensor:armed=false right?  this means setArmed=0?

     

    Please login or register to see this code.

    When i check the logs i see that it do setArmed=1

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 14 minutes ago, jompa68 said:

    @jgab is my dwSensor:armed=false right?  this means setArmed=0?

     

    Please login or register to see this code.

    When i check the logs i see that it do setArmed=1

    Please login or register to see this code.

     

    That's very strange. I test the same kind of code and it sets it to '0'.

    You run an old version of ER?

    Link to comment
    Share on other sites

  • Topic Author
  • 2 minutes ago, jompa68 said:

    B44

    If you just do

    rule(“55:armed=false”)

    change 55 for a real device? Still wrong? 

    Link to comment
    Share on other sites

    14 hours ago, jgab said:

    Still wrong? 

    I got this working now, was a mistype of logic at my end.

    Another issue with this rule, seems to work but nothing in NR

    Please login or register to see this code.

    AH! Sorry, my node-red is running on default port 1880. Copy&paste from your example was 8080 ?

    Edited by jompa68
    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...