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

Posted

Please login or register to see this image.

/monthly_2020_05/image.png.50fc69674d319c133e27c4419eb27e29.png" />image.png.82c6282a5a90a68abe25730a7faf65f7.png

 

 

image.png.de5a0d92bec1055e7f4072a3c141254e.png

 

image.png.1d61bcb3641e254c8b9a2375ddf745bc.png

 

 

Please login or register to see this attachment.

 

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

  • Like 2
Posted

I was thinking to store 2 files for each QA (and scene)

QA_<ID>.lua with the Lua code (maybe annotated with the fibaroapiHC3.lua intro/outro)

QA_<ID>.rsrc being the original json struct (but pretty printed to make it easier to eventually edit - like the layout)

Then a restore command deploy/restore command that combine them to a .fqa and upload them to the HC3.

 

Because we don't have a clean format we need some kind of resource fork. However, it's really nice with a flat file format that is easily edited.

Alternatively, we come up with some format that can be included in a comment in the code that describe the other properties like layout and quickvars and type etc.

Similar to what I attempted with

Please login or register to see this link.

>

Please login or register to see this code.

 

 

Posted (edited)

That makes three of us working on this ;) I think splitting Lua scenes in "conditions" and "code" like @10der did is the way to go, but the conditions are "json" and not lua (check extension)

Keep in mind though block scenes are JSON only ("actions" is array instead of Lua). Edit: If it's a block scene the conditions part is a json struct. If it's a lua scene it's a Lua table. At the moment I do not split scenes anymore.

 

I name my scenes based on ID and name, eg SC0042_BatteryCheck_v5.json but I've thought about using directories instead, because I think whatever we try to export on HC3 will end up as more than one file, but you might need all of those files to get back the original.

 

FQA's ... I export both the output of the device API and the FQA. There is a lot of overlap...

 

 

Edited by petergebruers
  • Topic Author
  • Posted
    4 minutes ago, petergebruers said:

    Keep in mind though block scenes are JSON only ("actions" is array instead of Lua)

    Peter,  with all due respect to you

    Please login or register to see this link.

    it's NOT JSON

    Please login or register to see this image.

    /monthly_2020_05/image.png.ad9f53874dbfd89cc3ab56aeade6ac0f.png" />

     

    just proof

    Please login or register to see this attachment.

     

     

    what did I miss?!

     

     

  • Topic Author
  • Posted

    OMG!

     

    New notations in ECMAScript 2015

     

     

    Please login or register to see this code.

     

    Posted (edited)

    Oops! I am talking nonsense I guess ;) Big Oops! Those are Lua tables, aren't they? Edit: If it's a block scene the conditions part is a json struct. If it's a lua scene it's a Lua table.

    Edited by petergebruers
    • Thanks 1
  • Topic Author
  • Posted

    but no

     

    Please login or register to see this code.

    it's WRONG JS!!

     

    1 minute ago, petergebruers said:

    Those are Lua tables, aren't they?

    yep Sir!

    it''s LUA ? 

    Posted
    2 minutes ago, 10der said:

    yep Sir!

    it''s LUA ? 

    Yeah, sorry, my bad. I am programming an ESP8266 to connect a PM2.5 dust sensor and my brain is all messed up with C++ :D

  • Topic Author
  • Posted
    7 minutes ago, petergebruers said:

    Yeah, sorry, my bad. I am programming an ESP8266 to connect a PM2.5 dust sensor and my brain is all messed up with C++ :D

    O!!!!!!!! please share your code in PM. please.

    pm2.5 was delivered from alie yesterday...

    Posted

    Hi,

     

    What do you think about this ?

     

     

    • multiplatform
    • can access remote controllers
    • configurable
    • lots of good things to come :)

     

    image.png.78059720d43614cd6c1044610d89af22.png

     

    image.png.a27cbeddc185f5c0ae9059b54638203c.png

     

    image.png.33254bd4c3bcd9b7dbd86c0fdef6e61d.png

     

     

     

    image.png.740bf5165f9ffb1a9b47c8442e97890b.png

     

    • Like 2
    • Thanks 1
  • Topic Author
  • Posted

    cool!

    Posted

    One thing I worry about (without having a clear answer) is the restrictions of filenames on different platforms. For example, ? (question mark) is valid on Mac but available on windows. And then there is case sensitive, case preserving issue. Maybe "?" is not the best example, it may be more about UTF support. It is a mess ;) - I bet the source code of "Syncthing" can learn us something in that respect. I run Syncthing on linux/max/windows and it is tricky sometimes (it has the potential to delete entire directories because of naming issues)

    Posted
    12 minutes ago, petergebruers said:

    One thing I worry about (without having a clear answer) is the restrictions of filenames on different platforms.

     

    I will test on different platforms ;)

     

    • Thanks 2
  • Topic Author
  • Posted

    Python (3)

    cross platformed

    support UTF

    no issues on win

     

    • Like 1
    Posted
    1 minute ago, Krikroff said:

    I will test on different platforms ;)

    Awesome!

     

    1 minute ago, 10der said:

    no issues on win

    Generally speaking "no issues" but that "?" issue is an O/S thing so no language can work around that...

    Posted
    8 minutes ago, 10der said:

    Python (3)

    cross platformed

    support UTF

    no issues on win

     

     

    The two projects can coexist no worries, on the contrary it's cool :)

     

  • Topic Author
  • Posted

    No your project win ;) 

    All ok I just share idea 

    Posted

    So, I'm downloading and uploading QuickApps today. The format is a flat form.

    For backup purposes I have settled on the same flat format where I put device struct in a comment at the end of the file.

    Please login or register to see this attachment.

    I have no opinion on what to name the files.

     

    Then I have functions that convert between. format - including the "upload" format of QuickApps.

    I kind of like the flat format as it's easier to keep in sync and allows for easy edit/debug workflow. Edit and upload (including modifying struct. properties)

    Planning the same for scenes.

    Please login or register to see this code.

    Running it gives

    Please login or register to see this code.

     

    • Like 1
  • Topic Author
  • Posted

    Jan, I hope Fibaro will make a native tools for it ;) 

    Posted (edited)
    2 hours ago, jgab said:

    The format is a flat form.

    I like it. The funny thing though is this: the HC2 had "triggers" as comments at the top of the scene code, then HC3 moves away from this and has separate edit windows for condition and action.

    The trouble with JSON is ... it needs special diff tool, it does not work well when using classic text diff/merge. Sorting the keys/values might help, I have never tried. Same issue with Lua tables and key/value stores in other languages, they do not define a fixed order (most people assume by that "insertion order" and some "alphabetical order") by design. After all it does not matter if you say "a=1; b=2;" or "b=2; a=1;" when that text represents k/v pairs.

    Edited by petergebruers

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