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


HC3 QuickApps coding - tips and tricks


jgab

Recommended Posts

not that i don't like the Sonos Zone Controller by @Krikroff , however i found out, that some users / situations need simple Sonos Player, in most cases just "play from stream", "play from cifs", "setVolume", etc.

 

Therefore attached (i placed it in marketplace as well, wating for validation) Moved to marketplace now - simple Sonos Player, for exact such simple things. 

 

I don't need to know what is playing, nor any Sonos informations, i need spped and simple usage, with block scenes and some triggers things of course.

Description:

 

Please login or register to see this spoiler.

 

Btw, no TTS, sorry, create your fav. mp3 with your fav. voice and save it somewhere in your lan. This is faster and don't need any internet based things.

 

EDIT: Moved to marketplace:

 

Please login or register to see this link.

 

 

Please login or register to see this attachment.

 

Edited by tinman
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

21 minutes ago, tinman said:

-- or when "TRANSITIONING" after "PLAYING" change source (e.g. ding dong played once , than radio/cifs stream

@tinman,

What a nice QA ?

Like many people I just want to play dingdong.mp3, residing on my PC. How to play dingdong using your QA?

And how to return to the music playing, which was interrupted by dingdong?

Link to comment
Share on other sites

3 minutes ago, Rover said:

@tinman,

What a nice QA ?

Like many people I just want to play dingdong.mp3, residing on my PC. How to play dingdong using your QA?

And how to return to the music playing, which was interrupted by dingdong?

 

most ppl play just some radio stream, so when ding-dong.mp3 will get played, one can check (when it ends) with the "TRANSITIONING" trigger and start again playFromUri(yourradiostation). The ding-dong.mp3 will not be added into playlist, the playlist stops at the last track (if there was one, if radio id does not matter). In principle one could add track check here, and position .. but exactly this is what i don't need, as it eats resources and need more code - and the Zone Controller is here better solution.

Link to comment
Share on other sites

3 minutes ago, tinman said:

 

most ppl play just some radio stream, so when ding-dong.mp3 will get played, one can check (when it ends) with the "TRANSITIONING" trigger and start again playFromUri(yourradiostation). The ding-dong.mp3 will not be added into playlist, the playlist stops at the last track (if there was one, if radio id does not matter). In principle one could add track check here, and position .. but exactly this is what i don't need, as it eats resources and need more code - and the Zone Controller is here better solution.

Like many people I just want to play dingdong.mp3, residing on my PC. How to play dingdong using your QA?

Link to comment
Share on other sites

1 hour ago, Rover said:

Like many people I just want to play dingdong.mp3, residing on my PC. How to play dingdong using your QA?

 

example is inside the QA, in principle very simple:

 

Please login or register to see this code.

One can get/save the last played URI (e.g. to play it after ding-dong.mp3)

 

Please login or register to see this code.

 

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

14 hours ago, tinman said:

-- play some mp3 from network share fibaro.call(SonosQAID, "playFromCIFS","192.168.199.33/2Pac/Me and My Girlfriend.mp3")

Test scene delivers no sound

Please login or register to see this spoiler.

State is at all positions STOPPED

While file://///192.168.1.3/d/SonosGeluiden/Deurbel.mp3 in browser delivers sound (in PC of course, not in Sonos).

Link to comment
Share on other sites

1 minute ago, Rover said:

Test scene delivers no sound

 

While file://///192.168.1.3/d/SonosGeluiden/Deurbel.mp3 in browser delivers sound (in PC of course, not in Sonos).

 

and you have added that path to sonos media lib and can play that file from Sonos App?

Link to comment
Share on other sites

5 minutes ago, tinman said:

 

and you have added that path to sonos media lib and can play that file from Sonos App?

In HC2 with Krikroff's VD's Sonos Player and TTS :

fibaro:setGlobal("huiskamersonos","//Mediacenter/d/Sonosgeluiden/deurbel.mp3")
    fibaro:call(jT.VD.TTSHuiskamer, "pressButton", "1")

works nicely for many years.

Link to comment
Share on other sites

no idea, check if you can play from Sonos App. It works for me, and it does deliver status

 

Please login or register to see this image.

/monthly_2020_09/image.png.0fdfaa91c7a339d11157cb5748bc6194.png" />

 

image.png.1ef1996234de7dd25825a02a280f79d8.png

 

BTw, you don't need any "play" extra, playFromCIFS and playFromUri starts it automatically.

 

image.png.db61603dda3a687fc95db1866af917e7.png

 

EDIT: some hint for other with similar issues, name != IP, so try both.

Edited by tinman
Link to comment
Share on other sites

fibaro:setGlobal("huiskamersonos","//Mediacenter/d/Sonosgeluiden/deurbel.mp3")

 

vs.

 

fibaro.call(115, "playFromCIFS","192.168.1.3/d/SonosGeluiden/Deurbel.mp3")

Edited by tinman
Link to comment
Share on other sites

 [27.09.2020] [16:48:11] [DEBUG] [QUICKAPP115]: onAction: {"deviceId":115,"actionName":"playFromCIFS","args":["192.168.1.3\/d\/SonosGeluiden\/Deurbel.mp3"]}

Do not look good, is not it?

41 minutes ago, tinman said:

fibaro:setGlobal("huiskamersonos","//Mediacenter/d/Sonosgeluiden/deurbel.mp3")

 

vs.

 

fibaro.call(115, "playFromCIFS","192.168.1.3/d/SonosGeluiden/Deurbel.mp3")

Please login or register to see this spoiler.

does the same: STOPPED

Link to comment
Share on other sites

I found   "Device" class..

Fibaro uses "Device" class as QuickApp Device.

Maybe.. there will be more classes...

Please login or register to see this code.

 

Link to comment
Share on other sites

  • Topic Author
  • 27 minutes ago, rangee said:

    I found   "Device" class..

    Fibaro uses "Device" class as QuickApp Device.

    Maybe.. there will be more classes...

    Please login or register to see this code.

     

    QuickApp inherits from QuickAppBase that inherits  from Device. I don’t think that Device is so useful standalone.

    Link to comment
    Share on other sites

    3 minutes ago, jgab said:

    QuickApp inherits from QuickAppBase that inherits  from Device. I don’t think that Device is so useful standalone.

    Oh. wow..

    Device - QuickAppBase - QuickApp - QuickAppChild.

     

    Your right. I agree with you.

     

    is it still unavailable making viewlayout at QuickAppChild devices?

    Link to comment
    Share on other sites

    Hello all,

     

    In the QA editor on the left there are two icons, a cube and a list, after pressing the list icon it is possible to add extra lua files.

    I searched allover this forum, maybe somewhere there is a manual but i did not find it.

     

    I think one can use this for splitting a big lua file in more readable sections (main, menu, screen,devices,calculate,etc)

    But how do i call the functions?

     

    I tried changing the function name, i used the filename instead of self,

    so i typed 'menu:Blahblah(12)' in the main file to call a function in the 'menu lua file' but that does not work.

    Link to comment
    Share on other sites

  • Topic Author
  • 11 hours ago, xirilius said:

    Hello all,

     

    In the QA editor on the left there are two icons, a cube and a list, after pressing the list icon it is possible to add extra lua files.

    I searched allover this forum, maybe somewhere there is a manual but i did not find it.

     

    I think one can use this for splitting a big lua file in more readable sections (main, menu, screen,devices,calculate,etc)

    But how do i call the functions?

     

    I tried changing the function name, i used the filename instead of self,

    so i typed 'menu:Blahblah(12)' in the main file to call a function in the 'menu lua file' but that does not work.

    Yes it works like a lua

    Please login or register to see this link.

     

    It means that you can only share Lua global functions and variables. Local declared symbols will not be accessible.

    Ex.

    "main":

    Please login or register to see this code.

     

    "myFile":

    Please login or register to see this code.

    You have to be a bit careful because you can't be sure in what order the files are loaded. That's why in the example we call foo inside 'onInit' because we know that the QA code is loaded (all files) then and the QA is ready to start.

     

    A way to control the load order and also optionally load a file is to define a "module" structure...

    "main":

    Please login or register to see this code.

     

    "fileA:"

    Please login or register to see this code.

     

    "fileB":

    Please login or register to see this code.

    Lots of things going on in this last example. We have two library files, fileA and fileB. We need to load fileB before fileA because fileA uses a function in fileB (setupX).

    Each library file define all their functions within a "load" function that allows our "main" to load them in the order needed and not depend on the order the QA decides to load them.

    fileA also adds a "QuickApp" function. However we can't define QuickApp:bar() inside loadA() because the QuickApp is already created by then. However we can add it directly to 'self' so we get access to it the way we expect. This means that "main" when calling loadA and loadB sends its 'self' as argument so the module/library can add functions and variables to self it they need.

     

    I'm using a module system for my own library files

     

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

    @tinman Tnx! fo sonos QA.

     

    somethims i do not need any UI at all + I have some Sonos in my house.

    here is device base of sources by Tin.

     

    Please login or register to see this code.

    so, 

     

    local dev = SonosDevice("192.168.1.70"1400)
    -- for network share source:
    dev:playFromCIFS("192.168.1.29/Multimedia/Music/Ding.mp3")

     

    or if you wrap this code to QA

     

    add as first param IP address for Sonos

     

    PS: yes I canse create 10500 QAs according count of my Sonos but this method more elegant as for me

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

  • Topic Author
  • 5 minutes ago, 10der said:

    @tinman Tnx! fo sonos QA.

     

    somethims i do not need any UI at all + I have some Sonos in my house.

    local dev = SonosDevice("192.168.1.70"1400)
    -- for network share source:
    dev:playFromCIFS("192.168.1.29/Multimedia/Music/Ding.mp3")

     

    or if you wrap this code to QA

     

    add as first param IP address for Sonos

    Or a good candidate to include in a QA “library” file. I may include it in my ER4 to get Sonos support...

    • Like 1
    • Thanks 1
    Link to comment
    Share on other sites

    I have patched @tinman code with separated "device"

    now 

    dev:playFromCIFS

    or

    dev:playFromUri

    not removed the current queue playing.

    so if you now listen Ozyy Osbourne and HC3 playing notification now it lok like


     

    Quote

     

    But, I can't stand to say goodbye
    Mama, I'm [HC3 DING-DONG] coming home

    ...

     


     

     

    :) 

     

    Please login or register to see this code.

     

    • Like 1
    Link to comment
    Share on other sites

    On 10/3/2020 at 2:22 PM, 10der said:

    @tinman Tnx! fo sonos QA.

    you're welcome

     

    Quote

    somethims i do not need any UI at all + I have some Sonos in my house.

     

    Please login or register to see this code.

     

     

    actually updating not existing propery will create error in logs, each time one change it:

     

    Please login or register to see this image.

    /monthly_2020_10/image.png.809b1483f44d1132a7a7c622d1903c19.png" />

     

    Oct  3 16:10:25 HC3-00000691 HCServer[4118]: 14:10:25:185902#033[1;32m [Error] #011LOADER: [setProperty @Device.cpp:1632] [Device::setProperty] deviceId=<106> propertyName=<logflood> device property doesn't exist, update ignored #033[0m
    Oct  3 16:10:25 HC3-00000691 HCServer: 4118 185902 [Error] TCPServerConnection ([#26]) LOADER [setProperty @Device.cpp:1632] [Device::setProperty] deviceId=<106> propertyName=<logflood> device property doesn't exist, update ignored

     

    I think loud, maybe is better idea to check the code on real HC3, normally your should get immediately errors with self:updateProperty within your SonosDevice class, in worst case hidden from ui (but still flooding HC3: deviceId: 118 Unknown error occurred: no static 'updateProperty' in class 'SonosDevice' )

     

     

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