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



jgab

Recommended Posts

  • Topic Author
  • Ok, I have just pushed v2.0, beta1.

    It consists of two main files. EventRunner.lua as before and HC2.lua (EventRunnerDebug.lua is gone)

    To install you only need a plain Zerobrain studio install and the two files mentioned. No FibaroSceneAPI.lua or json library.

     

    EventRunner.lua looks similar as before. It starts like this.

    Please login or register to see this code.

     

    In the beginning,

    Please login or register to see this code.

    it's possible to pass a name of the scene and a sceneID (EventRunner and 10 here) here.

    When the file is run, the dofile("HC2.lua") will start the emulator and register the file that called it (EventRunner.lua here)  as a scene in the emulator and run it.

    When a scene is run in the emulator the variable _EMULATED is defined to 'true'. THat's why we check for not _EMULATED to not call the emulator again when the emulator is starting up the scene.

     

    There are fever variables in the beginning as they have moved to HC2.lua. 

    Otherwise the EventRunner.lua is more or less the same and the execution on the HC2 should not differ.

     

    HC2.lua is the emulator where the environment is setup.

    _SPEEDTIME etc resides here.

    The file starts like this:

    Please login or register to see this code.

    The HC2.loadEmbedded() is what makes it load the file calling the emulator (the 'dofile' above).

    Otherwise you can tell it to load scenes from a directory at start up

    HC2.loadScenesFromDir()

    You can register individual files

    HC2.registerScene

    Some documentation is here

    If you instead of running the scene, run HC2.lua, you can still set breakpoints in the scene file if it is open in ZBS and it will break there.

    I usually set HC2.lua as the start file (right click in the project tab on the left in ZBS on HC2.lua and set as start file). Then I can edit any scene open in the editor, hit debug and the emulator will run.

     

    The iOSLocator and the Supervisor has moved to the subdirectory scenesER in the Github repository.

     

    Not all features are there yet but I believe that it is at least as good as the old way of doing things when running offline. 

    Try it out and ask me if something is not working or not clear.

    /J

     

    Edited by jgab
    Link to comment
    Share on other sites

    Continue here :D

     

    Please login or register to see this code.

     

    Edited by jompa68
    Link to comment
    Share on other sites

  • Topic Author
  • 2 minutes ago, jompa68 said:

    Continue here :D

     

    Ok, this is a mystery

    Can you go in to the Hue clipper web form and talk directly to the bridge and run the same url for lights/1 and see what it responds? or give an error?

    Please login or register to see this link.

     

    Link to comment
    Share on other sites

  • Topic Author
  • Can you replace the self.request in the Hue sections once more to this...

    Please login or register to see this code.

    ...you see what I'm starting to believe... ;-) 

    Edited by jgab
    str -> url
    Link to comment
    Share on other sites

    Did delete lightID 1 in Hue app,  rescanned lights so now it have a new ligthID (9)

    Did replace function but still the same error "Bad file descriptor"

    Link to comment
    Share on other sites

  • Topic Author
  • 2 minutes ago, jompa68 said:

    Did delete lightID 1 in Hue app,  rescanned lights so now it have a new ligthID (9)

    Did replace function but still the same error "Bad file descriptor"

    Ok,

    after this log in your previous post

    Please login or register to see this code.

    you get a "Hue connection:" error I guess. How does it look? Can you give the section of the log with the "Monitoring URL:.." log and "Hue connection:" error log? (now with light 9)

    Trying to understand if we are seeing the same request in both cases.

    You can also try in main() with the real username

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    2 minutes ago, petrkl12 said:

    @jompa68

     

    you can try to setup _HueTimeout=20000

    then it will work without error "Bad file descriptor"

    YEAH!!! :D

    Thanks @petrkl12

    Link to comment
    Share on other sites

  • Topic Author
  • 1 minute ago, jompa68 said:

    YEAH!!! :D

    Thanks @petrkl12

    Grrreat!, Thanks @petrkl12 Would have taken me ages to arrive at that... :-) 

    Link to comment
    Share on other sites

  • Topic Author
  • Just now, petrkl12 said:

    I think best way could be setup timeout=20000 as default value

    Well, sometimes when I'm at work and run the code offline and forgot to null _HueHubs (or node-red) it will hang for a long time ... :-)

    Isn't 20s a bit exaggerated? It takes 20s for a response? Could it be that all the other stuff that is going on in ER is starving the http request thread so it takes longer than what the actual response takes?

    Link to comment
    Share on other sites

    Based on my testing it is save value. I don't have any problems with responses ...

    Link to comment
    Share on other sites

    W dniu 16.02.2019 o 11:37, jgab napisał:

     

    So, a simple chat bot with Telegram that allows you to turn on and off devices in the HomeTable structure could look like this

    Please login or register to see this code.

    If we have a HomeTable like {dev={kitchen={lamp=88}, bedroom={lamp=99},back={garden=89}}}

    It returns the first match from the "bottom" of the HomeTable. Could add more checks if it is a device that can be turned on...

    Anyway, we can do commands like

    Please login or register to see this code.

    ...and it's easy to extend with other commands.

    For at least a couple of hours trying to set up telegram <=>HC2 without success, can someone help me with this?  

    what is the triger ? 

    Link to comment
    Share on other sites

    First, have you setup telegram in Node-red? I did struggle with bot setup first before i got it to work with chatID and so.

    Link to comment
    Share on other sites

    6 minut temu, jompa68 napisał:

    First, have you setup telegram in Node-red? I did struggle with bot setup first before i got it to work with chatID and so.

    The bot is set up, chat id is known, messages from telegram are visible in node red.

    I don't know how to trigger a role in ER...

     

    Edited by domin12
    Link to comment
    Share on other sites

    Good :)

    Here is code i use in a separated scene for Telegram. I can send for example "set testvar to test1234" and get a response back.

    put inside main()

     

    Please login or register to see this code.

     

    remember to set sceneID in NR

    image.png.e748dfe4398948cb98b8bdbaa70607ce.png

    Link to comment
    Share on other sites

  • Topic Author
  • 6 minutes ago, jompa68 said:

    Good :)

    Here is code i use in a separated scene for Telegram. I can send for example "set testvar to test1234" and get a response back.

    put inside main()

     

     

    remember to set sceneID in NR

     

     

    or msg.ESceneID=-1 if you want to send to the PC while testing. You also need to setup the ZBS node with the ip and port of the PC (6872)

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