Jump to content

Recommended Posts

  • Replies 103
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

This is a thread for the fibaroapiHC3.lua sdk that is under development (keeping it separate from the HC3 QuickApps coding - tips and tricks thread) I've started to run and test HC3 QuickApps off

Here is a post with some notes on the implementation of the SDK.   The overall components looks like this From a scene or a quickapp you interact with the HC3 using the fibaro.*()

New version v0.120. Hopefully this version is usable in Visual Studio (Windows) thanks to debugging effort from @10der.    Besides being an emulator for the HC3, fibaroapiHC3.lua is als

Posted Images

Did you get the mqtt library installed OK ?

Or you mean you are using IF's to not execute any mqtt statements offline ?

 

Our posts overlapped sorry - what OS are you running ZeroBrane on ?

Edited by xAPPO
Link to post
Share on other sites
17 minutes ago, xAPPO said:

Did you get the mqtt library installed OK ?

Or you mean you are using IF's to not execute any mqtt statements offline ?

 

Our posts overlapped sorry - what OS are you running ZeroBrane on ?

no. I am chuck norris

Link to post
Share on other sites
20 minutes ago, 10der said:

@jgab Jan 

another issue

 

image.png.7cdf3af5b1153c02b1b80f996b0562a3.png

 

I can't see any ":" in the code - this piece of code has compiled for months - must be some evil char that have sneaked into your source.

Link to post
Share on other sites
42 minutes ago, 10der said:

image.thumb.png.8667e46e0e0fbf9a8f89232dada01ec9.png

 

You need to change the way you include the emulator

if require and not hc3_emulator then
  require("fibaro")
end

...otherwise you get an infinite loop.

 

Link to post
Share on other sites
12 minutes ago, 10der said:

Jan. thank you.

fixed.

 

so. luamqtt doesn't work in VSCode.

attached lib works. but I re-wrote (cuz uncompatibile) your code :(

 

mqtt_lua-master.zip 123.74 kB · 0 downloads

Why doesn't it work? Is it some lib? like luasocket?

Link to post
Share on other sites

ok. trying to debug.

btw: simple lib what i attached worls like a charm

 

image.thumb.png.e786285c6935b2dd913187ae2e626966.png

Link to post
Share on other sites
18 minutes ago, 10der said:

ok. trying to debug.

btw: simple lib what i attached worls like a charm

 

image.thumb.png.e786285c6935b2dd913187ae2e626966.png

Ok, I will have look at the library and see if I can use it instead.

Link to post
Share on other sites

@jgab fixed luamqtt installation fro VSCode

 

now i have this blad.

[19.07.2020] [23:13:14] |ERROR|: MQTT error:failed to open network connection: socket.connect failed: host or service not provided, or not known

Link to post
Share on other sites

UPD
 

mqtt://192.168.1.10:1883

 

self.client = mqtt.Client.connect("192.168.1.10", {clientId = "HC3"})

 

 

[19.07.2020] [23:20:07] |[34;1mSDBG |: MQTT connect:{"rc":0,"type":2,"sp":false}
[19.07.2020] [23:20:12] [DEBUG]: connected: {"returnCode":0,"sessionPresent":false}

 

[19.07.2020] [23:20:17] |[34;1mSDBG |: MQTT close:{"close_reason":"connection closed by broker","connack":{"type":2,"rc":0,"sp":false},"coro":thread: 

 

Edited by 10der
Link to post
Share on other sites

UPD2: all OK!

just clientID already was busy by own app. 

 

image.thumb.png.1058b2c9f7bf6f14e51abd16fb77a7c2.png

Link to post
Share on other sites

so, RTFM for windows VSCode users

 

1) download luamqtt-master.zip 

2) unpack to mqtt folder from zip mqtt folder (sorry for tautology)

3) create mqtt.lua file

image.png.a7f6477629f5e625f00971cdb156b34b.png

with context

return require("mqtt.init")

happy debugging!

 

Link to post
Share on other sites

After F/W upgrade to 5.040.37..

mainFunction  now invisible.

Yes. Can't edit via api.post()

Link to post
Share on other sites

click in the main file left .. this version supports multifile QAs. Once clicked you should see content and be able to save, so the selection stays in saved QA.

  • Like 1
Link to post
Share on other sites
Posted (edited)
1 hour ago, rangee said:

After F/W upgrade to 5.040.37..

mainFunction  now invisible.

Yes. Can't edit via api.post()

Yes, the quickApp's code management have become more sophisticated. I need to update the way I deal with it in the emulator. The good news is that I believe what we got is much better....

Edited by jgab
Link to post
Share on other sites
2 minutes ago, jgab said:

Yes, the quickApp's code management have become more sophisticated. I need to update the way I deal with it in the emulator. The good news is that I believe what we got is much better....

I think this is preparation of QA encryption.

To encrypt the code, it need to be invisible via any way.

 

QA editor  consists of main file and additional files(eg. test1)

 

QA loads   test1, test2 and finally  main file.

main file loaded at last.

test1, test2, main   these 3 files are cooperative but works independently.

I mean...

test1's local var, fun   cannot call at  test2, main.

 

test1's   function Quickapp:method is callable at main.

 

Link to post
Share on other sites
Posted (edited)
1 hour ago, rangee said:

QA editor  consists of main file and additional files(eg. test1)

QA loads   test1, test2 and finally  main file.

main file loaded at last.

test1, test2, main   these 3 files are cooperative but works independently.

I mean...

test1's local var, fun   cannot call at  test2, main.

test1's   function Quickapp:method is callable at main.

 

So they share the global environment and not locals, and that is expected.

Yes it seems like 'main' (that can't be removed) is run last. The rest of the files seems to be loaded in order, top to bottom.

If I have 3 files:

File 'main':  print("A1") function QuickApp:onInit() self:debug("A1") end

File 'test1': print("B1")

File 'test2': print("C1")

 

I get the log:

[23.07.2020] [22:23:32] [DEBUG] [QUICKAPP1333]: B1

[23.07.2020] [22:23:32] [DEBUG] [QUICKAPP1333]: C1

[23.07.2020] [22:23:32] [DEBUG] [QUICKAPP1333]: A1

[23.07.2020] [22:23:32] [DEBUG] [QUICKAPP1333]: B1

[23.07.2020] [22:23:32] [DEBUG] [QUICKAPP1333]: C1

[23.07.2020] [22:23:32] [DEBUG] [QUICKAPP1333]: A1

 

Which looks like they load all the files twice(!) - be aware to not have commands that execute directly in your files - like the prints in my example... 

However, it's only when we save the QA - if it restarts due to a crash it only loads the files once.

Edited by jgab
Link to post
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...